forked from github-starred/komodo
only show things relevant to user in sidebar
This commit is contained in:
@@ -15,8 +15,15 @@ import { useTheme } from "../../state/ThemeProvider";
|
||||
const Sidebar: Component<{}> = () => {
|
||||
const { sidebar, servers } = useAppState();
|
||||
const { height } = useAppDimensions();
|
||||
const { permissions } = useUser();
|
||||
const { permissions, username } = useUser();
|
||||
const { themeClass } = useTheme();
|
||||
const filteredServerIds = () =>
|
||||
servers
|
||||
.ids()
|
||||
?.filter(
|
||||
(id) =>
|
||||
permissions() > 1 || servers.get(id)!.owners.includes(username()!)
|
||||
);
|
||||
return (
|
||||
<Show when={servers.loaded() && sidebar.open()}>
|
||||
<Tabs
|
||||
@@ -33,7 +40,7 @@ const Sidebar: Component<{}> = () => {
|
||||
"max-height": inPx(height() - TOPBAR_HEIGHT - 80),
|
||||
}}
|
||||
>
|
||||
<For each={servers.ids()}>{(id) => <Server id={id} />}</For>
|
||||
<For each={filteredServerIds()}>{(id) => <Server id={id} />}</For>
|
||||
<Show when={permissions() > 1}>
|
||||
<AddServer />
|
||||
</Show>
|
||||
|
||||
@@ -11,16 +11,23 @@ import NewBuild from "./NewBuild";
|
||||
|
||||
const Builds: Component<{}> = (p) => {
|
||||
const { builds } = useAppState();
|
||||
const { permissions } = useUser();
|
||||
const { permissions, username } = useUser();
|
||||
const { themeClass } = useTheme();
|
||||
const filteredBuildIds = () =>
|
||||
builds
|
||||
.ids()
|
||||
?.filter(
|
||||
(id) =>
|
||||
permissions() > 1 || builds.get(id)!.owners.includes(username()!)
|
||||
);
|
||||
return (
|
||||
<Grid gap=".5rem" class={combineClasses(s.Deployments, "shadow", themeClass())}>
|
||||
<Show
|
||||
when={builds.ids() && (builds.ids() as string[]).length === 0}
|
||||
when={filteredBuildIds() && (filteredBuildIds() as string[]).length === 0}
|
||||
>
|
||||
<Flex justifyContent="center">no builds</Flex>
|
||||
</Show>
|
||||
<For each={builds.ids()}>{(id) => <Build id={id} />}</For>
|
||||
<For each={filteredBuildIds()}>{(id) => <Build id={id} />}</For>
|
||||
<Show when={permissions() >= 1}>
|
||||
<NewBuild />
|
||||
</Show>
|
||||
|
||||
Reference in New Issue
Block a user