This repository has been archived by the owner on Feb 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new components for
<ManageItemList/>
and <PopupItemList/>
Their Redux containers have gotten sufficiently-complex that it was time to create new React components to encapsulate this stuff.
- Loading branch information
Jim Porter
committed
Mar 21, 2018
1 parent
2b5e800
commit 99c55c7
Showing
5 changed files
with
105 additions
and
93 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/webextension/list/manage/components/manage-item-list.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { Localized } from "fluent-react"; | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
|
||
import ItemList, { ItemListPlaceholder } from "../../components/item-list"; | ||
|
||
export default function ManageItemList({totalItemCount, ...props}) { | ||
if (props.items.length === 0) { | ||
return ( | ||
<Localized id={`all-items-${totalItemCount ? "no-results" : | ||
"get-started"}`}> | ||
<ItemListPlaceholder> | ||
wHEn yOu cREATe an eNTRy... | ||
</ItemListPlaceholder> | ||
</Localized> | ||
); | ||
} | ||
return ( | ||
<ItemList {...props}/> | ||
); | ||
} | ||
|
||
ManageItemList.propTypes = { | ||
totalItemCount: PropTypes.number.isRequired, | ||
...ItemList.propTypes, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { Localized } from "fluent-react"; | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
|
||
import { PanelBanner } from "../../../widgets/panel"; | ||
import ItemList, { ItemListPlaceholder } from "../../components/item-list"; | ||
|
||
const MAX_VERBOSE_ITEMS = 2; | ||
|
||
import styles from "./popup-item-list.css"; | ||
|
||
export default class PopupItemList extends React.Component { | ||
static get propTypes() { | ||
return { | ||
items: ItemList.propTypes.items, | ||
noResultsBanner: PropTypes.bool, | ||
}; | ||
} | ||
|
||
static get defaultProps() { | ||
return { | ||
noResultsBanner: false, | ||
}; | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
selected: null, | ||
}; | ||
} | ||
|
||
handleChange(selected) { | ||
this.setState({selected}); | ||
} | ||
|
||
render() { | ||
const {items, noResultsBanner, ...props} = this.props; | ||
if (items.length === 0) { | ||
return ( | ||
<Localized id="all-items-no-results"> | ||
<ItemListPlaceholder> | ||
no rESULTs | ||
</ItemListPlaceholder> | ||
</Localized> | ||
); | ||
} | ||
|
||
const {selected} = this.state; | ||
const verbose = items.length <= MAX_VERBOSE_ITEMS; | ||
return ( | ||
<div className={styles.itemListContainer}> | ||
{noResultsBanner && ( | ||
<Localized id="no-results-banner"> | ||
<PanelBanner>no rESULTs</PanelBanner> | ||
</Localized> | ||
)} | ||
<ItemList {...props} items={items} className={styles.itemList} | ||
verbose={verbose} selected={selected} | ||
onChange={(s) => this.handleChange(s)}/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters