Skip to content

Commit

Permalink
Merge pull request #19 from dhis2/feat/DHIS2-11290
Browse files Browse the repository at this point in the history
feat: add datasets navigation
  • Loading branch information
mediremi authored Jul 7, 2021
2 parents ad26f53 + d6d290e commit 9e5823d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/data-workspace/data-workspace.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from 'react'
import React, { useState } from 'react'
import { useWorkflowContext } from '../workflow-context/index.js'
import { Navigation } from './navigation.js'
import { TitleBar } from './title-bar.js'

const DataWorkspace = () => {
const workflow = useWorkflowContext()
const [selectedDataSet, setSelectedDataSet] = useState(
workflow.dataSets.length === 1 ? workflow.dataSets[0].id : null
)

return (
<>
Expand All @@ -12,6 +16,11 @@ const DataWorkspace = () => {
dataSetsCount={workflow.dataSets.length}
approvalState={workflow.approvalStatus.state}
/>
<Navigation
dataSets={workflow.dataSets}
selected={selectedDataSet}
onChange={setSelectedDataSet}
/>
</>
)
}
Expand Down
25 changes: 25 additions & 0 deletions src/data-workspace/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { TabBar, Tab } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'

const Navigation = ({ dataSets, selected, onChange }) => (
<TabBar scrollable>
{dataSets.map(dataSet => (
<Tab
key={dataSet.id}
onClick={() => onChange(dataSet.id)}
selected={dataSet.id === selected}
>
{dataSet.displayName}
</Tab>
))}
</TabBar>
)

Navigation.propTypes = {
dataSets: PropTypes.array.isRequired,
onChange: PropTypes.func.isRequired,
selected: PropTypes.string,
}

export { Navigation }
1 change: 1 addition & 0 deletions src/data-workspace/title-bar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
grid-template-columns: max-content max-content max-content;
align-items: center;
grid-gap: var(--spacers-dp12);
margin-bottom: var(--spacers-dp12);
}

.workflowName {
Expand Down

0 comments on commit 9e5823d

Please sign in to comment.