diff --git a/cypress/e2e/3_cache-aliases.cy.js b/cypress/e2e/3_cache-aliases.cy.js new file mode 100644 index 000000000..ba49efdcc --- /dev/null +++ b/cypress/e2e/3_cache-aliases.cy.js @@ -0,0 +1,51 @@ +describe('Data Container Caches', () => { + beforeEach(() => { + cy.login(Cypress.env('username'), Cypress.env('password')); + }); + + it('successfully add / update / remove an alias', () => { + cy.get('[data-cy=actions-default]').click(); + cy.get('[aria-label=updateAliasesCacheAction]').click(); + cy.get('[data-cy=updateAliasesCacheModal]').should('exist'); + cy.get('#updateAliasesCacheModal [aria-label=Close]').click(); //Closing modal with close button + cy.get('[data-cy=updateAliasesCacheModal]').should('not.exist'); + + cy.get('[data-cy=actions-default]').click(); + cy.get('[aria-label=updateAliasesCacheAction]').click(); + cy.get('[data-cy=updateAliasesCacheModal]').should('exist'); + cy.get('[data-cy=closeAction]').click(); //Closing modal with Close button + cy.get('[data-cy=updateAliasesCacheModal]').should('not.exist'); + cy.get('[data-cy=actions-default]').click(); + cy.get('[aria-label=updateAliasesCacheAction]').click(); + // add aliases + cy.get('[data-cy=menu-toogle-aliasesSelector]') + .click().type('alias1') + .type('{enter}'); + cy.get('[data-cy=updateAliasesButton]').click(); //Update aliases + cy.get('[data-cy=closeAction]').click(); //Closing modal with Close button + cy.contains('alias1'); + + // Check detail has aliases + cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/default'); + cy.contains('Aliases'); + cy.contains('alias1'); + cy.login(Cypress.env('username'), Cypress.env('password')); + + cy.get('[data-cy=actions-default]').click(); + cy.get('[aria-label=updateAliasesCacheAction]').click(); + // add aliases + cy.get('[data-cy=menu-toogle-aliasesSelector]') + .click().type('alias1') + .type('{enter}'); + cy.get('[data-cy=updateAliasesButton]').click(); //Update aliases + cy.get('[data-cy=closeAction]').click(); //Closing modal with Close button + cy.contains('alias1').should('not.exist'); + cy.contains('Success alert:Cache default successfully updated.'); + + // Check detail has aliases + cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/default'); + cy.contains('Aliases').should('not.exist'); + cy.contains('alias1').should('not.exist'); + cy.login(Cypress.env('username'), Cypress.env('password')); + }); +}); diff --git a/cypress/e2e/3_cache-ignore.cy.js b/cypress/e2e/3_cache-ignore.cy.js index 036bdf48f..8333a11a2 100644 --- a/cypress/e2e/3_cache-ignore.cy.js +++ b/cypress/e2e/3_cache-ignore.cy.js @@ -1,4 +1,4 @@ -describe('Data Container Caches list', () => { +describe('Data Container Caches', () => { beforeEach(() => { cy.login(Cypress.env('username'), Cypress.env('password')); }); diff --git a/src/app/CacheManagers/CacheTableDisplay.tsx b/src/app/CacheManagers/CacheTableDisplay.tsx index 8e537a558..41da10788 100644 --- a/src/app/CacheManagers/CacheTableDisplay.tsx +++ b/src/app/CacheManagers/CacheTableDisplay.tsx @@ -72,7 +72,7 @@ const CacheTableDisplay = (props: { setCachesCount: (count: number) => void; isV const { t } = useTranslation(); const { connectedUser } = useConnectedUser(); const { setBanner } = useBanner(); - const { caches, errorCaches, loadingCaches } = useCaches(); + const { caches, errorCaches, loadingCaches, reloadCaches } = useCaches(); const { cm } = useDataContainer(); const [filteredCaches, setFilteredCaches] = useState([]); @@ -160,11 +160,22 @@ const CacheTableDisplay = (props: { setCachesCount: (count: number) => void; isV }, [rows]); useEffect(() => { - setFilteredCaches(caches.filter((cache) => onSearch(searchValue, cache.name)).filter(onFilter)); + setFilteredCaches( + caches + .filter( + (cache) => + // on cache name + onSearch(searchValue, cache.name) || + // on aliases + cache.aliases.map((alias) => onSearch(searchValue, alias)).filter((r) => r).length > 0 + ) + .filter(onFilter) + ); }, [searchValue, selectedCacheFeature, selectedCacheType, selectedCacheStatus]); const columnNames = { name: t('cache-managers.cache-name'), + aliases: t('cache-managers.cache-aliases'), mode: t('cache-managers.cache-mode'), health: t('cache-managers.cache-health'), features: t('cache-managers.cache-features'), @@ -332,6 +343,27 @@ const CacheTableDisplay = (props: { setCachesCount: (count: number) => void; isV ); }; + const displayCacheAliases = (cacheInfo: CacheInfo) => { + if (cacheInfo.aliases.length == 0) { + return ( + + + {t('cache-managers.aliases-none')} + + + ); + } + return ( + + {cacheInfo.aliases.map((alias) => ( + + ))} + + ); + }; + const displayCacheFeatures = (cacheInfo: CacheInfo) => { return ( @@ -798,6 +830,7 @@ const CacheTableDisplay = (props: { setCachesCount: (count: number) => void; isV {columnNames.name} + {columnNames.aliases} {columnNames.mode} {columnNames.health} {columnNames.features} @@ -814,6 +847,7 @@ const CacheTableDisplay = (props: { setCachesCount: (count: number) => void; isV return ( {displayCacheName(row)} + {displayCacheAliases(row)} {displayCacheType(row.type)} {displayCacheHealth(row.health)} {displayCacheFeatures(row)} @@ -851,7 +885,10 @@ const CacheTableDisplay = (props: { setCachesCount: (count: number) => void; isV setCacheAction({ cacheName: '', action: '' })} + closeModal={() => { + setCacheAction({ cacheName: '', action: '' }); + reloadCaches(); + }} /> diff --git a/src/app/Caches/DetailCache.tsx b/src/app/Caches/DetailCache.tsx index ae3af95a7..27eb0eada 100644 --- a/src/app/Caches/DetailCache.tsx +++ b/src/app/Caches/DetailCache.tsx @@ -48,6 +48,7 @@ import { global_BackgroundColor_100, global_danger_color_200, global_info_color_200, + global_spacer_xs, global_warning_color_100 } from '@patternfly/react-tokens'; import { ExclamationCircleIcon, InfoCircleIcon, InfoIcon, RedoIcon } from '@patternfly/react-icons'; @@ -349,11 +350,30 @@ const DetailCache = (props: { cacheName: string }) => { ); }; + const buildAliasesChips = () => { + if (!cache?.aliases || cache?.aliases?.length == 0) return; + + return ( + + + + {cache.aliases.map((feature) => ( + + ))} + + + + ); + }; + const buildShowMorePanel = () => { return ( + {buildAliasesChips()} {cacheManager.tracing_enabled && ( diff --git a/src/app/Caches/SetAvailableCache.tsx b/src/app/Caches/SetAvailableCache.tsx index 0a2dbc1b2..c13e9c015 100644 --- a/src/app/Caches/SetAvailableCache.tsx +++ b/src/app/Caches/SetAvailableCache.tsx @@ -13,7 +13,6 @@ const SetAvailableCache = (props: { cacheName: string; isModalOpen: boolean; clo const { onSetAvailable } = useSetAvailableCache(props.cacheName); const { t } = useTranslation(); - const brandname = t('brandname.brandname'); const clearSetAvailableCacheModal = (setAvailableDone: boolean) => { props.closeModal(setAvailableDone); diff --git a/src/app/Caches/UpdateAliasCache.tsx b/src/app/Caches/UpdateAliasCache.tsx index ceca572ea..cad954d3a 100644 --- a/src/app/Caches/UpdateAliasCache.tsx +++ b/src/app/Caches/UpdateAliasCache.tsx @@ -9,7 +9,6 @@ import { SelectMultiWithChips } from '@app/Common/SelectMultiWithChips'; */ const UpdateAliasCache = (props: { cacheName: string; isModalOpen: boolean; closeModal: (boolean) => void }) => { const { loading, setLoading, error, aliases, setAliases, update } = useCacheAliases(props.cacheName); - const { t } = useTranslation(); useEffect(() => { @@ -69,8 +68,8 @@ const UpdateAliasCache = (props: { cacheName: string; isModalOpen: boolean; clos return ( ,