mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
update impact metrics layout
This commit is contained in:
parent
e5c24117f0
commit
dcb649436d
@ -5,7 +5,7 @@ import Add from '@mui/icons-material/Add';
|
|||||||
import { useImpactMetricsMetadata } from 'hooks/api/getters/useImpactMetricsMetadata/useImpactMetricsMetadata.ts';
|
import { useImpactMetricsMetadata } from 'hooks/api/getters/useImpactMetricsMetadata/useImpactMetricsMetadata.ts';
|
||||||
import { type FC, useMemo, useState } from 'react';
|
import { type FC, useMemo, useState } from 'react';
|
||||||
import { ChartConfigModal } from '../../../impact-metrics/ChartConfigModal/ChartConfigModal.tsx';
|
import { ChartConfigModal } from '../../../impact-metrics/ChartConfigModal/ChartConfigModal.tsx';
|
||||||
import { useImpactMetricsApi } from 'hooks/api/actions/useImpactMetricsSettingsApi/useImpactMetricsApi.ts';
|
import { useImpactMetricsApi } from 'hooks/api/actions/useImpactMetricsApi/useImpactMetricsApi.ts';
|
||||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam.ts';
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam.ts';
|
||||||
import { useFeatureImpactMetrics } from 'hooks/api/getters/useFeatureImpactMetrics/useFeatureImpactMetrics.ts';
|
import { useFeatureImpactMetrics } from 'hooks/api/getters/useFeatureImpactMetrics/useFeatureImpactMetrics.ts';
|
||||||
import { ChartItem } from '../../../impact-metrics/ChartItem.tsx';
|
import { ChartItem } from '../../../impact-metrics/ChartItem.tsx';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import type { ChartConfig } from '../types.ts';
|
import type { ChartConfig } from '../types.ts';
|
||||||
import { useImpactMetricsConfig } from 'hooks/api/getters/useImpactMetricsConfig/useImpactMetricsConfig.ts';
|
import { useImpactMetricsConfig } from 'hooks/api/getters/useImpactMetricsConfig/useImpactMetricsConfig.ts';
|
||||||
import { useImpactMetricsApi } from 'hooks/api/actions/useImpactMetricsSettingsApi/useImpactMetricsApi.ts';
|
import { useImpactMetricsApi } from 'hooks/api/actions/useImpactMetricsApi/useImpactMetricsApi.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Select all" represents all current and future labels.
|
* "Select all" represents all current and future labels.
|
||||||
@ -19,17 +19,22 @@ export const useImpactMetricsState = () => {
|
|||||||
|
|
||||||
const { layout, charts } = useMemo(
|
const { layout, charts } = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
layout: configs.map((config, index) => ({
|
layout: configs.map((config, index) => {
|
||||||
i: config.id,
|
const column = index % 2;
|
||||||
x: 0,
|
const row = Math.floor(index / 2);
|
||||||
y: index * 4,
|
|
||||||
w: 6,
|
return {
|
||||||
h: 4,
|
i: config.id,
|
||||||
minW: 4,
|
x: column * 6,
|
||||||
minH: 2,
|
y: row * 2,
|
||||||
maxW: 12,
|
w: 6,
|
||||||
maxH: 8,
|
h: 2,
|
||||||
})),
|
minW: 4,
|
||||||
|
minH: 2,
|
||||||
|
maxW: 12,
|
||||||
|
maxH: 8,
|
||||||
|
};
|
||||||
|
}),
|
||||||
charts: configs,
|
charts: configs,
|
||||||
}),
|
}),
|
||||||
[configs],
|
[configs],
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
import { useCallback } from 'react';
|
|
||||||
import useAPI from '../useApi/useApi.js';
|
|
||||||
import type { ImpactMetricsState } from 'component/impact-metrics/types.ts';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use `useImpactMetricsApi()` instead
|
|
||||||
*/
|
|
||||||
export const useImpactMetricsSettingsApi = () => {
|
|
||||||
const { makeRequest, createRequest, errors, loading } = useAPI({
|
|
||||||
propagateErrors: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateSettings = useCallback(
|
|
||||||
async (settings: ImpactMetricsState) => {
|
|
||||||
const path = `api/admin/impact-metrics/settings`;
|
|
||||||
const req = createRequest(
|
|
||||||
path,
|
|
||||||
{
|
|
||||||
method: 'PUT',
|
|
||||||
body: JSON.stringify(settings),
|
|
||||||
},
|
|
||||||
'updateImpactMetricsSettings',
|
|
||||||
);
|
|
||||||
|
|
||||||
return makeRequest(req.caller, req.id);
|
|
||||||
},
|
|
||||||
[makeRequest, createRequest],
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
updateSettings,
|
|
||||||
errors,
|
|
||||||
loading,
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,21 +0,0 @@
|
|||||||
import { fetcher, useApiGetter } from '../useApiGetter/useApiGetter.js';
|
|
||||||
import { formatApiPath } from 'utils/formatPath';
|
|
||||||
import type { DisplayImpactMetricsState } from 'component/impact-metrics/types.ts';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated use `useImpactMetricsConfig()` instead
|
|
||||||
*/
|
|
||||||
export const useImpactMetricsSettings = () => {
|
|
||||||
const PATH = `api/admin/impact-metrics/settings`;
|
|
||||||
const { data, refetch, loading, error } =
|
|
||||||
useApiGetter<DisplayImpactMetricsState>(formatApiPath(PATH), () =>
|
|
||||||
fetcher(formatApiPath(PATH), 'Impact metrics settings'),
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
settings: data || { charts: [], layout: [] },
|
|
||||||
refetch,
|
|
||||||
loading,
|
|
||||||
error,
|
|
||||||
};
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user