Skip to content

Commit c4228a7

Browse files
Improve "superusers only" option presentation
1 parent 54c9c8f commit c4228a7

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

packages/client/src/admin/sketchClasses/SketchClassAdmin.tsx

+28-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useTemplateSketchClassesQuery,
77
} from "../../generated/graphql";
88
import TemplateChooser from "./TemplateChooser";
9-
import { useCallback, useMemo } from "react";
9+
import { useCallback, useMemo, useState } from "react";
1010
import NavSidebar, { NavSidebarItem } from "../../components/NavSidebar";
1111
import Button from "../../components/Button";
1212
import { useHistory, useRouteMatch, Switch, Route } from "react-router-dom";
@@ -49,6 +49,8 @@ export default function SketchClassAdmin() {
4949
];
5050
}, [sketchClasses, slug]);
5151

52+
const [showSuperuserOptions, setShowSuperuserOptions] = useState(false);
53+
5254
const onCreate = useCallback(
5355
(sc: SketchingDetailsFragment) => {
5456
// eslint-disable-next-line i18next/no-literal-string
@@ -66,12 +68,32 @@ export default function SketchClassAdmin() {
6668
<h2 className="text-lg font-semibold mb-2">
6769
{t("Create a new Sketch Class")}
6870
</h2>
69-
<TemplateChooser onCreate={onCreate} />
70-
<Button
71-
label={t("Cancel")}
72-
className="mt-4"
73-
href={`/${getSlug()}/admin/sketching/`}
71+
<TemplateChooser
72+
showSuperuserOptions={showSuperuserOptions}
73+
onCreate={onCreate}
7474
/>
75+
<div className="flex items-center mt-4">
76+
<Button
77+
label={t("Cancel")}
78+
className=""
79+
href={`/${getSlug()}/admin/sketching/`}
80+
/>
81+
<div className="flex-1 text-right absolute right-5 top-2">
82+
<div className="opacity-10 hover:opacity-100">
83+
<input
84+
type="checkbox"
85+
className="ml-4 rounded"
86+
checked={showSuperuserOptions}
87+
onChange={(e) => {
88+
setShowSuperuserOptions(e.target.checked);
89+
}}
90+
/>
91+
<label className="ml-2 text-xs">
92+
{t("Show superuser options")}
93+
</label>
94+
</div>
95+
</div>
96+
</div>
7597
</div>
7698
</div>
7799
</Route>

packages/client/src/admin/sketchClasses/TemplateChooser.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import useIsSuperuser from "../../useIsSuperuser";
2323

2424
export default function TemplateChooser({
2525
onCreate,
26+
showSuperuserOptions,
2627
}: {
2728
onCreate?: (sketchClass: SketchingDetailsFragment) => void;
29+
showSuperuserOptions?: boolean;
2830
}) {
2931
const { t } = useTranslation("admin:sketching");
3032
const onError = useGlobalErrorHandler();
@@ -92,7 +94,7 @@ export default function TemplateChooser({
9294
.filter((sk) => {
9395
return (
9496
sk.geometryType !== SketchGeometryType.FilteredPlanningUnits ||
95-
isSuperuser
97+
(showSuperuserOptions && isSuperuser)
9698
);
9799
})
98100
.map((template, actionIdx) => (

0 commit comments

Comments
 (0)