Skip to content

Commit

Permalink
Global select disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasmadei committed Jun 12, 2024
1 parent c65882a commit fce5ff4
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 fce5ff4

Please sign in to comment.