Skip to content

Commit

Permalink
Merge pull request #408 from akaene/feature/new-way-for-global-system…
Browse files Browse the repository at this point in the history
…-disable

Global select disabled
  • Loading branch information
blcham authored Jun 12, 2024
2 parents c65882a + fce5ff4 commit 3ef02ee
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/appBar/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@ interface Props {
showBackButton?: boolean;
}

const shouldDropdownBeDisabled = (url: string) => {
const pathParts = url.split("/");
const routes = [ROUTES.FTA.substring(1), ROUTES.SYSTEMS.substring(1)];

return routes.some((route) => {
const index = pathParts.indexOf(route);
return index !== -1 && pathParts[index + 1] !== undefined;
});
};

const AppBar = ({ title, showBackButton = false, topPanelHeight }: Props) => {
const [loggedUser] = useLoggedUser();
const { classes } = useStyles();
const history = useNavigate();
const { i18n, t } = useTranslation();
const { appBarTitle, systemsList } = useAppBar();
const location = useLocation();
const path = location.pathname;
const dropdownDisabled = shouldDropdownBeDisabled(location.pathname);

const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const [selectedSystem, setSelectedSystem] = useSelectedSystem();
Expand Down Expand Up @@ -144,7 +154,7 @@ const AppBar = ({ title, showBackButton = false, topPanelHeight }: Props) => {
className={classes.textfieldSelect}
value={selectedSystem ? selectedSystem.iri : ""}
onChange={handleSystemChange}
disabled={path.includes("instance")}
disabled={dropdownDisabled}
>
{systemsList.map((s, i) => {
return (
Expand Down

0 comments on commit 3ef02ee

Please sign in to comment.