Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cypress/e2e/2_cache-detail.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ describe('Cache Detail Overview', () => {
cy.contains('Rebalancing is on');
});

it('successfully displays delete cache modal', () => {
cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageDeleteLink]").click();
cy.get('#deleteCacheModal').should('exist');
})

function verifyGet(keyType, key, value) {
// Going back to cache entries page
cy.get('[data-cy=cacheEntriesTab]').click();
Expand Down
37 changes: 27 additions & 10 deletions cypress/e2e/3_cache-crud-wizard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('Cache Creation Wizard', () => {
deleteCache('aSimpleCache');
});

it('successfully creates without a template a XML config', () => {
it.only('successfully creates without a template a XML config', () => {
//go to create cache page
cy.get('[data-cy=createCacheButton]').click();
cy.get('#cache-name').click();
Expand Down Expand Up @@ -242,26 +242,43 @@ describe('Cache Creation Wizard', () => {
cy.get('[data-cy="statusInfo-clusterManager"]').should('exist');
cy.get('[data-cy=rebalancingSwitch]').should('exist');
cy.contains('aSimpleXmlCache');
deleteCache('aSimpleXmlCache');
deleteCache('aSimpleXmlCache', true);
});

function deleteCache(cacheName) {
cy.login(Cypress.env('username'), Cypress.env('password'));
cy.get(`[data-cy=actions-${cacheName}]`).click();
cy.get('[aria-label=deleteCacheAction]').click();
function deleteCache(cacheName, isDetailPage) {
if (isDetailPage) {
cy.login(Cypress.env('username'), Cypress.env('password'), `/cache/${cacheName}`);
cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageDeleteLink]").click();
} else {
cy.login(Cypress.env('username'), Cypress.env('password'));
cy.get(`[data-cy=actions-${cacheName}]`).click();
cy.get('[aria-label=deleteCacheAction]').click();
}

cy.get('#deleteCacheModal').should('exist');
cy.contains('Permanently delete cache?');
cy.get('#deleteCacheModal [aria-label=Close]').click(); //Closing modal with close button
cy.contains('Permanently delete cache?').should('not.exist');

cy.get(`[data-cy=actions-${cacheName}]`).click();
cy.get('[aria-label=deleteCacheAction]').click();
if (isDetailPage) {
cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageDeleteLink]").click();
} else {
cy.get(`[data-cy=actions-${cacheName}]`).click();
cy.get('[aria-label=deleteCacheAction]').click();
}
cy.contains('Permanently delete cache?');
cy.get('[data-cy=cancelCacheDeleteButton]').click(); //Closing modal with Cancel button
cy.contains('Permanently delete cache?').should('not.exist');

cy.get(`[data-cy=actions-${cacheName}]`).click();
cy.get('[aria-label=deleteCacheAction]').click();
if (isDetailPage) {
cy.get('[data-cy=detailCacheActions]').click();
cy.get("[data-cy=manageDeleteLink]").click();
} else {
cy.get(`[data-cy=actions-${cacheName}]`).click();
cy.get('[aria-label=deleteCacheAction]').click();
}
cy.get('#cache-to-delete').click();
cy.get('#cache-to-delete').type(cacheName);
cy.get('[data-cy=deleteCacheButton]').click(); //Deleting cache aCache
Expand Down
43 changes: 42 additions & 1 deletion src/app/Caches/DetailCache.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import {
ExclamationCircleIcon,
InfoCircleIcon,
PencilAltIcon,
RedoIcon
RedoIcon,
TrashIcon
} from '@patternfly/react-icons';
import { QueryEntries } from '@app/Caches/Query/QueryEntries';
import { Link } from 'react-router-dom';
Expand All @@ -60,6 +61,7 @@ import { TracingEnabled } from '@app/Common/TracingEnabled';
import { InfinispanComponentStatus } from '@app/Common/InfinispanComponentStatus';
import { PageHeader } from '@patternfly/react-component-groups';
import { UpdateAliasCache } from '@app/Caches/UpdateAliasCache';
import { DeleteCache } from '@app/Caches/DeleteCache';

const DetailCache = (props: { cacheName: string }) => {
const cacheName = props.cacheName;
Expand All @@ -71,6 +73,7 @@ const DetailCache = (props: { cacheName: string }) => {
const [activeTabKey1, setActiveTabKey1] = useState<number | string>('');
const [activeTabKey2, setActiveTabKey2] = useState<number | string>(10);
const [isOpen, setIsOpen] = useState(false);
const [isOpenDelete, setIsOpenDelete] = useState(false);
const [cacheAction, setCacheAction] = useState<string>('');
const isAdmin = ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser);
const isCacheReader = ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.READ, cacheName, connectedUser);
Expand Down Expand Up @@ -209,6 +212,10 @@ const DetailCache = (props: { cacheName: string }) => {
return cache && cache?.features?.indexed;
};

const displayDelete = () => {
return isAdmin && cache;
};

const displayEditConfigManage = () => {
return isAdmin && cache;
};
Expand Down Expand Up @@ -296,6 +303,25 @@ const DetailCache = (props: { cacheName: string }) => {
);
};

const buildDelete = () => {
if (!displayDelete()) return;

return (
<DropdownItem
value={'deleteCache'}
key="manageDeleteLink"
data-cy="manageDeleteLink"
icon={<TrashIcon />}
onClick={(ev) => {
setIsOpenDelete(true);
setIsOpen(false);
}}
>
{t('caches.actions.action-delete')}
</DropdownItem>
);
};

const buildRefresh = () => {
return (
<React.Fragment>
Expand Down Expand Up @@ -460,6 +486,7 @@ const DetailCache = (props: { cacheName: string }) => {
{buildIndexManage()}
{buildBackupsManage()}
{buildRefresh()}
{buildDelete()}
</DropdownList>
</Dropdown>
</ToolbarItem>
Expand Down Expand Up @@ -513,6 +540,20 @@ const DetailCache = (props: { cacheName: string }) => {
)}
{buildDetailContent()}
</PageSection>
<DeleteCache
cacheName={cacheName}
isModalOpen={isOpenDelete}
closeModal={(deleteDone: boolean) => {
if (deleteDone) {
navigate({
pathname: '/',
search: location.search
});
} else {
setIsOpenDelete(false);
}
}}
/>
<UpdateAliasCache
cacheName={cacheName}
isModalOpen={cacheAction == 'aliases'}
Expand Down
3 changes: 2 additions & 1 deletion src/app/Common/SelectMultiWithChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ const SelectMultiWithChips = (props: {
props.onClear();
textInputRef?.current?.focus();
}}
aria-label="Clear input value" id="clearInput"
aria-label="Clear input value"
id="clearInput"
>
<TimesIcon aria-hidden />
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/app/assets/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@
"action-manage-tracing": "Manage tracing",
"action-manage-backups": "Manage backups",
"action-manage-config": "Edit configuration",
"action-delete": "Delete",
"refresh": "Refresh",
"back": "Back"
},
Expand Down
4 changes: 1 addition & 3 deletions src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const App = () => {
ConsoleServices.init();
}
// Base is coming from index.html, and can dynamically change in prod with a reverse proxy
const base =
document.querySelector('base')?.getAttribute('href')?.replace(/\/$/, '') || '/';

const base = document.querySelector('base')?.getAttribute('href')?.replace(/\/$/, '') || '/';

return (
<Router basename={base == '{{INFINISPAN_BASE_PATH}}' ? '/console' : base}>
Expand Down
4 changes: 2 additions & 2 deletions src/services/ConsoleServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class ConsoleServices {
return process.env.INFINISPAN_SERVER_URL + '/rest/v2';
}
} else {
const x = (window as any);
return window.location.origin.toString() + (x.INFINISPAN_CONFIG?.restContextPath || '/rest') + '/v2';
const x = window as any;
return window.location.origin.toString() + (x.INFINISPAN_CONFIG?.restContextPath || '/rest') + '/v2';
}
}

Expand Down