Skip to content

Commit 5556de1

Browse files
committed
[#629] Add cache delete in cache detail
1 parent 8f1324d commit 5556de1

File tree

6 files changed

+54
-7
lines changed

6 files changed

+54
-7
lines changed

cypress/e2e/2_cache-detail.cy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ describe('Cache Detail Overview', () => {
326326
cy.contains('Rebalancing is on');
327327
});
328328

329+
it('successfully displays delete cache modal', () => {
330+
cy.get('[data-cy=detailCacheActions]').click();
331+
cy.get("[data-cy=manageDeleteLink]").click();
332+
cy.get('#deleteCacheModal').should('exist');
333+
})
334+
329335
function verifyGet(keyType, key, value) {
330336
// Going back to cache entries page
331337
cy.get('[data-cy=cacheEntriesTab]').click();

src/app/Caches/DetailCache.tsx

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ import {
4444
ExclamationCircleIcon,
4545
InfoCircleIcon,
4646
PencilAltIcon,
47-
RedoIcon
47+
RedoIcon,
48+
TrashIcon
4849
} from '@patternfly/react-icons';
4950
import { QueryEntries } from '@app/Caches/Query/QueryEntries';
5051
import { Link } from 'react-router-dom';
@@ -60,6 +61,7 @@ import { TracingEnabled } from '@app/Common/TracingEnabled';
6061
import { InfinispanComponentStatus } from '@app/Common/InfinispanComponentStatus';
6162
import { PageHeader } from '@patternfly/react-component-groups';
6263
import { UpdateAliasCache } from '@app/Caches/UpdateAliasCache';
64+
import { DeleteCache } from '@app/Caches/DeleteCache';
6365

6466
const DetailCache = (props: { cacheName: string }) => {
6567
const cacheName = props.cacheName;
@@ -71,6 +73,7 @@ const DetailCache = (props: { cacheName: string }) => {
7173
const [activeTabKey1, setActiveTabKey1] = useState<number | string>('');
7274
const [activeTabKey2, setActiveTabKey2] = useState<number | string>(10);
7375
const [isOpen, setIsOpen] = useState(false);
76+
const [isOpenDelete, setIsOpenDelete] = useState(false);
7477
const [cacheAction, setCacheAction] = useState<string>('');
7578
const isAdmin = ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser);
7679
const isCacheReader = ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.READ, cacheName, connectedUser);
@@ -209,6 +212,10 @@ const DetailCache = (props: { cacheName: string }) => {
209212
return cache && cache?.features?.indexed;
210213
};
211214

215+
const displayDelete = () => {
216+
return isAdmin && cache;
217+
};
218+
212219
const displayEditConfigManage = () => {
213220
return isAdmin && cache;
214221
};
@@ -296,6 +303,25 @@ const DetailCache = (props: { cacheName: string }) => {
296303
);
297304
};
298305

306+
const buildDelete = () => {
307+
if (!displayDelete()) return;
308+
309+
return (
310+
<DropdownItem
311+
value={'deleteCache'}
312+
key="manageDeleteLink"
313+
data-cy="manageDeleteLink"
314+
icon={<TrashIcon />}
315+
onClick={(ev) => {
316+
setIsOpenDelete(true);
317+
setIsOpen(false);
318+
}}
319+
>
320+
{t('caches.actions.action-delete')}
321+
</DropdownItem>
322+
);
323+
};
324+
299325
const buildRefresh = () => {
300326
return (
301327
<React.Fragment>
@@ -460,6 +486,7 @@ const DetailCache = (props: { cacheName: string }) => {
460486
{buildIndexManage()}
461487
{buildBackupsManage()}
462488
{buildRefresh()}
489+
{buildDelete()}
463490
</DropdownList>
464491
</Dropdown>
465492
</ToolbarItem>
@@ -513,6 +540,20 @@ const DetailCache = (props: { cacheName: string }) => {
513540
)}
514541
{buildDetailContent()}
515542
</PageSection>
543+
<DeleteCache
544+
cacheName={cacheName}
545+
isModalOpen={isOpenDelete}
546+
closeModal={(deleteDone: boolean) => {
547+
if (deleteDone) {
548+
navigate({
549+
pathname: '/',
550+
search: location.search
551+
});
552+
} else {
553+
setIsOpenDelete(false);
554+
}
555+
}}
556+
/>
516557
<UpdateAliasCache
517558
cacheName={cacheName}
518559
isModalOpen={cacheAction == 'aliases'}

src/app/Common/SelectMultiWithChips.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ const SelectMultiWithChips = (props: {
213213
props.onClear();
214214
textInputRef?.current?.focus();
215215
}}
216-
aria-label="Clear input value" id="clearInput"
216+
aria-label="Clear input value"
217+
id="clearInput"
217218
>
218219
<TimesIcon aria-hidden />
219220
</Button>

src/app/assets/languages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@
589589
"action-manage-tracing": "Manage tracing",
590590
"action-manage-backups": "Manage backups",
591591
"action-manage-config": "Edit configuration",
592+
"action-delete": "Delete",
592593
"refresh": "Refresh",
593594
"back": "Back"
594595
},

src/app/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ const App = () => {
2525
ConsoleServices.init();
2626
}
2727
// Base is coming from index.html, and can dynamically change in prod with a reverse proxy
28-
const base =
29-
document.querySelector('base')?.getAttribute('href')?.replace(/\/$/, '') || '/';
30-
28+
const base = document.querySelector('base')?.getAttribute('href')?.replace(/\/$/, '') || '/';
3129

3230
return (
3331
<Router basename={base == '{{INFINISPAN_BASE_PATH}}' ? '/console' : base}>

src/services/ConsoleServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export class ConsoleServices {
5050
return process.env.INFINISPAN_SERVER_URL + '/rest/v2';
5151
}
5252
} else {
53-
const x = (window as any);
54-
return window.location.origin.toString() + (x.INFINISPAN_CONFIG?.restContextPath || '/rest') + '/v2';
53+
const x = window as any;
54+
return window.location.origin.toString() + (x.INFINISPAN_CONFIG?.restContextPath || '/rest') + '/v2';
5555
}
5656
}
5757

0 commit comments

Comments
 (0)