-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial approach for restricted users permission checks [WD-188…
…36] (#1082) ## Done - Check if user is restricted by using `/1.0/identities/current` endpoint - Wrap `fetchInstances` and `fetchInstance` inside custom hooks to apply entitlement query params if the user is restricted - Setup custom hook for checking instance entitlements - Applied entitlement checks for instance state action buttons on the instance list page.
- Loading branch information
Showing
20 changed files
with
166 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { queryKeys } from "util/queryKeys"; | ||
import { UseQueryResult } from "@tanstack/react-query"; | ||
import { fetchInstance, fetchInstances } from "api/instances"; | ||
import { useAuth } from "./auth"; | ||
import type { LxdInstance } from "types/instance"; | ||
|
||
export const useInstances = ( | ||
project: string, | ||
): UseQueryResult<LxdInstance[]> => { | ||
const { isFineGrained } = useAuth(); | ||
return useQuery({ | ||
queryKey: [queryKeys.instances, project], | ||
queryFn: () => fetchInstances(project, isFineGrained), | ||
enabled: !!project && isFineGrained !== null, | ||
}); | ||
}; | ||
|
||
export const useInstance = ( | ||
name: string, | ||
project: string, | ||
enabled?: boolean, | ||
): UseQueryResult<LxdInstance> => { | ||
const { isFineGrained } = useAuth(); | ||
return useQuery({ | ||
queryKey: [queryKeys.instances, name, project], | ||
queryFn: () => fetchInstance(name, project, isFineGrained), | ||
enabled: enabled && isFineGrained !== null, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.