diff --git a/.gitignore b/.gitignore index 4d29575de80483b005c29bfcac5061cd2f45313e..eba48c4cade15575d91fa18c94065be3a69eb899 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +src/models/new diff --git a/.vscode/settings.json b/.vscode/settings.json index 2b2d38cd70ee5869e689220691ef286c1d701a37..8db7649b1b7e08e2b4d9f165e54e707890a504a7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "files.exclude": {} + "files.exclude": {}, + "editor.formatOnSave": true } diff --git a/src/components/Events/DataCollection.tsx b/src/components/Events/DataCollection.tsx index 4ac25d92f5be9cbebc7f460c7a3093619fa4d287..4ea3f054ac8e8afee6aca6786ee980e925cd8cf5 100644 --- a/src/components/Events/DataCollection.tsx +++ b/src/components/Events/DataCollection.tsx @@ -20,6 +20,7 @@ import SSX from './DataCollections/SSX/SSX'; import Map from './DataCollections/Mapping/Map'; import MapXAS from './DataCollections/Mapping/MapXAS'; import EnergyScan from './DataCollections/Mapping/EnergyScan'; +import { useUIOptions } from 'hooks/useUIOptions'; function renderInner({ item, @@ -73,6 +74,7 @@ export function DataCollectionBox( ) { const { item, parent, children, buttons, showProcessing = true } = props; const navigate = useNavigate(); + const uiOptions = useUIOptions(); const [showAttachments, setShowAttachments] = useState<boolean>(false); const [showReprocess, setShowReprocess] = useState<boolean>(false); @@ -136,12 +138,16 @@ export function DataCollectionBox( (props.messageStatuses?.errors === 0 && props.messageStatuses?.warnings === 0), }, - { - icon: <Gear />, - hint: 'Reprocess', - onClick: () => setShowReprocess(true), - hidden: parent.count > 1, - }, + ...(uiOptions.enableReprocessing + ? [ + { + icon: <Gear />, + hint: 'Reprocess', + onClick: () => setShowReprocess(true), + hidden: parent.count > 1, + }, + ] + : []), ] } /> diff --git a/src/components/Header.tsx b/src/components/Header.tsx index b159946ed759d9b361d7599104fbdadb2db7820b..d87803c0f75363fe37a5faeb9d3d86ec3323ba6f 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -9,6 +9,8 @@ import { useProposal } from 'hooks/useProposal'; import { useProposalInfo } from 'hooks/useProposalInfo'; import { useCurrentUser } from 'hooks/useCurrentUser'; import AuthErrorBoundary from './AuthErrorBoundary'; +import { useUIOptions } from 'hooks/useUIOptions'; +import useComponentsTitle from 'hooks/useComponentsTitle'; function PersonMenu() { const currentUser = useCurrentUser(); @@ -122,6 +124,8 @@ function PyHeader() { const { proposalName } = useProposal(); const proposalInfo = useProposalInfo(); const { pathname } = useLocation(); + const uiOptions = useUIOptions(); + const componentsTitle = useComponentsTitle(); return ( <> @@ -158,23 +162,27 @@ function PyHeader() { > Calendar </NavDropdown.Item> + {uiOptions.enableShipping && ( + <> + <NavDropdown.Item + as={NavLink} + to={`/proposals/${proposalName}/contacts`} + > + Contacts + </NavDropdown.Item> + <NavDropdown.Item + as={NavLink} + to={`/proposals/${proposalName}/shipments`} + > + Shipments + </NavDropdown.Item> + </> + )} <NavDropdown.Item as={NavLink} - to={`/proposals/${proposalName}/contacts`} - > - Contacts - </NavDropdown.Item> - <NavDropdown.Item - as={NavLink} - to={`/proposals/${proposalName}/shipments`} - > - Shipments - </NavDropdown.Item> - <NavDropdown.Item - as={NavLink} - to={`/proposals/${proposalName}/proteins`} + to={`/proposals/${proposalName}/${componentsTitle.toLowerCase()}`} > - Proteins + {componentsTitle} </NavDropdown.Item> <NavDropdown.Item as={NavLink} @@ -186,12 +194,20 @@ function PyHeader() { {proposalInfo && proposalInfo._metadata.uiGroups && proposalInfo._metadata.uiGroups.includes('mapping') && ( - <NavDropdown.Item - as={NavLink} - to={`/proposals/${proposalName}/samples/review`} - > - Sample Review - </NavDropdown.Item> + <> + <NavDropdown.Item + as={NavLink} + to={`/proposals/${proposalName}/queue`} + > + Acqusition Queue + </NavDropdown.Item> + <NavDropdown.Item + as={NavLink} + to={`/proposals/${proposalName}/samples/review`} + > + Sample Review + </NavDropdown.Item> + </> )} </> </NavDropdown> diff --git a/src/components/Proteins/ProteinsList.tsx b/src/components/Proteins/ProteinsList.tsx index 3e63623030dd1833a641407a5d22d7f17b2037d0..2e3aef0f0215447378a107bfce1c1f1237cd2fc2 100644 --- a/src/components/Proteins/ProteinsList.tsx +++ b/src/components/Proteins/ProteinsList.tsx @@ -9,6 +9,7 @@ import { usePath } from 'hooks/usePath'; import { usePaging } from 'hooks/usePaging'; import { useSearch } from 'hooks/useSearch'; import { enumBadge } from 'components/Layout/TableCells'; +import useComponentsTitle from 'hooks/useComponentsTitle'; export default function ProteinsList() { const [searchParams] = useSearchParams(); @@ -17,6 +18,7 @@ export default function ProteinsList() { const navigate = useNavigate(); const proposal = usePath('proposal'); const status = searchParams.get('status'); + const componentsTitle = useComponentsTitle(); const proteins = useSuspense(ProteinResource.getList, { skip, limit, @@ -26,7 +28,9 @@ export default function ProteinsList() { }); const onRowClick = (row: Protein) => { - navigate(`/proposals/${proposal}/proteins/${row.proteinId}`); + navigate( + `/proposals/${proposal}/${componentsTitle.toLowerCase()}/${row.proteinId}` + ); }; const safetyLevels = { @@ -37,7 +41,7 @@ export default function ProteinsList() { return ( <section> - <h1>Proteins</h1> + <h1>{componentsTitle}</h1> <Search focus /> <Table keyId="proteinId" diff --git a/src/hooks/useComponentsTitle.ts b/src/hooks/useComponentsTitle.ts new file mode 100644 index 0000000000000000000000000000000000000000..c0a973347770877366335b8f52dcbf2f5c670035 --- /dev/null +++ b/src/hooks/useComponentsTitle.ts @@ -0,0 +1,10 @@ +import { useProposalInfo } from './useProposalInfo'; + +export default function useComponentsTitle() { + const proposalInfo = useProposalInfo(); + return proposalInfo && + proposalInfo._metadata.uiGroups && + !proposalInfo._metadata.uiGroups.includes('mx') + ? 'Components' + : 'Proteins'; +} diff --git a/src/models/UIOptions.ts b/src/models/UIOptions.ts index 09a623d3ec99c54b7a88c72aca95da8fd5c28bd3..0adf92034b2dd3bb3b3592eafb10a652e83c01fd 100644 --- a/src/models/UIOptions.ts +++ b/src/models/UIOptions.ts @@ -33,6 +33,8 @@ export type SampleChangerCapacity = null | number; export type Archived = boolean; export type Beamlines = BeamLineGroupBeamLine[]; export type BeamlineGroups = BeamLineGroup[]; +export type EnableShipping = boolean; +export type EnableReprocessing = boolean; /** * Publicly available UI options @@ -40,6 +42,8 @@ export type BeamlineGroups = BeamLineGroup[]; export interface UIOptions { motd?: MessageOfTheDay; beamLineGroups?: BeamlineGroups; + enableShipping?: EnableShipping; + enableReprocessing?: EnableReprocessing; } export interface BeamLineGroup { groupName: GroupName; @@ -58,11 +62,15 @@ export interface BeamLineGroupBeamLine { export abstract class UIOptionsBase extends Entity { motd?: MessageOfTheDay; beamLineGroups?: BeamlineGroups; + enableShipping?: EnableShipping; + enableReprocessing?: EnableReprocessing; } export abstract class UIOptionsSingletonBase extends SingletonEntity { motd?: MessageOfTheDay; beamLineGroups?: BeamlineGroups; + enableShipping?: EnableShipping; + enableReprocessing?: EnableReprocessing; } export abstract class BeamLineGroupBase extends Entity { diff --git a/src/routes/Proposal.tsx b/src/routes/Proposal.tsx index 525605f0c74be224568ef09a77185f6e115b5463..91f5f0ed152751d8b7776d4e186b12ae8cd62cbd 100644 --- a/src/routes/Proposal.tsx +++ b/src/routes/Proposal.tsx @@ -10,7 +10,7 @@ import EventsRoutes from './Events'; import StatsRoutes from './Stats'; import { SessionRoutes, CalendarRoutes } from './Proposals'; import SampleRoutes from './Samples'; -import ProteinRoutes from './Proteins'; +import ProteinRoutes, { ComponentsRoutes } from './Proteins'; import QueueRoutes from './Queue'; const ProposalBreadCrumb: BreadcrumbComponentType<'proposal'> = ({ @@ -29,6 +29,7 @@ const ProposalRoutes = { CalendarRoutes, SampleRoutes, ProteinRoutes, + ComponentsRoutes, ContactRoutes, ShippingRoutes, EventsRoutes, diff --git a/src/routes/Proteins.tsx b/src/routes/Proteins.tsx index d44b66d4fcb96af59df0d0619f9c34f6200acfdf..50d4e9441b7a389f8b5888caa34accfeb5b94f8a 100644 --- a/src/routes/Proteins.tsx +++ b/src/routes/Proteins.tsx @@ -22,4 +22,12 @@ const ProteinRoutes = { ], }; +export const ComponentsRoutes = { + path: 'components', + children: [ + { index: true, element: <ProteinsList />, breadcrumb: 'Components' }, + { path: ':proteinId', element: <ViewProtein />, breadcrumb: 'View' }, + ], +}; + export default ProteinRoutes;