Skip to content

Commit be4648e

Browse files
authored
Merge pull request #2288 from umbraco/v14/bugfix/rollback-permissions
Bugfix: Enforce Rollback permissions
2 parents a95086b + f059b8b commit be4648e

23 files changed

+120
-37
lines changed

src/packages/core/icon-registry/icon-dictionary.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,10 @@
10961096
"name": "icon-help",
10971097
"file": "life-buoy.svg"
10981098
},
1099+
{
1100+
"name": "icon-history",
1101+
"file": "history.svg"
1102+
},
10991103
{
11001104
"name": "icon-home",
11011105
"file": "house.svg"

src/packages/core/icon-registry/icons.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,10 @@ name: "icon-help",
879879

880880
path: () => import("./icons/icon-help.js"),
881881
},{
882+
name: "icon-history",
883+
884+
path: () => import("./icons/icon-history.js"),
885+
},{
882886
name: "icon-home",
883887

884888
path: () => import("./icons/icon-home.js"),
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default `<!-- @license lucide-static v0.424.0 - ISC -->
2+
<svg
3+
class="lucide lucide-history"
4+
xmlns="http://www.w3.org/2000/svg"
5+
viewBox="0 0 24 24"
6+
fill="none"
7+
stroke="currentColor"
8+
stroke-width="1.75"
9+
stroke-linecap="round"
10+
stroke-linejoin="round"
11+
>
12+
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
13+
<path d="M3 3v5h5" />
14+
<path d="M12 7v5l4 2" />
15+
</svg>
16+
`;

src/packages/documents/documents/manifests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { manifests as pickerManifests } from './picker/manifests.js';
88
import { manifests as propertyEditorManifests } from './property-editors/manifests.js';
99
import { manifests as recycleBinManifests } from './recycle-bin/manifests.js';
1010
import { manifests as repositoryManifests } from './repository/manifests.js';
11+
import { manifests as rollbackManifests } from './rollback/manifests.js';
1112
import { manifests as searchProviderManifests } from './search/manifests.js';
1213
import { manifests as trackedReferenceManifests } from './reference/manifests.js';
1314
import { manifests as treeManifests } from './tree/manifests.js';
@@ -27,6 +28,7 @@ export const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [
2728
...propertyEditorManifests,
2829
...recycleBinManifests,
2930
...repositoryManifests,
31+
...rollbackManifests,
3032
...searchProviderManifests,
3133
...trackedReferenceManifests,
3234
...treeManifests,

src/packages/documents/documents/modals/manifests.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import type { ManifestModal, ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
22

3-
export const UMB_ROLLBACK_MODAL_ALIAS = 'Umb.Modal.Rollback';
43
export const UMB_DOCUMENT_SAVE_MODAL_ALIAS = 'Umb.Modal.DocumentSave';
54
export const UMB_DOCUMENT_PUBLISH_MODAL_ALIAS = 'Umb.Modal.DocumentPublish';
65
export const UMB_DOCUMENT_UNPUBLISH_MODAL_ALIAS = 'Umb.Modal.DocumentUnpublish';
76
export const UMB_DOCUMENT_SCHEDULE_MODAL_ALIAS = 'Umb.Modal.DocumentSchedule';
87
export const UMB_DOCUMENT_PUBLISH_WITH_DESCENDANTS_MODAL_ALIAS = 'Umb.Modal.DocumentPublishWithDescendants';
98

109
const modals: Array<ManifestModal> = [
11-
{
12-
type: 'modal',
13-
alias: UMB_ROLLBACK_MODAL_ALIAS,
14-
name: 'Rollback Modal',
15-
js: () => import('./rollback/rollback-modal.element.js'),
16-
},
1710
{
1811
type: 'modal',
1912
alias: UMB_DOCUMENT_SAVE_MODAL_ALIAS,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { UMB_DOCUMENT_ENTITY_TYPE } from '../../entity.js';
2+
import { UMB_USER_PERMISSION_DOCUMENT_ROLLBACK } from '../../user-permissions/index.js';
3+
import { UMB_DOCUMENT_WORKSPACE_ALIAS } from '../../workspace/index.js';
4+
import { UMB_ENTITY_IS_NOT_TRASHED_CONDITION_ALIAS } from '@umbraco-cms/backoffice/recycle-bin';
5+
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
6+
7+
export const manifests: Array<ManifestTypes> = [
8+
{
9+
type: 'entityAction',
10+
kind: 'default',
11+
alias: 'Umb.EntityAction.Document.Rollback',
12+
name: 'Rollback Document Entity Action',
13+
weight: 500,
14+
api: () => import('./rollback.action.js'),
15+
forEntityTypes: [UMB_DOCUMENT_ENTITY_TYPE],
16+
meta: {
17+
icon: 'icon-history',
18+
label: '#actions_rollback',
19+
},
20+
conditions: [
21+
{
22+
alias: 'Umb.Condition.UserPermission.Document',
23+
allOf: [UMB_USER_PERMISSION_DOCUMENT_ROLLBACK],
24+
},
25+
{
26+
alias: UMB_ENTITY_IS_NOT_TRASHED_CONDITION_ALIAS,
27+
},
28+
/* Currently the rollback is tightly coupled to the workspace contexts so we only allow it to show up
29+
In the document workspace. */
30+
{
31+
alias: 'Umb.Condition.WorkspaceAlias',
32+
match: UMB_DOCUMENT_WORKSPACE_ALIAS,
33+
},
34+
],
35+
},
36+
];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { UMB_ROLLBACK_MODAL } from '../modal/rollback-modal.token.js';
2+
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
3+
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
4+
import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification';
5+
import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';
6+
7+
export class UmbRollbackDocumentEntityAction extends UmbEntityActionBase<never> {
8+
#localize = new UmbLocalizationController(this);
9+
10+
override async execute() {
11+
const modalManagerContext = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
12+
const modalContext = modalManagerContext.open(this, UMB_ROLLBACK_MODAL, {});
13+
14+
await modalContext.onSubmit();
15+
const notificationContext = await this.getContext(UMB_NOTIFICATION_CONTEXT);
16+
notificationContext.peek('positive', {
17+
data: { message: this.#localize.term('rollback_documentRolledBack') },
18+
});
19+
}
20+
}
21+
22+
export { UmbRollbackDocumentEntityAction as api };
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './modal/index.js';
2+
export * from './repository/index.js';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { manifests as entityActionManifests } from './entity-action/manifests.js';
2+
import { manifests as modalManifests } from './modal/manifests.js';
3+
import { manifests as repositoryManifests } from './repository/manifests.js';
4+
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
5+
6+
export const manifests: Array<ManifestTypes> = [...entityActionManifests, ...modalManifests, ...repositoryManifests];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const UMB_ROLLBACK_MODAL_ALIAS = 'Umb.Modal.Rollback';

0 commit comments

Comments
 (0)