mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
TODO: add constraint ids for default strategy
which is in the project overview.
This commit is contained in:
parent
6ee18b0fe0
commit
c9efa26365
@ -1,5 +1,5 @@
|
|||||||
import useSWR, { type SWRConfiguration } from 'swr';
|
import useSWR, { type SWRConfiguration } from 'swr';
|
||||||
import { useCallback } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import { getProjectOverviewFetcher } from './getProjectOverviewFetcher.js';
|
import { getProjectOverviewFetcher } from './getProjectOverviewFetcher.js';
|
||||||
import type { ProjectOverviewSchema } from 'openapi';
|
import type { ProjectOverviewSchema } from 'openapi';
|
||||||
|
|
||||||
@ -41,8 +41,26 @@ const useProjectOverview = (id: string, options: SWRConfiguration = {}) => {
|
|||||||
mutate();
|
mutate();
|
||||||
}, [mutate]);
|
}, [mutate]);
|
||||||
|
|
||||||
|
const overriddenData = useMemo(() => {
|
||||||
|
if (!data) return undefined;
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
environments: data.environments?.map((env) => {
|
||||||
|
return env.defaultStrategy
|
||||||
|
? {
|
||||||
|
...env,
|
||||||
|
defaultStrategy: {
|
||||||
|
...env.defaultStrategy,
|
||||||
|
title: 'custom title override',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: env;
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
project: data || fallbackProject,
|
project: overriddenData || fallbackProject,
|
||||||
loading: !error && !data,
|
loading: !error && !data,
|
||||||
error,
|
error,
|
||||||
refetch,
|
refetch,
|
||||||
|
Loading…
Reference in New Issue
Block a user