From 228771bae7404479e59f402fc7fba031275cf732 Mon Sep 17 00:00:00 2001 From: Katia Aresti Date: Tue, 10 Oct 2023 16:13:25 +0200 Subject: [PATCH] ISPN-15125 Display correctly metrics when no entries and admin --- cypress/e2e/rbac_func.cy.js | 29 +++++++++ package-lock.json | 60 +++++++++--------- package.json | 2 +- src/app/CacheManagers/CacheTableDisplay.tsx | 23 ++++++- src/app/Caches/DetailCache.tsx | 69 ++++++++------------- 5 files changed, 107 insertions(+), 76 deletions(-) diff --git a/cypress/e2e/rbac_func.cy.js b/cypress/e2e/rbac_func.cy.js index 78697185e..c0f64e910 100644 --- a/cypress/e2e/rbac_func.cy.js +++ b/cypress/e2e/rbac_func.cy.js @@ -10,6 +10,8 @@ describe('RBAC Functionlity Tests', () => { checkSecuredCacheDetailsView(true, false, false, 'monitor', 'indexed-cache'); checkNotOwnSecuredCache('super-cache'); checkNonSecuredCacheDetailView(true, false); + cy.login(monitorUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(false); }); it('successfully logins and performs actions with observer user', () => { @@ -31,6 +33,8 @@ describe('RBAC Functionlity Tests', () => { //Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix) checkSchemasPageView(false); checkCountersPageView(); + cy.login(observerUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(false); }); it('successfully logins and performs actions with application user', () => { @@ -45,6 +49,8 @@ describe('RBAC Functionlity Tests', () => { //Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix) checkSchemasPageView(false); checkCountersPageView(); + cy.login(applicationUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(false); }); it('successfully logins and performs actions with deployer user', () => { @@ -59,6 +65,8 @@ describe('RBAC Functionlity Tests', () => { //Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix) checkSchemasPageView(true); checkCountersPageView(); + cy.login(deployerUserName, Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(false); }); it('successfully logins and performs actions with admin user', () => { @@ -74,6 +82,8 @@ describe('RBAC Functionlity Tests', () => { checkSchemasPageView(true); checkCountersPageView(); checkTasksPage(); + cy.login(Cypress.env('username'), Cypress.env('password'), '/cache/default'); + checkNoEntriesTabView(true); }); function checkDataContainerView(isMonitor, isDeployer, isAdmin, isSuperAdmin) { @@ -192,6 +202,25 @@ describe('RBAC Functionlity Tests', () => { cy.contains(/cacheName$/).should('not.exist'); } + function checkNoEntriesTabView(isSuperAdmin) { + // nobody sees manage metrics tab for default cache + cy.get('[data-cy=manageEntriesTab]').should('not.exist'); + cy.get('[data-cy=cacheMetricsTab]').should('exist'); + if (isSuperAdmin) { + cy.get('[data-cy=cacheConfigurationTab]').should('exist'); + // config tab is visible + cy.contains('JSON').should('exist'); + cy.get('[data-cy=cacheMetricsTab]').click(); + cy.contains('Data access').should('exist'); + } else { + // no config tab + cy.get('[data-cy=cacheConfigurationTab]').should('not.exist'); + // metrics tab is visible + cy.contains('Data access').should('exist'); + } + + } + function checkNonSecuredCacheDetailView(isMonitor, isSuperAdmin) { //Checking actions on non-secured cache cy.get('[data-cy=detailButton-indexed-cache-no-auth]').click(); diff --git a/package-lock.json b/package-lock.json index d93c72a5e..8dbea4c25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "infinispan-console", - "version": "14.0.7", + "version": "14.0.13", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3039,7 +3039,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, "at-least-node": { @@ -3297,7 +3297,7 @@ "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", "dev": true }, "brace-expansion": { @@ -3532,7 +3532,7 @@ "check-more-types": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/check-more-types/-/check-more-types-2.24.0.tgz", - "integrity": "sha1-FCD/sQ/URNz8ebQ4kbv//TKoRgA=", + "integrity": "sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==", "dev": true }, "chokidar": { @@ -3746,7 +3746,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "connect-history-api-fallback": { @@ -4383,7 +4383,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "dev": true }, "depd": { @@ -5655,7 +5655,7 @@ "format": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz", - "integrity": "sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs=" + "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==" }, "forwarded": { "version": "0.2.0", @@ -5694,7 +5694,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "fsevents": { @@ -6575,7 +6575,7 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -6633,7 +6633,7 @@ "irregular-plurals": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.4.0.tgz", - "integrity": "sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y=", + "integrity": "sha512-kniTIJmaZYiwa17eTtWIfm0K342seyugl6vuC8DiiyiRAJWAVlLkqGCI0Im0neo0TkXw+pRcKaBPRdcKHnQJ6Q==", "dev": true }, "is-alphabetical": { @@ -6754,7 +6754,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-fullwidth-code-point": { @@ -6890,7 +6890,7 @@ "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, "is-unicode-supported": { @@ -6942,13 +6942,13 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", "dev": true }, "isstream": { @@ -8689,7 +8689,7 @@ "lazy-ass": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/lazy-ass/-/lazy-ass-1.6.0.tgz", - "integrity": "sha1-eZllXoZGwX8In90YfRUNMyTVRRM=", + "integrity": "sha512-cc8oEVoctTvsFZ/Oje/kGnHbpWHYBe8IAJe4C0QNc3t8uM/0Y8+erSz/7Y1ALuXTEZTMvxXwO6YbX1ey3ujiZw==", "dev": true }, "leven": { @@ -8903,19 +8903,19 @@ "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dev": true }, "lodash.isequal": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", "dev": true }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", "dev": true }, "lodash.memoize": { @@ -8939,7 +8939,7 @@ "lodash.set": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", - "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=", + "integrity": "sha512-4hNPN5jlm/N/HLMCO43v8BXKq9Z7QdAGc/VGrRD61w8gN9g/6jF9A4L1pbUgBLCffi0w9VsXfTOij5x8iTyFvg==", "dev": true }, "lodash.truncate": { @@ -9470,7 +9470,7 @@ "numeral": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/numeral/-/numeral-2.0.6.tgz", - "integrity": "sha1-StCAk21EPCVhrtnyGX7//iX05QY=" + "integrity": "sha512-qaKRmtYPZ5qdw4jWJD6bxEf1FJEqllJrwxCLIm0sQU/A7v2/czigzOb+C2uSiFsa9lBUzeH7M1oK+Q+OLxL3kA==" }, "nwsapi": { "version": "2.2.0", @@ -9481,7 +9481,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" }, "object-inspect": { "version": "1.9.0", @@ -10172,7 +10172,7 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" @@ -10369,7 +10369,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-key": { @@ -10458,7 +10458,7 @@ "plur": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/plur/-/plur-2.1.2.tgz", - "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", + "integrity": "sha512-WhcHk576xg9y/iv6RWOuroZgsqvCbJN+XGvAypCJwLAYs2iWDp5LUmvaCdV6JR2O0SMBf8l6p7A94AyLCFVMlQ==", "dev": true, "requires": { "irregular-plurals": "^1.0.0" @@ -11354,13 +11354,13 @@ "requestidlecallback": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/requestidlecallback/-/requestidlecallback-0.3.0.tgz", - "integrity": "sha1-b7dOBzP5DfP6pIOPn2oqX5t0KsU=", + "integrity": "sha512-TWHFkT7S9p7IxLC5A1hYmAYQx2Eb9w1skrXmQ+dS1URyvR8tenMLl4lHbqEOUnpEYxNKpkVMXUgknVpBZWXXfQ==", "dev": true }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, "require-from-string": { @@ -12666,7 +12666,7 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "throat": { @@ -12684,7 +12684,7 @@ "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "thunky": { @@ -12995,7 +12995,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "util-extend": { @@ -13842,7 +13842,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "write-file-atomic": { diff --git a/package.json b/package.json index 5f5bce5b8..bda5c1b05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "infinispan-console", - "version": "14.0.7", + "version": "14.0.13", "description": "The console for Infinispan/Red Hat Data Grid", "main": "index.js", "repository": "https://github.com/infinispan/infinispan-console.git", diff --git a/src/app/CacheManagers/CacheTableDisplay.tsx b/src/app/CacheManagers/CacheTableDisplay.tsx index 9b3c17702..7c64623f8 100644 --- a/src/app/CacheManagers/CacheTableDisplay.tsx +++ b/src/app/CacheManagers/CacheTableDisplay.tsx @@ -16,7 +16,7 @@ import { Select, SelectGroup, SelectOption, - SelectVariant, + SelectVariant, Spinner, Text, TextContent, TextVariants, @@ -287,7 +287,26 @@ const CacheTableDisplay = (props: { cmName: string; setCachesCount: (count: numb disableActions: boolean; }[]; - if (currentPageCaches.length == 0 || loadingCaches || errorCaches != '') { + if (loadingCaches) { + currentRows = [ + { + heightAuto: true, + disableActions: true, + cells: [ + { + props: { colSpan: 5 }, + title: ( + + + + + + ) + } + ] + } + ]; + } else if (currentPageCaches.length == 0 || errorCaches != '') { currentRows = [ { heightAuto: true, diff --git a/src/app/Caches/DetailCache.tsx b/src/app/Caches/DetailCache.tsx index 55969e01e..300c56e90 100644 --- a/src/app/Caches/DetailCache.tsx +++ b/src/app/Caches/DetailCache.tsx @@ -60,7 +60,7 @@ const DetailCache = (props: { cacheName: string }) => { const encodingDocs = t('brandname.encoding-docs-link'); const { connectedUser } = useConnectedUser(); const { loading, error, cache, loadCache } = useCacheDetail(); - const [activeTabKey1, setActiveTabKey1] = useState(0); + const [activeTabKey1, setActiveTabKey1] = useState(''); const [activeTabKey2, setActiveTabKey2] = useState(10); const [displayShowMore, setDisplayShowMore] = useState(true); @@ -68,6 +68,20 @@ const DetailCache = (props: { cacheName: string }) => { loadCache(cacheName); }, []); + useEffect(() => { + if (activeTabKey1 != '' || !cache) { + return; + } + + if (cache.editable && ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.READ, cacheName, connectedUser)) { + setActiveTabKey1(0); + } else if (ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser)) { + setActiveTabKey1(1); + } else { + setActiveTabKey1(2); + } + }, [cache]) + const encodingMessageDisplay = () => { if (!ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.READ, cacheName, connectedUser)) { return ''; @@ -184,34 +198,19 @@ const DetailCache = (props: { cacheName: string }) => { ); } - const displayEntries: boolean = cache.editable && - ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.READ, cacheName, connectedUser); - - const displayConf: boolean = ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser); - - if ( - activeTabKey1 == 0 && displayEntries) { + if (activeTabKey1 == 0) { return {buildEntriesTabContent(cache.queryable)}; } - if (displayConf && (activeTabKey1 == 1 || (!displayEntries && activeTabKey1 == 0))) { + if (activeTabKey1 == 1) { return ( cache.configuration && ); } - let metricsKey = 2; - if (!displayConf) { - metricsKey --; - } - if (!displayEntries) { - metricsKey--; - } - if (activeTabKey1 == metricsKey) { - return ( - - ); - } - return ''; + + return ( + + ); }; const buildBackupsManage = () => { @@ -404,33 +403,17 @@ const DetailCache = (props: { cacheName: string }) => { return ; } - let eventKey = 1; - if (!ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.READ, cacheName, connectedUser) || !cache.editable) { - eventKey--; - } - - return ; + return ( + + ); }; const displayCacheStats = () => { - if (!cache.stats) { - return ''; - } - - let eventKey = 2; - if (!ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.READ, cacheName, connectedUser) || !cache.editable) { - eventKey--; - } - - if (!ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser)) { - eventKey--; - } - return ( ); };