Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 28919 Rules tab should not be visible to user with restricted access to Rules #30926

Merged
merged 7 commits into from
Dec 17, 2024
13 changes: 13 additions & 0 deletions core-web/libs/portlets/edit-ema/portlet/src/lib/shared/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const MOCK_RESPONSE_HEADLESS: DotPageApiResponse = {
inode: '123-i',
canEdit: true,
canRead: true,
canSeeRules: true,
contentType: 'htmlpageasset',
canLock: true,
locked: false,
Expand Down Expand Up @@ -212,6 +213,7 @@ export const MOCK_RESPONSE_VTL: DotPageApiResponse = {
inode: '123-i',
canEdit: true,
canRead: true,
canSeeRules: true,
rendered: '<html><body><h1>Hello, World!</h1></body></html>',
contentType: 'htmlpageasset',
canLock: true,
Expand Down Expand Up @@ -427,6 +429,7 @@ export const PAGE_RESPONSE_BY_LANGUAGE_ID = {
inode: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'index',
liveInode: '1234',
stInode: '12345',
Expand Down Expand Up @@ -455,6 +458,7 @@ export const PAGE_RESPONSE_BY_LANGUAGE_ID = {
inode: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'index',
liveInode: '1234',
stInode: '12345',
Expand Down Expand Up @@ -483,6 +487,7 @@ export const PAGE_RESPONSE_BY_LANGUAGE_ID = {
inode: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'index',
liveInode: '1234',
stInode: '12345',
Expand Down Expand Up @@ -757,6 +762,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
identifier: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canLock: false,
isLocked: true,
Expand Down Expand Up @@ -785,6 +791,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
identifier: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canLock: true,
locked: true,
Expand All @@ -811,6 +818,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canEdit: false
},
Expand All @@ -836,6 +844,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: 'i-have-a-running-experiment',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
rendered: '<div>New Content - Hello World</div>',
canEdit: true
Expand All @@ -862,6 +871,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
rendered: '<div>New Content - Hello World</div>',
canEdit: true
Expand All @@ -888,6 +898,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
rendered: '<div>hello world</div>',
canEdit: true
Expand All @@ -914,6 +925,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canEdit: true
},
Expand All @@ -939,6 +951,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
identifier: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'page-one'
},
site: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export interface DotPage {
inode: string;
canEdit: boolean;
canRead: boolean;
canSeeRules: boolean;
canLock?: boolean;
locked?: boolean;
lockedBy?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export const UVEStore = signalStore(
label: 'editema.editor.navbar.rules',
id: 'rules',
href: `rules/${page?.identifier}`,
isDisabled: !page?.canEdit || !isEnterpriseLicense
isDisabled:
!page?.canSeeRules || !page?.canEdit || !isEnterpriseLicense
},
{
iconURL: 'experiments',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ protected Map<String, Object> transform(final HTMLPageAsset page, final Map<Stri
map.put("canEdit", toolBox.permissionAPI.doesUserHavePermission(page, PermissionLevel.EDIT.getType(), user, false));
map.put("canRead", toolBox.permissionAPI.doesUserHavePermission(page, PermissionLevel.READ.getType(), user, false));
map.put("canLock", canLock(page, user));
map.put("canSeeRules", toolBox.permissionAPI.doesUserHavePermissions(page, "RULES: " + PermissionLevel.READ.getType(), user, false));


if(info.isPresent() && info.get().getLockedBy()!=null) {
map.put("lockedOn", info.get().getLockedOn());
Expand Down
Loading