Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit

Permalink
Merge pull request #578 from BlueBrain/Update-project-menu
Browse files Browse the repository at this point in the history
Create project menu component
  • Loading branch information
Stafeeva authored Feb 25, 2020
2 parents 8fea143 + 6fd4635 commit ff37958
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 84 deletions.
14 changes: 13 additions & 1 deletion src/shared/App.less
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
}

.studio-modal {
margin: 20px 0 0;
margin: 5px 0 0;
}

.studio-resource-view {
Expand Down Expand Up @@ -135,3 +135,15 @@
padding: 8px 16px;
margin-bottom: 8px;
}

.project-menu {
&__content {
padding: 6px;
width: 280px;
}

&__controls {
display: flex;
flex-direction: column;
}
}
48 changes: 36 additions & 12 deletions src/shared/components/Menu/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,26 @@ const ANIMATIONS = {
export interface SideMenuProps {
title?: string;
visible: boolean;
onClose: () => void;
onClose?: () => void;
side?: 'left' | 'right';
tabList?: any;
activeTabKey?: any;
tabBarExtraContent?: any;
onTabChange?: (key: string) => void;
}

const SideMenu: React.FunctionComponent<SideMenuProps> = props => {
const { title, children, visible, onClose, side = 'right' } = props;
const {
title,
children,
visible,
onClose,
side = 'right',
tabList,
activeTabKey,
tabBarExtraContent,
onTabChange,
} = props;
const transitions = useTransition(visible, null, ANIMATIONS[side]);
return (
<>
Expand All @@ -34,17 +48,27 @@ const SideMenu: React.FunctionComponent<SideMenuProps> = props => {
<animated.div className="side-menu" style={props} key={key}>
<Card
title={
<div className="header">
{!!title && <div className="ant-drawer-title">{title}</div>}
<button
className="ant-drawer-close"
aria-label="Close"
onClick={onClose}
>
<Icon type="close" />
</button>
</div>
(title || onClose) && (
<div className="header">
{!!title && (
<div className="ant-drawer-title">{title}</div>
)}
{!!onClose && (
<button
className="ant-drawer-close"
aria-label="Close"
onClick={onClose}
>
<Icon type="close" />
</button>
)}
</div>
)
}
tabList={tabList}
activeTabKey={activeTabKey}
tabBarExtraContent={tabBarExtraContent}
onTabChange={onTabChange}
size="small"
bordered={false}
>
Expand Down
3 changes: 2 additions & 1 deletion src/shared/components/Studio/Studio.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
.label {
.ellipsis();
font-weight: bold;
color: @text-color;
color: @primary-color;
margin-bottom: 6px;
}

.description {
Expand Down
5 changes: 2 additions & 3 deletions src/shared/components/Studio/StudioList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { Empty, Spin } from 'antd';
import { Spin } from 'antd';

import useMeasure from '../../hooks/useMeasure';
import ListItem from '../List/Item';
import InfiniteSearch from '../List/InfiniteSearch';

Expand Down Expand Up @@ -53,7 +52,7 @@ const StudioList: React.FC<{
dataLength={studios.length}
onLoadMore={onLoadMore}
hasMore={hasMore}
height={500}
height={340}
defaultSearchValue={searchQuery}
>
{studios.map(studio => {
Expand Down
95 changes: 95 additions & 0 deletions src/shared/containers/ProjectMenuContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import * as React from 'react';
import { AccessControl } from '@bbp/react-nexus';
import { Link } from 'react-router-dom';
import { Divider, Button } from 'antd';

import SideMenu from '../components/Menu/SideMenu';
import FileUploadContainer from '../containers/FileUploadContainer';
import ResourceFormContainer from '../containers/ResourceFormContainer';
import StudioListContainer from '../containers/StudioListContainer';

const ProjectMenuContainer: React.FunctionComponent<{
menuVisible: boolean;
setMenuVisible: (value: boolean) => void;
orgLabel: string;
projectLabel: string;
}> = ({ menuVisible, orgLabel, projectLabel, setMenuVisible }) => {
const [activeResourceMenuTab, setActiveResourceMenuTab] = React.useState(
'resources'
);

const tabList = [
{
key: 'resources',
tab: 'Resources',
},
{
key: 'studios',
tab: 'Studios',
},
];

const menuContentList: { [key: string]: any } = {
resources: [
<p>
View resources in your project using pre-defined query-helper lists.
</p>,
<div className="project-menu__controls">
<AccessControl
path={`/${orgLabel}/${projectLabel}`}
permissions={['resources/write']}
>
<ResourceFormContainer
orgLabel={orgLabel}
projectLabel={projectLabel}
/>
</AccessControl>
<Link to={`/${orgLabel}/${projectLabel}/nxv:defaultSparqlIndex/sparql`}>
Sparql Query Editor
</Link>
<Link
to={`/${orgLabel}/${projectLabel}/nxv:defaultElasticSearchIndex/_search`}
>
ElasticSearch Query Editor
</Link>
<Link to={`/${orgLabel}/${projectLabel}/_settings/acls`}>
View Project's permissions
</Link>
</div>,
<AccessControl
path={`/${orgLabel}/${projectLabel}`}
permissions={['files/write']}
>
<Divider />
<FileUploadContainer projectLabel={projectLabel} orgLabel={orgLabel} />
</AccessControl>,
],
studios: (
<StudioListContainer orgLabel={orgLabel} projectLabel={projectLabel} />
),
};

return (
<div className="project-menu">
<SideMenu
visible={menuVisible}
tabList={tabList}
onTabChange={(key: string) => setActiveResourceMenuTab(key)}
activeTabKey={activeResourceMenuTab}
tabBarExtraContent={
<Button
icon="close"
onClick={() => setMenuVisible(false)}
style={{ border: 'none' }}
/>
}
>
<div className="project-menu__content">
{menuContentList[activeResourceMenuTab]}
</div>
</SideMenu>
</div>
);
};

export default ProjectMenuContainer;
76 changes: 9 additions & 67 deletions src/shared/views/ProjectView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import {
ProjectResponseCommon,
DEFAULT_ELASTIC_SEARCH_VIEW_ID,
} from '@bbp/nexus-sdk';
import { useNexusContext, AccessControl } from '@bbp/react-nexus';
import { notification, Popover, Divider, Switch, Tabs, Icon } from 'antd';
import { useNexusContext } from '@bbp/react-nexus';
import { notification, Popover, Switch, Icon } from 'antd';
import { Link } from 'react-router-dom';

import ViewStatisticsContainer from '../components/Views/ViewStatisticsProgress';
import SideMenu from '../components/Menu/SideMenu';
import FileUploadContainer from '../containers/FileUploadContainer';
import ResourceFormContainer from '../containers/ResourceFormContainer';
import ResourceListBoardContainer from '../containers/ResourceListBoardContainer';
import StudioListContainer from '../containers/StudioListContainer';
import HomeIcon from '../components/HomeIcon';

const { TabPane } = Tabs;
import ProjectMenuContainer from '../containers/ProjectMenuContainer';

const ProjectView: React.FunctionComponent<{
match: match<{ orgLabel: string; projectLabel: string }>;
Expand All @@ -38,9 +33,6 @@ const ProjectView: React.FunctionComponent<{

const [menuVisible, setMenuVisible] = React.useState(true);
const [refreshLists, setRefreshLists] = React.useState(false);
const [activeResourceMenuTab, setActiveResourceMenuTab] = React.useState(
'Resources'
);

React.useEffect(() => {
setState({
Expand Down Expand Up @@ -116,62 +108,12 @@ const ProjectView: React.FunctionComponent<{
checkedChildren={<Icon type="menu-unfold" />}
unCheckedChildren={<Icon type="menu-fold" />}
/>
<SideMenu
visible={menuVisible}
onClose={() => setMenuVisible(false)}
>
<Tabs
onChange={(key: string) => setActiveResourceMenuTab(key)}
activeKey={activeResourceMenuTab}
>
<TabPane tab="Resources" key="Resources">
<p>
View resources in your project using pre-defined
query-helper lists.
</p>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<AccessControl
path={`/${orgLabel}/${projectLabel}`}
permissions={['resources/write']}
>
<ResourceFormContainer
orgLabel={orgLabel}
projectLabel={projectLabel}
/>
</AccessControl>
<Link
to={`/${orgLabel}/${projectLabel}/nxv:defaultSparqlIndex/sparql`}
>
Sparql Query Editor
</Link>
<Link
to={`/${orgLabel}/${projectLabel}/nxv:defaultElasticSearchIndex/_search`}
>
ElasticSearch Query Editor
</Link>
<Link to={`/${orgLabel}/${projectLabel}/_settings/acls`}>
View Project's permissions
</Link>
</div>
<AccessControl
path={`/${orgLabel}/${projectLabel}`}
permissions={['files/write']}
>
<Divider />
<FileUploadContainer
projectLabel={projectLabel}
orgLabel={orgLabel}
/>
</AccessControl>
</TabPane>
<TabPane tab="Studios" key="Studios">
<StudioListContainer
orgLabel={orgLabel}
projectLabel={projectLabel}
/>
</TabPane>
</Tabs>
</SideMenu>
<ProjectMenuContainer
menuVisible={menuVisible}
setMenuVisible={setMenuVisible}
projectLabel={projectLabel}
orgLabel={orgLabel}
/>
</div>
</div>
<div className="list-board">
Expand Down

0 comments on commit ff37958

Please sign in to comment.