mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-15 01:16:22 +02:00
https://linear.app/unleash/issue/2-485/bug-pro-access-page-the-tooltip-on-the-roles-is-not-working Fixes an issue where we would not show anything for project role permissions since we're not serving that specific endpoint below Enterprise level. This way we fallback to the access role descriptions, which are also nice and informative:  PR also adds support for SWR options in ConditionalSWR and EnterpriseSWR.
26 lines
785 B
TypeScript
26 lines
785 B
TypeScript
import { formatApiPath } from 'utils/formatPath';
|
|
import handleErrorResponses from '../httpErrorResponseHandler';
|
|
import { IChangeRequest } from 'component/changeRequest/changeRequest.types';
|
|
import { useEnterpriseSWR } from '../useEnterpriseSWR/useEnterpriseSWR';
|
|
|
|
const fetcher = (path: string) => {
|
|
return fetch(path)
|
|
.then(handleErrorResponses('ChangeRequest'))
|
|
.then(res => res.json());
|
|
};
|
|
|
|
export const usePendingChangeRequests = (project: string) => {
|
|
const { data, error, mutate } = useEnterpriseSWR<IChangeRequest[]>(
|
|
[],
|
|
formatApiPath(`api/admin/projects/${project}/change-requests/pending`),
|
|
fetcher
|
|
);
|
|
|
|
return {
|
|
draft: data,
|
|
loading: !error && !data,
|
|
refetch: mutate,
|
|
error,
|
|
};
|
|
};
|