Skip to content

Commit

Permalink
ISPN-14450 Remove actions for users without WRITE permission
Browse files Browse the repository at this point in the history
  • Loading branch information
karesti committed Jun 27, 2024
1 parent 3fc7a51 commit f48e75a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/1_rbac_func.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ describe('RBAC Functionality Tests', () => {
checkDataContainerView(false, false, false, false);
checkSecuredCacheDetailsView(false, false, false, 'observer', 'indexed-cache');
cy.contains('Elaia');
cy.get('[data-cy=actions-elaia]').should('exist');
cy.get('[data-cy=actions-elaia]').should('not.exist');
//Running query on secured page
cy.get('[data-cy=queriesTab]').click();
cy.get('#textSearchByQuery').click().type('from org.infinispan.Person where age>2');
cy.get('button[aria-label=searchButton]').click();
cy.contains('1 - 1 of 1');
cy.contains('Elaia');

``
checkNotOwnSecuredCache('a-rbac-test-cache');
checkNonSecuredCacheDetailView(false, false);
//Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix)
Expand Down
40 changes: 26 additions & 14 deletions src/app/Caches/Entries/CacheEntries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,32 @@ const CacheEntries = (props: { cacheName: string }) => {
});
};

const displayActions = (row): IAction[] => [
{
'aria-label': 'editEntryAction',
title: t('caches.entries.action-edit'),
onClick: () => onClickEditEntryButton(row.key, row.keyContentType as ContentType)
},
{
'aria-label': 'deleteEntryAction',
title: t('caches.entries.action-delete'),
onClick: () => onClickDeleteEntryButton(row.key, row.keyContentType as ContentType)
const displayActions = (row) => {
if (!ConsoleServices.security().hasCacheConsoleACL(ConsoleACL.WRITE, cache.name, connectedUser)) {
return (
<Td></Td>
);
}
];

const actions = [
{
'aria-label': 'editEntryAction',
title: t('caches.entries.action-edit'),
onClick: () => onClickEditEntryButton(row.key, row.keyContentType as ContentType)
},
{
'aria-label': 'deleteEntryAction',
title: t('caches.entries.action-delete'),
onClick: () => onClickDeleteEntryButton(row.key, row.keyContentType as ContentType)
}
]

return (
<Td isActionCell data-cy={`actions-${row.key}`}>
<ActionsColumn items={actions} />
</Td>
);
}

const columnNames = {
key: t('caches.entries.column-key'),
Expand Down Expand Up @@ -439,9 +453,7 @@ const CacheEntries = (props: { cacheName: string }) => {
<Td dataLabel={columnNames.lifespan}>{displayTimeToLive(row)}</Td>
<Td dataLabel={columnNames.maxIdle}>{displayMaxIdle(row)}</Td>
<Td dataLabel={columnNames.expires}>{displayExpires(row)}</Td>
<Td isActionCell data-cy={`actions-${row.key}`}>
<ActionsColumn items={displayActions(row)} />
</Td>
{displayActions(row)}
</Tr>
);
})
Expand Down

0 comments on commit f48e75a

Please sign in to comment.