mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: disable delete button tag (#413)
This commit is contained in:
parent
2503a16d53
commit
2990fc180a
@ -41,7 +41,7 @@ export const useStyles = makeStyles(theme => ({
|
||||
margin: 0,
|
||||
},
|
||||
tagContent: {
|
||||
padding: '1.5rem',
|
||||
padding: '1rem',
|
||||
},
|
||||
tagChip: {
|
||||
marginRight: '0.25rem',
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { useState, useContext } from 'react';
|
||||
import { Chip } from '@material-ui/core';
|
||||
import { Add, Label } from '@material-ui/icons';
|
||||
import { useParams } from 'react-router-dom';
|
||||
@ -12,13 +13,13 @@ import { formatAssetPath } from '../../../../../utils/format-path';
|
||||
import useTagTypes from '../../../../../hooks/api/getters/useTagTypes/useTagTypes';
|
||||
import useFeatureApi from '../../../../../hooks/api/actions/useFeatureApi/useFeatureApi';
|
||||
import AddTagDialog from './AddTagDialog/AddTagDialog';
|
||||
import { useState } from 'react';
|
||||
import Dialogue from '../../../../common/Dialogue';
|
||||
import { ITag } from '../../../../../interfaces/tags';
|
||||
import useToast from '../../../../../hooks/useToast';
|
||||
import { UPDATE_FEATURE } from '../../../../AccessProvider/permissions';
|
||||
import { UPDATE_FEATURE, DELETE_TAG } from '../../../../AccessProvider/permissions';
|
||||
import PermissionIconButton from '../../../../common/PermissionIconButton/PermissionIconButton';
|
||||
import ConditionallyRender from '../../../../common/ConditionallyRender';
|
||||
import AccessContext from '../../../../../contexts/AccessContext';
|
||||
|
||||
const FeatureOverviewTags = () => {
|
||||
const [openTagDialog, setOpenTagDialog] = useState(false);
|
||||
@ -33,6 +34,8 @@ const FeatureOverviewTags = () => {
|
||||
const { tagTypes } = useTagTypes();
|
||||
const { deleteTagFromFeature } = useFeatureApi();
|
||||
const { toast, setToastData } = useToast();
|
||||
const { hasAccess } = useContext(AccessContext);
|
||||
const canDeleteTag = hasAccess(DELETE_TAG);
|
||||
|
||||
const handleDelete = async () => {
|
||||
try {
|
||||
@ -102,10 +105,10 @@ const FeatureOverviewTags = () => {
|
||||
data-loading
|
||||
label={t.value}
|
||||
key={`${t.type}:${t.value}`}
|
||||
onDelete={() => {
|
||||
onDelete={canDeleteTag ? () => {
|
||||
setShowDelDialog(true);
|
||||
setSelectedTag({ type: t.type, value: t.value });
|
||||
}}
|
||||
}: undefined}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -117,7 +120,6 @@ const FeatureOverviewTags = () => {
|
||||
Tags
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<AddTagDialog open={openTagDialog} setOpen={setOpenTagDialog} />
|
||||
<PermissionIconButton
|
||||
onClick={() => setOpenTagDialog(true)}
|
||||
|
Loading…
Reference in New Issue
Block a user