Skip to content

Commit

Permalink
BASIRA #275 - Adjusting style of value list tabs to allow scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
dleadbetter committed Dec 12, 2024
1 parent 09fdfb7 commit c2e950a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
4 changes: 4 additions & 0 deletions client/src/pages/admin/ValueLists.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.value-lists > .tab > .ui.menu {
overflow: auto;
padding-bottom: 0.25em;
}
59 changes: 41 additions & 18 deletions client/src/pages/admin/ValueLists.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// @flow

import type { EditContainerProps } from '@performant-software/shared-components/types';
import React, { useEffect, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Container, Header, Tab } from 'semantic-ui-react';
import _ from 'underscore';
import ValueListsTable from '../../components/ValueListsTable';
import withMenuBar from '../../hooks/MenuBar';
import ValueListsService from '../../services/ValueLists';
import {
Container,
Header,
Tab
} from 'semantic-ui-react';
import './ValueLists.css';

import type { ValueList as ValueListType } from '../../types/ValueList';
import type { Translateable } from '../../types/Translateable';
Expand All @@ -21,24 +19,49 @@ type Props = EditContainerProps & Translateable & {
const ValueLists = (props: Props) => {
const [objectsList, setObjectsList] = useState([]);

useEffect(() => {
ValueListsService.getObjectsList()
.then((response) => setObjectsList(response.data.objects));
}, []);

const panes = objectsList.map((objectName) => ({
/**
* Memo-izes the tab panes.
*
* @type {{menuItem: *, render: function(): *}[]}
*/
const panes = useMemo(() => objectsList.map((objectName) => ({
menuItem: objectName,
render: () => (
<Tab.Pane attached={false}>
<ValueListsTable objectName={objectName} />
<Tab.Pane
attached={false}
>
<ValueListsTable
objectName={objectName}
/>
</Tab.Pane>
)
}));
})), [objectsList]);

/**
* Sets the tab list on the state.
*/
useEffect(() => {
ValueListsService
.getObjectsList()
.then((response) => setObjectsList(response.data.objects))
}, []);

return (
<Container>
<Header as='h2'>{props.t('Admin.menu.valueLists')}</Header>
<Tab menu={{ secondary: true, pointing: true }} panes={panes} />
<Container
className='value-lists'
>
<Header
as='h2'
>
{ props.t('Admin.menu.valueLists') }
</Header>
<Tab
className='tab'
menu={{
secondary: true
}}
panes={panes}
/>
</Container>
);
};
Expand Down

0 comments on commit c2e950a

Please sign in to comment.