mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +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, |         margin: 0, | ||||||
|     }, |     }, | ||||||
|     tagContent: { |     tagContent: { | ||||||
|         padding: '1.5rem', |         padding: '1rem', | ||||||
|     }, |     }, | ||||||
|     tagChip: { |     tagChip: { | ||||||
|         marginRight: '0.25rem', |         marginRight: '0.25rem', | ||||||
|  | |||||||
| @ -1,3 +1,4 @@ | |||||||
|  | import { useState, useContext } from 'react';  | ||||||
| import { Chip } from '@material-ui/core'; | import { Chip } from '@material-ui/core'; | ||||||
| import { Add, Label } from '@material-ui/icons'; | import { Add, Label } from '@material-ui/icons'; | ||||||
| import { useParams } from 'react-router-dom'; | 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 useTagTypes from '../../../../../hooks/api/getters/useTagTypes/useTagTypes'; | ||||||
| import useFeatureApi from '../../../../../hooks/api/actions/useFeatureApi/useFeatureApi'; | import useFeatureApi from '../../../../../hooks/api/actions/useFeatureApi/useFeatureApi'; | ||||||
| import AddTagDialog from './AddTagDialog/AddTagDialog'; | import AddTagDialog from './AddTagDialog/AddTagDialog'; | ||||||
| import { useState } from 'react'; |  | ||||||
| import Dialogue from '../../../../common/Dialogue'; | import Dialogue from '../../../../common/Dialogue'; | ||||||
| import { ITag } from '../../../../../interfaces/tags'; | import { ITag } from '../../../../../interfaces/tags'; | ||||||
| import useToast from '../../../../../hooks/useToast'; | 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 PermissionIconButton from '../../../../common/PermissionIconButton/PermissionIconButton'; | ||||||
| import ConditionallyRender from '../../../../common/ConditionallyRender'; | import ConditionallyRender from '../../../../common/ConditionallyRender'; | ||||||
|  | import AccessContext from '../../../../../contexts/AccessContext'; | ||||||
| 
 | 
 | ||||||
| const FeatureOverviewTags = () => { | const FeatureOverviewTags = () => { | ||||||
|     const [openTagDialog, setOpenTagDialog] = useState(false); |     const [openTagDialog, setOpenTagDialog] = useState(false); | ||||||
| @ -33,6 +34,8 @@ const FeatureOverviewTags = () => { | |||||||
|     const { tagTypes } = useTagTypes(); |     const { tagTypes } = useTagTypes(); | ||||||
|     const { deleteTagFromFeature } = useFeatureApi(); |     const { deleteTagFromFeature } = useFeatureApi(); | ||||||
|     const { toast, setToastData } = useToast(); |     const { toast, setToastData } = useToast(); | ||||||
|  |     const { hasAccess } = useContext(AccessContext); | ||||||
|  |     const canDeleteTag = hasAccess(DELETE_TAG); | ||||||
| 
 | 
 | ||||||
|     const handleDelete = async () => { |     const handleDelete = async () => { | ||||||
|         try { |         try { | ||||||
| @ -102,10 +105,10 @@ const FeatureOverviewTags = () => { | |||||||
|             data-loading |             data-loading | ||||||
|             label={t.value} |             label={t.value} | ||||||
|             key={`${t.type}:${t.value}`} |             key={`${t.type}:${t.value}`} | ||||||
|             onDelete={() => { |             onDelete={canDeleteTag ? () => { | ||||||
|                 setShowDelDialog(true); |                 setShowDelDialog(true); | ||||||
|                 setSelectedTag({ type: t.type, value: t.value }); |                 setSelectedTag({ type: t.type, value: t.value }); | ||||||
|             }} |             }: undefined} | ||||||
|         /> |         /> | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| @ -117,7 +120,6 @@ const FeatureOverviewTags = () => { | |||||||
|                         Tags |                         Tags | ||||||
|                     </h4> |                     </h4> | ||||||
|                 </div> |                 </div> | ||||||
| 
 |  | ||||||
|                 <AddTagDialog open={openTagDialog} setOpen={setOpenTagDialog} /> |                 <AddTagDialog open={openTagDialog} setOpen={setOpenTagDialog} /> | ||||||
|                 <PermissionIconButton |                 <PermissionIconButton | ||||||
|                     onClick={() => setOpenTagDialog(true)} |                     onClick={() => setOpenTagDialog(true)} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user