Skip to content

Commit

Permalink
Hide user settings, add and import for anonymous user
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt committed Sep 2, 2024
1 parent 2ec5584 commit 1eea5dd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
44 changes: 25 additions & 19 deletions src/client/src/pages/overview/layout/mainSideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { FilterContext } from "../sidePanelContent/filter/filterContext.tsx";
import { useTranslation } from "react-i18next";
import { NavButton } from "../../../components/buttons/navButton.tsx";
import { ErrorResponse } from "../sidePanelContent/commons/actionsInterfaces.ts";
import { useAuth } from "../../../auth/useBdmsAuth.tsx";

export interface MainSideNavProps {
toggleDrawer: (open: boolean) => void;
Expand All @@ -42,6 +43,7 @@ const MainSideNav = ({
const history = useHistory();
const menuRef = useRef(null);
const { t } = useTranslation();
const auth = useAuth();
const [creating, setCreating] = useState<boolean>(false);
const [modal, setModal] = useState<boolean>(false);
const [upload, setUpload] = useState<boolean>(false);
Expand Down Expand Up @@ -118,25 +120,29 @@ const MainSideNav = ({
selected={isFilterPanelVisible}
onClick={handleToggleFilter}
/>
<NavButton
data-cy="new-borehole-button"
icon={<AddIcon />}
label={t("add")}
selected={isAddPanelVisible}
disabled={user.data.roles.indexOf("EDIT") === -1}
onClick={handleToggleAdd}
/>
<NavButton
data-cy="import-borehole-button"
icon={<UploadIcon />}
label={t("upload")}
disabled={user.data.roles.indexOf("EDIT") === -1}
onClick={() => {
toggleDrawer(false);
setModal(true);
setUpload(true);
}}
/>
{!auth.anonymousModeEnabled && (
<>
<NavButton
data-cy="new-borehole-button"
icon={<AddIcon />}
label={t("add")}
selected={isAddPanelVisible}
disabled={user.data.roles.indexOf("EDIT") === -1}
onClick={handleToggleAdd}
/>
<NavButton
data-cy="import-borehole-button"
icon={<UploadIcon />}
label={t("upload")}
disabled={user.data.roles.indexOf("EDIT") === -1}
onClick={() => {
toggleDrawer(false);
setModal(true);
setUpload(true);
}}
/>
</>
)}
<NavButton
data-cy="layers-button"
icon={<LayersIcon />}
Expand Down
7 changes: 5 additions & 2 deletions src/client/src/pages/settings/menuSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ import PropTypes from "prop-types";
import { withTranslation } from "react-i18next";
import { withRouter } from "react-router-dom";
import ListItem from "../../components/legacyComponents/listItem";
import { useAuth } from "../../auth/useBdmsAuth";

const MenuSettings = props => {
const { history, t, location } = props;
const auth = useAuth();

return (
<div>
<ListItem path="/" name="done" location={location} history={history} icon="arrow left" t={t} hasTranslation />
<ListItem path="/setting" name={t("header_settings")} location={location} history={history} icon="cog" />

{!auth.anonymousModeEnabled && (
<ListItem path="/setting" name={t("header_settings")} location={location} history={history} icon="cog" />
)}
{props.user.data.admin === true && (
<>
<ListItem path="/setting/admin" name="Admin" location={location} history={history} icon="user outline" />
Expand Down
4 changes: 3 additions & 1 deletion src/client/src/pages/settings/settingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import AdminSettings from "./admin/adminSettings";
import AboutSettings from "./aboutSettings";
import TermSettings from "./termSettings";
import { theme } from "../../AppTheme";
import { useAuth } from "../../auth/useBdmsAuth";

const SettingsPage = () => {
const auth = useAuth();
return (
<div
style={{
Expand Down Expand Up @@ -40,7 +42,7 @@ const SettingsPage = () => {
<Route component={AdminSettings} path={"/setting/admin"} />
<Route component={TermSettings} path={"/setting/term"} />
<Route component={AboutSettings} path={"/setting/about"} />
<Route component={EditorSettings} path={"/setting"} />
<Route component={auth.anonymousModeEnabled ? AboutSettings : EditorSettings} path={"/setting"} />
</Switch>
</div>
</div>
Expand Down

0 comments on commit 1eea5dd

Please sign in to comment.