mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +02:00
feat: flag impact metrics use update feature permission (#10615)
This commit is contained in:
parent
2fd40e7372
commit
3b1592b329
@ -10,7 +10,7 @@ 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';
|
||||||
import PermissionButton from 'component/common/PermissionButton/PermissionButton.tsx';
|
import PermissionButton from 'component/common/PermissionButton/PermissionButton.tsx';
|
||||||
import { ADMIN } from 'component/providers/AccessProvider/permissions.ts';
|
import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions.ts';
|
||||||
import useToast from 'hooks/useToast.tsx';
|
import useToast from 'hooks/useToast.tsx';
|
||||||
import { formatUnknownError } from 'utils/formatUnknownError.ts';
|
import { formatUnknownError } from 'utils/formatUnknownError.ts';
|
||||||
import type { ChartConfig } from '../../../impact-metrics/types.ts';
|
import type { ChartConfig } from '../../../impact-metrics/types.ts';
|
||||||
@ -28,6 +28,7 @@ type ModalState =
|
|||||||
|
|
||||||
export const FeatureImpactMetrics: FC = () => {
|
export const FeatureImpactMetrics: FC = () => {
|
||||||
const feature = useRequiredPathParam('featureId');
|
const feature = useRequiredPathParam('featureId');
|
||||||
|
const project = useRequiredPathParam('projectId');
|
||||||
|
|
||||||
const [modalState, setModalState] = useState<ModalState>({
|
const [modalState, setModalState] = useState<ModalState>({
|
||||||
type: 'closed',
|
type: 'closed',
|
||||||
@ -109,7 +110,8 @@ export const FeatureImpactMetrics: FC = () => {
|
|||||||
startIcon={<Add />}
|
startIcon={<Add />}
|
||||||
onClick={handleAddChart}
|
onClick={handleAddChart}
|
||||||
disabled={metadataLoading || !!metadataError}
|
disabled={metadataLoading || !!metadataError}
|
||||||
permission={ADMIN}
|
permission={UPDATE_FEATURE}
|
||||||
|
projectId={project}
|
||||||
>
|
>
|
||||||
Add Chart
|
Add Chart
|
||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
@ -123,6 +125,8 @@ export const FeatureImpactMetrics: FC = () => {
|
|||||||
config={config}
|
config={config}
|
||||||
onEdit={() => handleEditChart(config)}
|
onEdit={() => handleEditChart(config)}
|
||||||
onDelete={() => handleDeleteChart(config.id)}
|
onDelete={() => handleDeleteChart(config.id)}
|
||||||
|
permission={UPDATE_FEATURE}
|
||||||
|
projectId={project}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
|
@ -12,6 +12,8 @@ export interface ChartItemProps {
|
|||||||
config: DisplayChartConfig;
|
config: DisplayChartConfig;
|
||||||
onEdit: (config: ChartConfig) => void;
|
onEdit: (config: ChartConfig) => void;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
|
permission?: string;
|
||||||
|
projectId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getConfigDescription = (config: DisplayChartConfig): string => {
|
const getConfigDescription = (config: DisplayChartConfig): string => {
|
||||||
@ -104,7 +106,13 @@ const StyledChartActions = styled(Box)(({ theme }) => ({
|
|||||||
gap: theme.spacing(0.5),
|
gap: theme.spacing(0.5),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const ChartItem: FC<ChartItemProps> = ({ config, onEdit, onDelete }) => (
|
export const ChartItem: FC<ChartItemProps> = ({
|
||||||
|
config,
|
||||||
|
onEdit,
|
||||||
|
onDelete,
|
||||||
|
permission = ADMIN,
|
||||||
|
projectId,
|
||||||
|
}) => (
|
||||||
<StyledWidget>
|
<StyledWidget>
|
||||||
<StyledHeader>
|
<StyledHeader>
|
||||||
<StyledDragHandle className='grid-item-drag-handle'>
|
<StyledDragHandle className='grid-item-drag-handle'>
|
||||||
@ -121,13 +129,15 @@ export const ChartItem: FC<ChartItemProps> = ({ config, onEdit, onDelete }) => (
|
|||||||
<StyledChartActions>
|
<StyledChartActions>
|
||||||
<PermissionIconButton
|
<PermissionIconButton
|
||||||
onClick={() => onEdit(config)}
|
onClick={() => onEdit(config)}
|
||||||
permission={ADMIN}
|
permission={permission}
|
||||||
|
projectId={projectId}
|
||||||
>
|
>
|
||||||
<Edit />
|
<Edit />
|
||||||
</PermissionIconButton>
|
</PermissionIconButton>
|
||||||
<PermissionIconButton
|
<PermissionIconButton
|
||||||
onClick={() => onDelete(config.id)}
|
onClick={() => onDelete(config.id)}
|
||||||
permission={ADMIN}
|
permission={permission}
|
||||||
|
projectId={projectId}
|
||||||
>
|
>
|
||||||
<Delete />
|
<Delete />
|
||||||
</PermissionIconButton>
|
</PermissionIconButton>
|
||||||
|
Loading…
Reference in New Issue
Block a user