diff --git a/src/components/Table/ComplexTagTable.tsx b/src/components/Table/ComplexTagTable.tsx index 1a2281ec..4c53eefb 100644 --- a/src/components/Table/ComplexTagTable.tsx +++ b/src/components/Table/ComplexTagTable.tsx @@ -13,6 +13,7 @@ interface Props { data: ComplexTagResponse[] | undefined; clickHandler: (identifier: any) => void; showAccessPanelHandler: (tag: any) => void; + showRemoveAccessPanelHandler: (tag: any) => void; setShowDeleteTagPanel: (show: boolean) => void; setSelectedTagToDelete: (tag: TagToDelete) => void; } @@ -24,7 +25,8 @@ const ComplexTagTable = ({ clickHandler, showAccessPanelHandler, setShowDeleteTagPanel, - setSelectedTagToDelete + setSelectedTagToDelete, + showRemoveAccessPanelHandler }: Props) => { const { keycloak } = useKeycloak(); const isDarkMode = useAppSelector(state => state.darkMode.value); @@ -71,6 +73,23 @@ const ComplexTagTable = ({ ) : null} ); + } else if (el.accessor === 'removeAccess') { + return ( + + {dataEl['owner'] || keycloak.hasRealmRole(TAG_ACCESS_OVERRIDE) ? ( + + ) : null} + + ); } else if (el.accessor === 'delete') { return ( diff --git a/src/components/Table/EntityTagTable.tsx b/src/components/Table/EntityTagTable.tsx index 60cc9a5f..06badbd8 100644 --- a/src/components/Table/EntityTagTable.tsx +++ b/src/components/Table/EntityTagTable.tsx @@ -9,6 +9,7 @@ import { TagUpdateRequest } from '../../features/tagging/providers/types'; import { TagToDelete } from '../../features/tagging/components/ComplexTagging'; import { TAG_ACCESS_OVERRIDE } from '../../constants'; import { useKeycloak } from '@react-keycloak/web'; +import { EntityTagResponse } from '../../features/planSimulation/providers/types'; interface Props { columns: { name: string; sortValue?: string; accessor?: string; key?: string }[]; @@ -17,7 +18,8 @@ interface Props { clickHandler?: (identifier: any) => void; clickAccessor?: string; updateTag: (tag: TagUpdateRequest) => void; - showAccessPanelHandler: (tag: any) => void; + showAccessPanelHandler: (tag: EntityTagResponse) => void; + showRemoveAccessPanelHandler: (tag: any) => void; setShowDeleteTagPanel: (show: boolean) => void; setSelectedTagToDelete: (tag: TagToDelete) => void; } @@ -42,12 +44,14 @@ const EntityTagTable = ({ updateTag, showAccessPanelHandler, setShowDeleteTagPanel, - setSelectedTagToDelete + setSelectedTagToDelete, + showRemoveAccessPanelHandler }: Props) => { const [sortDirection, setSortDirection] = useState(false); const [activeSortField, setActiveSortField] = useState(''); const isDarkMode = useAppSelector(state => state.darkMode.value); const { keycloak } = useKeycloak(); + return ( @@ -128,7 +132,31 @@ const EntityTagTable = ({ ) : null; + } else if (el.name === 'removeAccess') { + return dataEl['owner'] || keycloak.hasRealmRole(TAG_ACCESS_OVERRIDE) ? ( + + ) : null; } else if (el.name === 'owners') { return ( diff --git a/src/components/Table/MetadataEntityTagTable2.tsx b/src/components/Table/MetadataEntityTagTable2.tsx index 50a88679..5ea72207 100644 --- a/src/components/Table/MetadataEntityTagTable2.tsx +++ b/src/components/Table/MetadataEntityTagTable2.tsx @@ -11,9 +11,10 @@ interface Props { setMetadataList: (list: MetadataFileImportResponse[]) => void; metadataList: MetadataFileImportResponse[]; columns: Column[]; + addAccess: boolean; } -const MetadataEntityTagTable2 = ({ data, setMetadataList, metadataList, columns }: Props) => { +const MetadataEntityTagTable2 = ({ data, setMetadataList, metadataList, columns, addAccess }: Props) => { const isDarkMode = useAppSelector(state => state.darkMode.value); const mapRows = useCallback((row: BaseTag): EntityTagResponse[] => { @@ -154,22 +155,66 @@ const MetadataEntityTagTable2 = ({ data, setMetadataList, metadataList, columns ))} - ) : cell.column.id === 'resultingOrgGrants' ? ( + ) : cell.column.id === 'resultingOrgGrants' || cell.column.id === 'removeOrgGrants' ? ( -
{org.name}
+ {!addAccess ? ( +
user.name).includes(org.name) + ? 'red' + : '' + }} + > + {org.name} +
+ ) : ( +
user.name).includes(org.name) + ? 'green' + : '' + }} + > + {org.name} +
+ )} ))} - ) : cell.column.id === 'resultingUserGrants' ? ( + ) : cell.column.id === 'resultingUserGrants' || cell.column.id === 'removeUserGrants' ? ( -
{org.username}
+ {/*
{org.username}
*/} + + {/*{addAccess ? } */} + + {!addAccess ? ( +
user.username).includes(org.username) + ? 'red' + : '' + }} + > + {org.username} +
+ ) : ( +
user.username).includes(org.username) + ? 'green' + : '' + }} + > + {org.username} +
+ )} ))} diff --git a/src/features/access/RemoveTagAccess.tsx b/src/features/access/RemoveTagAccess.tsx new file mode 100644 index 00000000..a10e8633 --- /dev/null +++ b/src/features/access/RemoveTagAccess.tsx @@ -0,0 +1,101 @@ +import { Button, Modal } from 'react-bootstrap'; +import React, { useEffect, useState } from 'react'; +import { BaseTag, EntityTagResponse } from '../planSimulation/providers/types'; +import { removeComplexTagGrants, removeEntityTagGrants } from './api'; + +import TagAccessOrganization from './components/TagAccessOrganization'; + +interface Props { + showRemoveAccess: boolean; + setShowRemoveAccess: (val: boolean) => void; + selectedMetadata: BaseTag[]; + setTagGrantsUpdated: () => void; + type: 'tag' | 'complexTag'; +} + +const RemoveTagAccess = ({ + showRemoveAccess, + setShowRemoveAccess, + selectedMetadata, + setTagGrantsUpdated, + type +}: Props) => { + const [updatedMetadata, setUpdatedMetadata] = useState([]); + + useEffect(() => { + setUpdatedMetadata(selectedMetadata); + }, [selectedMetadata]); + + return ( + setShowRemoveAccess(false)}> + Remove Access To Tags + + + + + + + + + ); +}; +export default RemoveTagAccess; diff --git a/src/features/access/TagAccess.tsx b/src/features/access/TagAccess.tsx index d4cee825..6c809f34 100644 --- a/src/features/access/TagAccess.tsx +++ b/src/features/access/TagAccess.tsx @@ -1,6 +1,6 @@ import { Button, Modal } from 'react-bootstrap'; import React, { useEffect, useState } from 'react'; -import { BaseTag } from '../planSimulation/providers/types'; +import { BaseTag, EntityTagResponse } from '../planSimulation/providers/types'; import { updateComplexTagGrants, updateEntityTagGrants } from './api'; import TagAccessOrganization from './components/TagAccessOrganization'; @@ -22,12 +22,13 @@ const TagAccess = ({ showTagAccess, setShowTagAccess, selectedMetadata, setTagGr return ( setShowTagAccess(false)}> - Tag Access + Grant Access To Tags @@ -35,16 +36,35 @@ const TagAccess = ({ showTagAccess, setShowTagAccess, selectedMetadata, setTagGr variant="secondary" onClick={() => { if (type === 'tag') { - updateEntityTagGrants( - updatedMetadata.map(meta => { - return { - identifier: meta.identifier, - public: meta.public, - resultingOrgs: meta.resultingOrgs, - resultingUsers: meta.resultingUsers - }; - }) - ).then(() => { + const tags = updatedMetadata.map(meta => { + return { + identifier: meta.identifier, + public: meta.public, + resultingOrgs: meta.resultingOrgs, + resultingUsers: meta.resultingUsers + }; + }); + updatedMetadata + .filter( + updatedMetadataItem => + updatedMetadataItem && + updatedMetadataItem instanceof EntityTagResponse && + (updatedMetadataItem as EntityTagResponse) && + (updatedMetadataItem as EntityTagResponse).children + ) + .forEach(updatedMetadataItem => { + // @ts-ignore + (updatedMetadataItem as EntityTagResponse).children.forEach(child => { + tags.push({ + identifier: child.identifier, + public: child.public, + resultingOrgs: child.resultingOrgs, + resultingUsers: child.resultingUsers + }); + }); + }); + + updateEntityTagGrants(tags).then(() => { setTagGrantsUpdated(); }); } else if (type === 'complexTag') { diff --git a/src/features/access/api/index.ts b/src/features/access/api/index.ts index 7345f57c..5816e2fc 100644 --- a/src/features/access/api/index.ts +++ b/src/features/access/api/index.ts @@ -23,6 +23,25 @@ export const getOrganizationList = async ( return data; }; +export const searchOrganizationList = async ( + size: number, + page: number, + search?: string, + sortField?: string, + direction?: boolean +): Promise> => { + const data = await api + .get>( + ORGANIZATION + + '/search' + + `?search=${search !== undefined ? search : ''}&size=${size}&page=${page}&_summary=FALSE&root=true&sort=${ + sortField !== undefined ? sortField : '' + },${direction ? 'asc' : 'desc'}` + ) + .then(response => response.data); + return data; +}; + export const getOrganizationCount = async (): Promise<{ count: number }> => { const data = await api.get<{ count: number }>(ORGANIZATION + '?_summary=COUNT').then(response => response.data); return data; @@ -32,6 +51,10 @@ export const updateEntityTagGrants = async (tags: EntityTagAccessRequest[]): Pro const data = await api.post(ENTITY_TAG + `/updateGrants`, tags).then(response => response.data); return data; }; +export const removeEntityTagGrants = async (tags: EntityTagAccessRequest[]): Promise => { + const data = await api.post(ENTITY_TAG + `/removeGrants`, tags).then(response => response.data); + return data; +}; export const updateComplexTagGrants = async (tags: ComplexTagAccessRequest[]): Promise => { const data = await api @@ -40,6 +63,13 @@ export const updateComplexTagGrants = async (tags: ComplexTagAccessRequest[]): P return data; }; +export const removeComplexTagGrants = async (tags: ComplexTagAccessRequest[]): Promise => { + const data = await api + .post(ENTITY_TAG + `/removeComplexTagGrants`, tags) + .then(response => response.data); + return data; +}; + export const getUserList = async ( size: number, page: number, diff --git a/src/features/access/components/TagAccessOrgUserExpandingTable.tsx b/src/features/access/components/TagAccessOrgUserExpandingTable.tsx index 7e9ab0bc..12bbc3ba 100644 --- a/src/features/access/components/TagAccessOrgUserExpandingTable.tsx +++ b/src/features/access/components/TagAccessOrgUserExpandingTable.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useState } from 'react'; +import React, { useRef } from 'react'; import { Table, FormCheck, Col, Row as ReactRow } from 'react-bootstrap'; import { useTable, useExpanded, Column, Row } from 'react-table'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; @@ -32,8 +32,6 @@ const TagAccessOrgUserExpandingTable = ({ setSelectedUsers, makePublic }: Props) => { - const [sortDirection, setSortDirection] = useState(false); - const [activeSortField, setActiveSortField] = useState(''); const isDarkMode = useAppSelector(state => state.darkMode.value); const expandAll = useRef(); @@ -387,30 +385,10 @@ const TagAccessOrgUserExpandingTable = ({ {headerGroups.map(headerGroup => ( {headerGroup.headers.map(column => ( - ))} diff --git a/src/features/access/components/TagAccessOrganization.tsx b/src/features/access/components/TagAccessOrganization.tsx index f98dd125..fcd79447 100644 --- a/src/features/access/components/TagAccessOrganization.tsx +++ b/src/features/access/components/TagAccessOrganization.tsx @@ -1,6 +1,6 @@ import React, { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react'; import { Accordion, Col, FormCheck, OverlayTrigger, Row, Tooltip } from 'react-bootstrap'; -import { getOrganizationCount, getOrganizationList, getUserList } from '../api'; +import { getOrganizationCount, getUserList, searchOrganizationList } from '../api'; import { Code, OrganizationModel } from '../providers/types'; import Paginator from '../../../components/Pagination'; import { PAGINATION_DEFAULT_SIZE } from '../../../constants'; @@ -35,9 +35,10 @@ interface Props { metadata: BaseTag[]; updatedMetadata: BaseTag[]; setUpdatedMetadata: React.Dispatch>; + addAccess: boolean; } -const TagAccessOrganization = ({ metadata, updatedMetadata, setUpdatedMetadata }: Props) => { +const TagAccessOrganization = ({ metadata, updatedMetadata, setUpdatedMetadata, addAccess }: Props) => { const [organizationAdaptedList, setOrganizationAdaptedList] = useState([]); const [organizationAdaptedListPaged, setOrganizationAdaptedListPaged] = useState>(); @@ -72,12 +73,70 @@ const TagAccessOrganization = ({ metadata, updatedMetadata, setUpdatedMetadata } return newList; }, []); + const columnsForMetadataTables = React.useMemo[]>( + () => [ + { + // Build our expander column + id: 'expander', // Make sure it has an ID + Cell: ({ row }: { row: any }) => + // Use the row.canExpand and row.getToggleRowExpandedProps prop getter + // to build the toggle for expanding a row + { + return row.canExpand ? ( + + {row.isExpanded ? ( + + ) : ( + + )} + + ) : null; + } + }, + { Header: 'tag', accessor: 'tag' }, + { Header: 'isPublic', accessor: 'public' }, + { Header: 'orgGrants' }, + { Header: 'userGrants' }, + { Header: addAccess ? 'resultingOrgGrants' : 'removeOrgGrants' }, + { Header: addAccess ? 'resultingUserGrants' : 'removeUserGrants' } + ], + [addAccess] + ); + const columnsForMetadataTablesWithoutChildren = React.useMemo[]>( + () => [ + { Header: 'tag', accessor: 'tag' }, + { Header: 'isPublic', accessor: 'public' }, + { Header: 'orgGrants' }, + { Header: 'userGrants' }, + { Header: addAccess ? 'resultingOrgGrants' : 'removeOrgGrants' }, + { Header: addAccess ? 'resultingUserGrants' : 'removeUserGrants' } + ], + [addAccess] + ); + const getColumns = useCallback(() => { + return updatedMetadata != null && updatedMetadata.length === 1 && !(updatedMetadata[0] instanceof EntityTagResponse) + ? columnsForMetadataTablesWithoutChildren + : columnsForMetadataTables; + }, [updatedMetadata, columnsForMetadataTables, columnsForMetadataTablesWithoutChildren]); + const loadData = useCallback( (size: number, page: number, searchData?: string, field?: string, sortDirection?: boolean) => { Promise.all([ - getOrganizationList(size, page, searchData !== undefined ? searchData : '', field, sortDirection), + searchOrganizationList(size, page, searchData !== undefined ? searchData : '', field, sortDirection), getOrganizationCount(), - getUserList(1000, 0, '', 'username') + getUserList(1000, 0, searchData !== undefined ? searchData : '', 'username') ]) .then(async ([organizations, { count }, userModels]) => { let orgUserList: OrgUserList = {}; @@ -241,69 +300,15 @@ const TagAccessOrganization = ({ metadata, updatedMetadata, setUpdatedMetadata } }); }, [makePublic, metadata, setUpdatedMetadata]); - const columnsForMetadataTables = React.useMemo[]>( - () => [ - { - // Build our expander column - id: 'expander', // Make sure it has an ID - Cell: ({ row }: { row: any }) => - // Use the row.canExpand and row.getToggleRowExpandedProps prop getter - // to build the toggle for expanding a row - { - return row.canExpand ? ( - - {row.isExpanded ? ( - - ) : ( - - )} - - ) : null; - } - }, - { Header: 'tag', accessor: 'tag' }, - { Header: 'isPublic', accessor: 'public' }, - { Header: 'orgGrants' }, - { Header: 'userGrants' }, - { Header: 'resultingOrgGrants' }, - { Header: 'resultingUserGrants' } - ], - [] - ); - - const columnsForMetadataTablesWithoutChildren = React.useMemo[]>( - () => [ - { Header: 'tag', accessor: 'tag' }, - { Header: 'isPublic', accessor: 'public' }, - { Header: 'orgGrants' }, - { Header: 'userGrants' }, - { Header: 'resultingOrgGrants' }, - { Header: 'resultingUserGrants' } - ], - [] - ); - return ( <> { // setUpdatedMetadata([]); setSelectedOrganizations([]); setSelectedUsers([]); - setMakePublic(evt.currentTarget.checked); + setMakePublic(addAccess ? evt.currentTarget.checked : !evt.currentTarget.checked); loadData(PAGINATION_DEFAULT_SIZE, 0); }} /> @@ -382,11 +387,8 @@ const TagAccessOrganization = ({ metadata, updatedMetadata, setUpdatedMetadata } } setMetadataList={() => {}} metadataList={[]} - columns={ - updatedMetadata != null && updatedMetadata.length === 1 - ? columnsForMetadataTablesWithoutChildren - : columnsForMetadataTables - } + columns={getColumns()} + addAccess={addAccess} /> diff --git a/src/features/metaDataImport/components/fileImport/MetaFileImport.tsx b/src/features/metaDataImport/components/fileImport/MetaFileImport.tsx index aaf46f7e..db46a846 100644 --- a/src/features/metaDataImport/components/fileImport/MetaFileImport.tsx +++ b/src/features/metaDataImport/components/fileImport/MetaFileImport.tsx @@ -13,6 +13,7 @@ import MetadataImportTable from '../../../../components/Table/MetadataImportTabl import { MetadataFileImportResponse } from '../../type'; import Paginator from '../../../../components/Pagination'; import TagAccess from '../../../access/TagAccess'; +import RemoveTagAccess from '../../../access/RemoveTagAccess'; const MetaFileImport = () => { const [open, setOpen] = useState(false); @@ -21,6 +22,7 @@ const MetaFileImport = () => { const [metadataImportList, setMetadataImportList] = useState([]); const [selectedMetadata, setSelectedMetadata] = useState([]); const [selectedMetaImport, setSelectedMetaImport] = useState(); + const [showRemoveAccess, setShowRemoveAccess] = useState(false); // const [setEntityTagsCreated] = useState(); const { t } = useTranslation(); @@ -133,6 +135,7 @@ const MetaFileImport = () => { const setTagGrantsUpdated = () => { setOpenAccess(false); + setShowRemoveAccess(false); loadData(PAGINATION_DEFAULT_SIZE, 0); }; @@ -159,6 +162,17 @@ const MetaFileImport = () => { Grant Access + + + @@ -204,10 +218,19 @@ const MetaFileImport = () => { selectedFile={selectedMetaImport} /> )} + {showRemoveAccess && ( + + )} {openAccess && ( { const [combinedHierarchyList, setCombinedHierarchyList] = useState(); @@ -41,6 +43,7 @@ const ComplexTagging = () => { const [showDeleteTagPanel, setShowDeleteTagPanel] = useState(false); const [selectedTagToDelete, setSelectedTagToDelete] = useState(); const [selectedMetadata, setSelectedMetadata] = useState([]); + const [showRemoveAccess, setShowRemoveAccess] = useState(false); useEffect(() => { Promise.all([getLocationHierarchyList(50, 0, true), getEntityList(), getGeneratedLocationHierarchyList()]) @@ -94,8 +97,32 @@ const ComplexTagging = () => { setSelectedMetadata([complexTag]); }; + const setShowRemoveAccessWithSelectedTag = (tag: ComplexTagResponse) => { + setShowRemoveAccess(true); + + const complexTag = new ComplexTagResponse( + tag.id, + tag.hierarchyId, + tag.hierarchyType, + tag.tagName, + tag.tags, + tag.formula, + tag.owner, + tag.owners, + tag.calculateValue, + tag.public, + tag.tagAccGrantsOrganization, + tag.tagAccGrantsUser, + tag.selected, + tag.resultingOrgs, + tag.resultingUsers + ); + setSelectedMetadata([complexTag]); + }; + const setTagGrantsUpdated = () => { setShowTagAccess(false); + setShowRemoveAccess(false); getComplexTagReponses().then(data => setComplexTags(data)); }; @@ -141,6 +168,7 @@ const ComplexTagging = () => { { name: 'complexTagVariables', accessor: 'complexTagVariables', sortValue: 'tags', key: 'tags' }, { name: 'owners', accessor: 'owners', sortValue: 'owners', key: 'owners' }, { name: 'access', accessor: 'access', sortValue: 'access', key: 'access' }, + { name: 'removeAccess', accessor: 'removeAccess', sortValue: 'removeAccess', key: 'removeAccess' }, { name: 'delete', accessor: 'delete', sortValue: 'delete', key: 'delete' } ]} data={complexTags} @@ -151,6 +179,7 @@ const ComplexTagging = () => { showAccessPanelHandler={setShowTagAccessWithSelectedTag} setShowDeleteTagPanel={setShowDeleteTagPanel} setSelectedTagToDelete={setSelectedTagToDelete} + showRemoveAccessPanelHandler={setShowRemoveAccessWithSelectedTag} /> ) : (

No data found.

@@ -189,6 +218,15 @@ const ComplexTagging = () => { type={'complexTag'} /> )} + {showRemoveAccess && ( + + )} {showDeleteTagPanel && ( { @@ -42,6 +44,7 @@ const Tagging = () => { const [currentSortField, setCurrentSortField] = useState(''); const [currentSearchInput, setCurrentSearchInput] = useState(''); const [showTagAccess, setShowTagAccess] = useState(false); + const [showRemoveAccess, setShowRemoveAccess] = useState(false); const [selectedMetadata, setSelectedMetadata] = useState([]); const [showDeleteTagPanel, setShowDeleteTagPanel] = useState(false); const [selectedTagToDelete, setSelectedTagToDelete] = useState(); @@ -50,6 +53,15 @@ const Tagging = () => { const loadData = useCallback((size: number, page: number, filter?: string, field?: string, direction?: boolean) => { getAllGlobalTags(size, page, filter, field, direction) .then(res => { + let entityTagsNotAggregate: Tag[] | undefined = res.content?.filter(entityTag => !entityTag.aggregate); + + let entityTagWithChildren = entityTagsNotAggregate?.map(entityTag => { + entityTag.children = res.content?.filter(entityTagEvent => { + return entityTagEvent.aggregate && entityTagEvent.referencedTag === entityTag.identifier; + }); + return entityTag; + }); + res.content = entityTagWithChildren; setTagList(res); }) .catch(err => toast.error(err)); @@ -60,21 +72,15 @@ const Tagging = () => { }, [loadData]); useEffect(() => { - console.log(selectedTagToDelete); - let tags = tagList?.content - .filter(tag => { - return tag.referencedTag === selectedTagToDelete?.id; - }) - .map(tag => { - return { - id: tag.identifier, - type: 'Simple', - tag: tag.tag - }; - }); - console.log(tags); - setSelectedTagsToDelete(tags); - }, [selectedTagToDelete, tagList]); + if (selectedTagToDelete) { + let tags = []; + tags.push(selectedTagToDelete); + if (selectedTagToDelete.children) { + tags.push(...selectedTagToDelete.children); + } + setSelectedTagsToDelete(tags); + } + }, [selectedTagToDelete]); const paginationHandler = (size: number, page: number) => { loadData(size, page, currentSearchInput, currentSortField, currentSortDirection); @@ -110,35 +116,41 @@ const Tagging = () => { accessor: 'tag', sortValue: 'access' }); + columns.push({ + name: 'removeAccess', + accessor: 'removeAccess', + sortValue: 'removeAccess' + }); columns.push({ name: 'delete', accessor: 'delete', sortValue: 'delete' }); + return columns; }; - const setShowTagAccessWithSelectedTag = (tag: any) => { + const setShowTagAccessWithSelectedTag = (tag: EntityTagResponse) => { setShowTagAccess(true); - setSelectedMetadata([ - { - identifier: tag.identifier, - tag: tag.tag, - definition: tag.definition, - valueType: tag.valueType, - aggregate: tag.aggregate, - created: tag.created, - metadataImportId: tag.metadataImportId, - tagAccGrantsUser: tag.tagAccGrantsUser, - tagAccGrantsOrganization: tag.tagAccGrantsOrganization, - owner: tag.owner, - owners: tag.owners - } - ]); + console.log('is it here', tag instanceof EntityTagResponse); + + setSelectedMetadata([tag]); + }; + + const setShowRemoveAccessWithSelectedTag = (tag: EntityTagResponse) => { + setShowRemoveAccess(true); + + setSelectedMetadata([tag]); }; + useEffect(() => { + console.log('selectedMetadata', selectedMetadata); + console.log('selectedMetadata', selectedMetadata); + }, [selectedMetadata]); + const setTagGrantsUpdated = () => { setShowTagAccess(false); + setShowRemoveAccess(false); loadData(PAGINATION_DEFAULT_SIZE, 0); }; @@ -186,6 +198,7 @@ const Tagging = () => { showAccessPanelHandler={setShowTagAccessWithSelectedTag} setShowDeleteTagPanel={setShowDeleteTagPanel} setSelectedTagToDelete={setSelectedTagToDelete} + showRemoveAccessPanelHandler={setShowRemoveAccessWithSelectedTag} /> { {showTagAccess && ( + )} + {showRemoveAccess && ( + { const { register, handleSubmit, - watch, control, formState: { errors } } = useForm({ @@ -28,26 +26,6 @@ const CreateTag = ({ closeHandler }: Props) => { name: 'tags' }); - const selectedValueType = watch('valueType'); - - useEffect(() => { - let selected: string[] = []; - switch (selectedValueType) { - case 'number': - selected = NUMBER_AGGREGATION; - break; - case 'string': - selected = BOOLEAN_STRING_AGGREGATION; - break; - case 'date': - selected = DATA_AGGREGATION; - break; - case 'boolean': - selected = BOOLEAN_STRING_AGGREGATION; - break; - } - }, [selectedValueType]); - const submitHandler = (form: TagCreateRequest) => { form.tags.forEach(tag => { tag.name = tag.name.replaceAll(' ', '-'); diff --git a/src/features/tagging/providers/types.ts b/src/features/tagging/providers/types.ts index 4faad1df..2d13985a 100644 --- a/src/features/tagging/providers/types.ts +++ b/src/features/tagging/providers/types.ts @@ -11,6 +11,9 @@ export interface Tag { owner: boolean; owners: Owners[]; referencedTag: String; + aggregate: boolean; + children?: Tag[]; + deleting: boolean; } export interface TagCreateRequest {
+ + @@ -147,21 +213,30 @@ const EntityTagTable = ({ } else if (el.accessor === 'delete') { return ( - {(dataEl['owner'] && !dataEl['aggregate']) || keycloak.hasRealmRole(TAG_ACCESS_OVERRIDE) ? ( + {(dataEl['owner'] || keycloak.hasRealmRole(TAG_ACCESS_OVERRIDE)) && !dataEl['aggregate'] ? ( ) : null} {cellData.resultingOrgs?.map(org => (
{cellData.resultingUsers?.map(org => (
{ - if (column.id !== 'expander') { - setSortDirection(!sortDirection); - setActiveSortField(column.Header?.toString() ?? ''); - sortHandler(column.id, sortDirection); - } - }} - {...column.getHeaderProps()} - > + {checkColumn(column) ? t('reportPage.table.' + column.Header?.toString(), column.Header?.toString()) : ''} - {activeSortField === column.render('Header') ? ( - sortDirection ? ( - - ) : ( - - ) - ) : column.id !== 'expander' ? ( - - ) : null}