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 { ChartItem } from '../../../impact-metrics/ChartItem.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 { formatUnknownError } from 'utils/formatUnknownError.ts';
|
||||
import type { ChartConfig } from '../../../impact-metrics/types.ts';
|
||||
@ -28,6 +28,7 @@ type ModalState =
|
||||
|
||||
export const FeatureImpactMetrics: FC = () => {
|
||||
const feature = useRequiredPathParam('featureId');
|
||||
const project = useRequiredPathParam('projectId');
|
||||
|
||||
const [modalState, setModalState] = useState<ModalState>({
|
||||
type: 'closed',
|
||||
@ -109,7 +110,8 @@ export const FeatureImpactMetrics: FC = () => {
|
||||
startIcon={<Add />}
|
||||
onClick={handleAddChart}
|
||||
disabled={metadataLoading || !!metadataError}
|
||||
permission={ADMIN}
|
||||
permission={UPDATE_FEATURE}
|
||||
projectId={project}
|
||||
>
|
||||
Add Chart
|
||||
</PermissionButton>
|
||||
@ -123,6 +125,8 @@ export const FeatureImpactMetrics: FC = () => {
|
||||
config={config}
|
||||
onEdit={() => handleEditChart(config)}
|
||||
onDelete={() => handleDeleteChart(config.id)}
|
||||
permission={UPDATE_FEATURE}
|
||||
projectId={project}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
|
@ -12,6 +12,8 @@ export interface ChartItemProps {
|
||||
config: DisplayChartConfig;
|
||||
onEdit: (config: ChartConfig) => void;
|
||||
onDelete: (id: string) => void;
|
||||
permission?: string;
|
||||
projectId?: string;
|
||||
}
|
||||
|
||||
const getConfigDescription = (config: DisplayChartConfig): string => {
|
||||
@ -104,7 +106,13 @@ const StyledChartActions = styled(Box)(({ theme }) => ({
|
||||
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>
|
||||
<StyledHeader>
|
||||
<StyledDragHandle className='grid-item-drag-handle'>
|
||||
@ -121,13 +129,15 @@ export const ChartItem: FC<ChartItemProps> = ({ config, onEdit, onDelete }) => (
|
||||
<StyledChartActions>
|
||||
<PermissionIconButton
|
||||
onClick={() => onEdit(config)}
|
||||
permission={ADMIN}
|
||||
permission={permission}
|
||||
projectId={projectId}
|
||||
>
|
||||
<Edit />
|
||||
</PermissionIconButton>
|
||||
<PermissionIconButton
|
||||
onClick={() => onDelete(config.id)}
|
||||
permission={ADMIN}
|
||||
permission={permission}
|
||||
projectId={projectId}
|
||||
>
|
||||
<Delete />
|
||||
</PermissionIconButton>
|
||||
|
Loading…
Reference in New Issue
Block a user