Skip to content

Commit

Permalink
Merge pull request #13 from cnpem/env-menu-close
Browse files Browse the repository at this point in the history
apps/spu-ui: add close option to env-menu
  • Loading branch information
matyson authored Nov 18, 2024
2 parents cca825b + cc8699c commit cf29fa9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 11 additions & 2 deletions apps/spu-ui/src/app/_components/env-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { useStatus } from "../_hooks/use-status";

export function EnvMenu() {
const { status, envUpdate, envOpen } = useStatus();
const { status, envUpdate, envOpen, envClose } = useStatus();

const statusMessage = () => {
if (status.isLoading) {
Expand All @@ -35,20 +35,29 @@ export function EnvMenu() {
<DropdownMenuContent>
<DropdownMenuLabel>Env controls</DropdownMenuLabel>
<DropdownMenuItem
className="cursor-pointer"
onClick={() => {
envUpdate.mutate();
}}
>
Update
</DropdownMenuItem>

<DropdownMenuItem
className="cursor-pointer"
onClick={() => {
envOpen.mutate();
}}
>
Open
</DropdownMenuItem>
<DropdownMenuItem
className="cursor-pointer text-muted-foreground hover:font-semibold hover:!text-red-500"
onClick={() => {
envClose.mutate();
}}
>
Close
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuLabel>Full status</DropdownMenuLabel>
<div className="mb-2 p-2">
Expand Down
8 changes: 7 additions & 1 deletion apps/spu-ui/src/app/_hooks/use-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ export const useStatus = () => {
},
});

return { status, envUpdate, envOpen };
const envClose = api.environment.close.useMutation({
onSuccess: async () => {
await utils.status.get.invalidate();
},
});

return { status, envUpdate, envOpen, envClose };
};

0 comments on commit cf29fa9

Please sign in to comment.