mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +02:00
feat: change flag impact metrics url structure (#10624)
This commit is contained in:
parent
29dc6c746d
commit
33d898f684
@ -31,15 +31,21 @@ type ModalState =
|
|||||||
| { type: 'editing'; config: ChartConfig };
|
| { type: 'editing'; config: ChartConfig };
|
||||||
|
|
||||||
export const FeatureImpactMetrics: FC = () => {
|
export const FeatureImpactMetrics: FC = () => {
|
||||||
const feature = useRequiredPathParam('featureId');
|
const featureName = useRequiredPathParam('featureId');
|
||||||
const project = useRequiredPathParam('projectId');
|
const projectId = useRequiredPathParam('projectId');
|
||||||
|
|
||||||
const [modalState, setModalState] = useState<ModalState>({
|
const [modalState, setModalState] = useState<ModalState>({
|
||||||
type: 'closed',
|
type: 'closed',
|
||||||
});
|
});
|
||||||
|
|
||||||
const { createImpactMetric, deleteImpactMetric } = useImpactMetricsApi();
|
const { createImpactMetric, deleteImpactMetric } = useImpactMetricsApi({
|
||||||
const { impactMetrics, refetch } = useFeatureImpactMetrics(feature);
|
projectId,
|
||||||
|
featureName,
|
||||||
|
});
|
||||||
|
const { impactMetrics, refetch } = useFeatureImpactMetrics({
|
||||||
|
projectId,
|
||||||
|
featureName,
|
||||||
|
});
|
||||||
const { setToastApiError } = useToast();
|
const { setToastApiError } = useToast();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -69,7 +75,7 @@ export const FeatureImpactMetrics: FC = () => {
|
|||||||
|
|
||||||
await createImpactMetric({
|
await createImpactMetric({
|
||||||
...data,
|
...data,
|
||||||
feature,
|
feature: featureName,
|
||||||
id: configId,
|
id: configId,
|
||||||
});
|
});
|
||||||
refetch();
|
refetch();
|
||||||
@ -112,7 +118,7 @@ export const FeatureImpactMetrics: FC = () => {
|
|||||||
onEdit={() => handleEditChart(config)}
|
onEdit={() => handleEditChart(config)}
|
||||||
onDelete={() => handleDeleteChart(config.id)}
|
onDelete={() => handleDeleteChart(config.id)}
|
||||||
permission={UPDATE_FEATURE}
|
permission={UPDATE_FEATURE}
|
||||||
projectId={project}
|
projectId={projectId}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
w: 6,
|
w: 6,
|
||||||
@ -121,7 +127,7 @@ export const FeatureImpactMetrics: FC = () => {
|
|||||||
y: Math.floor(index / 2) * 2,
|
y: Math.floor(index / 2) * 2,
|
||||||
static: true,
|
static: true,
|
||||||
})),
|
})),
|
||||||
[impactMetrics.configs, project],
|
[impactMetrics.configs, projectId],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -137,7 +143,7 @@ export const FeatureImpactMetrics: FC = () => {
|
|||||||
onClick={handleAddChart}
|
onClick={handleAddChart}
|
||||||
disabled={metadataLoading || !!metadataError}
|
disabled={metadataLoading || !!metadataError}
|
||||||
permission={UPDATE_FEATURE}
|
permission={UPDATE_FEATURE}
|
||||||
projectId={project}
|
projectId={projectId}
|
||||||
>
|
>
|
||||||
Add Chart
|
Add Chart
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
|
@ -2,14 +2,17 @@ import { useCallback } from 'react';
|
|||||||
import useAPI from '../useApi/useApi.js';
|
import useAPI from '../useApi/useApi.js';
|
||||||
import type { CreateImpactMetricsConfigSchema } from 'openapi';
|
import type { CreateImpactMetricsConfigSchema } from 'openapi';
|
||||||
|
|
||||||
export const useImpactMetricsApi = () => {
|
export const useImpactMetricsApi = ({
|
||||||
|
projectId,
|
||||||
|
featureName,
|
||||||
|
}: { projectId: string; featureName: string }) => {
|
||||||
const { makeRequest, createRequest, errors, loading } = useAPI({
|
const { makeRequest, createRequest, errors, loading } = useAPI({
|
||||||
propagateErrors: true,
|
propagateErrors: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const createImpactMetric = useCallback(
|
const createImpactMetric = useCallback(
|
||||||
async (config: CreateImpactMetricsConfigSchema) => {
|
async (config: CreateImpactMetricsConfigSchema) => {
|
||||||
const path = `api/admin/impact-metrics/config`;
|
const path = `api/admin/projects/${projectId}/features/${featureName}/impact-metrics/config`;
|
||||||
const req = createRequest(
|
const req = createRequest(
|
||||||
path,
|
path,
|
||||||
{
|
{
|
||||||
@ -26,7 +29,7 @@ export const useImpactMetricsApi = () => {
|
|||||||
|
|
||||||
const deleteImpactMetric = useCallback(
|
const deleteImpactMetric = useCallback(
|
||||||
async (metricId: string) => {
|
async (metricId: string) => {
|
||||||
const path = `api/admin/impact-metrics/config/${metricId}`;
|
const path = `api/admin/projects/${projectId}/features/${featureName}/impact-metrics/config/${metricId}`;
|
||||||
const req = createRequest(
|
const req = createRequest(
|
||||||
path,
|
path,
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,11 @@ import { fetcher, useApiGetter } from '../useApiGetter/useApiGetter.js';
|
|||||||
import { formatApiPath } from 'utils/formatPath';
|
import { formatApiPath } from 'utils/formatPath';
|
||||||
import type { ImpactMetricsConfigListSchema } from 'openapi';
|
import type { ImpactMetricsConfigListSchema } from 'openapi';
|
||||||
|
|
||||||
export const useFeatureImpactMetrics = (feature: string) => {
|
export const useFeatureImpactMetrics = ({
|
||||||
const PATH = `api/admin/impact-metrics/config/${feature}`;
|
projectId,
|
||||||
|
featureName,
|
||||||
|
}: { projectId: string; featureName: string }) => {
|
||||||
|
const PATH = `api/admin/projects/${projectId}/features/${featureName}/impact-metrics/config`;
|
||||||
const { data, refetch, loading, error } =
|
const { data, refetch, loading, error } =
|
||||||
useApiGetter<ImpactMetricsConfigListSchema>(formatApiPath(PATH), () =>
|
useApiGetter<ImpactMetricsConfigListSchema>(formatApiPath(PATH), () =>
|
||||||
fetcher(formatApiPath(PATH), 'Feature Impact Metrics'),
|
fetcher(formatApiPath(PATH), 'Feature Impact Metrics'),
|
||||||
|
Loading…
Reference in New Issue
Block a user