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

fix(manager): edge case when highlighting selected tab #430

Merged
merged 2 commits into from
Aug 28, 2024
Merged
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
108 changes: 47 additions & 61 deletions src/components/DataManagerContent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense, lazy, useEffect, useMemo } from "react";
import { Suspense, lazy, useEffect } from "react";
import { Navigate, Route, Routes } from "react-router-dom";

import { Menu, Skeleton } from "antd";
Expand Down Expand Up @@ -45,65 +45,51 @@ const DataManagerContent = () => {
canViewPermissions,
} = managerPermissions.permissions;

const menuItems = useMemo(
() => [
{
url: "/data/manager/projects",
style: { marginLeft: "4px" },
text: "Projects and Datasets",
disabled: !canManageProjectsDatasets,
},
{ url: "/data/manager/files", text: "Drop Box", disabled: !canViewDropBox },
{
url: "/data/manager/ingestion",
text: "Ingestion",
// TODO: more advanced permissions for this (workflow-level checks)
disabled: !canIngest,
},
{
url: "/data/manager/analysis",
text: "Analysis",
// TODO: more advanced permissions for this (workflow-level checks)
disabled: !canAnalyzeData,
},
{
url: "/data/manager/export",
text: "Export",
// TODO: more advanced permissions for this (workflow-level checks)
disabled: !canExportData,
},
{
url: "/data/manager/runs",
text: "Workflow Runs",
// TODO: check if we have any viewRuns in any grant, not just on RESOURCE_EVERYTHING
disabled: !canViewRuns,
},
{
url: "/data/manager/drs",
text: "DRS Objects",
// TODO: allow always, when we have object-level permissions on the front end for DRS.
disabled: !canQueryData,
},
{
url: "/data/manager/access",
text: "Access Management",
// TODO: check if we have any viewPermissions in any grant, not just on RESOURCE_EVERYTHING
disabled: !canViewPermissions,
},
],
[
canManageProjectsDatasets,
canViewDropBox,
canIngest,
canAnalyzeData,
canExportData,
canViewRuns,
canQueryData,
canViewPermissions,
],
);

const selectedKeys = useMemo(() => matchingMenuKeys(menuItems), [menuItems]);
const menuItems = [
{
url: "/data/manager/projects",
style: { marginLeft: "4px" },
text: "Projects and Datasets",
disabled: !canManageProjectsDatasets,
},
{ url: "/data/manager/files", text: "Drop Box", disabled: !canViewDropBox },
{
url: "/data/manager/ingestion",
text: "Ingestion",
// TODO: more advanced permissions for this (workflow-level checks)
disabled: !canIngest,
},
{
url: "/data/manager/analysis",
text: "Analysis",
// TODO: more advanced permissions for this (workflow-level checks)
disabled: !canAnalyzeData,
},
{
url: "/data/manager/export",
text: "Export",
// TODO: more advanced permissions for this (workflow-level checks)
disabled: !canExportData,
},
{
url: "/data/manager/runs",
text: "Workflow Runs",
// TODO: check if we have any viewRuns in any grant, not just on RESOURCE_EVERYTHING
disabled: !canViewRuns,
},
{
url: "/data/manager/drs",
text: "DRS Objects",
// TODO: allow always, when we have object-level permissions on the front end for DRS.
disabled: !canQueryData,
},
{
url: "/data/manager/access",
text: "Access Management",
// TODO: check if we have any viewPermissions in any grant, not just on RESOURCE_EVERYTHING
disabled: !canViewPermissions,
},
];

return (
<>
Expand All @@ -114,7 +100,7 @@ const DataManagerContent = () => {
<Menu
mode="horizontal"
style={styles.menu}
selectedKeys={selectedKeys}
selectedKeys={matchingMenuKeys(menuItems)}
items={menuItems.map(transformMenuItem)}
/>
}
Expand Down