Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search: added communities status filter component #1857

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import {
ResultsLoader,
SearchBar,
} from "react-searchkit";
import { Grid, Menu, Modal } from "semantic-ui-react";
import { Grid, Modal } from "semantic-ui-react";
import { CommunityListItem } from "./CommunityListItem";
import PropTypes from "prop-types";
import { CommunitiesStatusFilter } from "@js/invenio_communities/community";

export class CommunitySelectionSearch extends Component {
constructor(props) {
Expand Down Expand Up @@ -50,7 +51,7 @@ export class CommunitySelectionSearch extends Component {
isInitialSubmission,
CommunityListItem,
pagination,
myCommunitiesEnabled,
communitiesStatusFilterEnabled,
autofocus,
} = this.props;

Expand All @@ -74,7 +75,7 @@ export class CommunitySelectionSearch extends Component {
>
<>
<Modal.Content as={Grid} className="m-0 pb-0 centered">
{myCommunitiesEnabled && (
{communitiesStatusFilterEnabled && (
<Grid.Column
mobile={16}
tablet={8}
Expand All @@ -83,47 +84,27 @@ export class CommunitySelectionSearch extends Component {
floated="left"
className="pt-0 pl-0"
>
<Menu role="tablist" className="theme-primary-menu" compact>
<Menu.Item
as="button"
role="tab"
id="all-communities-tab"
aria-selected={selectedAppId === allCommunities.appId}
aria-controls={allCommunities.appId}
name="All"
active={selectedAppId === allCommunities.appId}
onClick={() =>
this.setState({
selectedConfig: allCommunities,
})
}
>
{i18next.t("All")}
</Menu.Item>
<Menu.Item
as="button"
role="tab"
id="my-communities-tab"
aria-selected={selectedAppId === myCommunities.appId}
aria-controls={myCommunities.appId}
name="My communities"
active={selectedAppId === myCommunities.appId}
onClick={() =>
this.setState({
selectedConfig: myCommunities,
})
}
>
{i18next.t("My communities")}
</Menu.Item>
</Menu>
<CommunitiesStatusFilter
myCommunitiesOnClick={() => {
this.setState({
selectedConfig: myCommunities,
});
}}
allCommunitiesOnClick={() => {
this.setState({
selectedConfig: allCommunities,
});
}}
appId={selectedAppId}
allCommunitiesSelected={selectedAppId === allCommunities.appId}
/>
</Grid.Column>
)}
<Grid.Column
mobile={16}
tablet={8}
computer={8}
floated={myCommunitiesEnabled ? "right" : "null"}
floated={communitiesStatusFilterEnabled ? "right" : "null"}
verticalAlign="middle"
className="pt-0 pr-0 pl-0"
>
Expand Down Expand Up @@ -182,14 +163,14 @@ CommunitySelectionSearch.propTypes = {
isInitialSubmission: PropTypes.bool,
CommunityListItem: PropTypes.elementType,
pagination: PropTypes.bool,
myCommunitiesEnabled: PropTypes.bool,
communitiesStatusFilterEnabled: PropTypes.bool,
autofocus: PropTypes.bool,
};

CommunitySelectionSearch.defaultProps = {
isInitialSubmission: true,
pagination: true,
myCommunitiesEnabled: true,
communitiesStatusFilterEnabled: true,
autofocus: true,
CommunityListItem: CommunityListItem,
apiConfigs: {
Expand Down