@crombolo/backoffice-host 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/backoffice-host",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Serves the Umbraco backoffice SPA: shell HTML, import map and package manifests.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@crombolo/core": "0.21.0",
34
+ "@crombolo/core": "0.23.0",
35
35
  "@crombolo/backoffice-dist": "18.2.0"
36
36
  }
37
37
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
+ "name": "Crombolo App Preview",
4
+ "id": "Crombolo.AppPreview",
5
+ "version": "0.23.0",
6
+ "allowPublicAccess": false,
7
+ "extensions": [
8
+ {
9
+ "type": "workspaceActionMenuItem",
10
+ "kind": "previewOption",
11
+ "alias": "Crombolo.Document.WorkspaceActionMenuItem.PreviewInApp",
12
+ "name": "Crombolo Preview In App",
13
+ "forWorkspaceActions": "Umb.WorkspaceAction.Document.SaveAndPreview",
14
+ "weight": 200,
15
+ "meta": {
16
+ "label": "Preview in app",
17
+ "urlProviderAlias": "cromboloAppPreview"
18
+ }
19
+ }
20
+ ]
21
+ }
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Assistant",
4
4
  "id": "Crombolo.Assistant",
5
- "version": "0.21.0",
5
+ "version": "0.23.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Localizations",
4
4
  "id": "Crombolo.Localizations",
5
- "version": "0.21.0",
5
+ "version": "0.23.0",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Hides the media library's changes from a user without `Crombolo.Media.Update`
3
3
  * (story 088). Umbraco has no media verbs, so its actions carry no permission
4
- * condition; this appends one to each. The server refuses them regardless.
4
+ * condition; this appends one to each, and puts the media workspace in its own
5
+ * read-only state, the one it uses for a trashed item, so the name and the
6
+ * properties cannot be typed into either. The server refuses them regardless.
5
7
  */
6
8
 
7
9
  export const MEDIA_UPDATE = 'Crombolo.Media.Update'
@@ -22,10 +24,23 @@ export const MEDIA_CHANGES = [
22
24
  'Umb.WorkspaceAction.Media.Save',
23
25
  ]
24
26
 
27
+ /** Whether a user's fallback verbs let them change media. */
28
+ export const mayChangeMedia = (verbs) => Array.isArray(verbs) && verbs.includes(MEDIA_UPDATE)
29
+
30
+ export const MEDIA_READ_ONLY = {
31
+ type: 'workspaceContext',
32
+ alias: 'Crombolo.WorkspaceContext.MediaReadOnly',
33
+ name: 'Crombolo Media Read Only',
34
+ // Loaded only in the backoffice, where its imports resolve.
35
+ api: () => import('./media-read-only.js'),
36
+ conditions: [{ alias: 'Umb.Condition.WorkspaceAlias', match: 'Umb.Workspace.Media' }],
37
+ }
38
+
25
39
  export const onInit = (_host, extensionRegistry) => {
26
40
  for (const alias of MEDIA_CHANGES)
27
41
  extensionRegistry.appendCondition(alias, {
28
42
  alias: 'Umb.Condition.UserPermission.Fallback',
29
43
  allOf: [MEDIA_UPDATE],
30
44
  })
45
+ extensionRegistry.register(MEDIA_READ_ONLY)
31
46
  }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The media workspace, read only for a user who may not change media (story
3
+ * 088): the state the workspace uses for a trashed item, so the name and the
4
+ * properties cannot be typed into. Registered by `media-permissions.js`.
5
+ */
6
+
7
+ import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'
8
+ import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user'
9
+ import { UMB_MEDIA_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/media'
10
+ import { mayChangeMedia } from './media-permissions.js'
11
+
12
+ const READ_ONLY_RULE = 'CROMBOLO_MEDIA_READ_ONLY'
13
+
14
+ /** The media workspace, read only for a user who may not change media. */
15
+ export class CromboloMediaReadOnly extends UmbControllerBase {
16
+ #workspace
17
+ #allowed = true
18
+
19
+ constructor(host) {
20
+ super(host)
21
+ this.consumeContext(UMB_MEDIA_WORKSPACE_CONTEXT, (workspace) => {
22
+ this.#workspace = workspace
23
+ this.#apply()
24
+ })
25
+ this.consumeContext(UMB_CURRENT_USER_CONTEXT, (user) => {
26
+ if (!user) return
27
+ this.observe(user.fallbackPermissions, (verbs) => {
28
+ // Not known yet is not a refusal: the workspace stays as it is until it is.
29
+ if (verbs === undefined) return
30
+ this.#allowed = mayChangeMedia(verbs)
31
+ this.#apply()
32
+ })
33
+ })
34
+ }
35
+
36
+ #apply() {
37
+ const guard = this.#workspace?.readOnlyGuard
38
+ if (!guard) return
39
+ if (this.#allowed) guard.removeRule(READ_ONLY_RULE)
40
+ else guard.addRule({ unique: READ_ONLY_RULE, permitted: true })
41
+ }
42
+ }
43
+
44
+ export { CromboloMediaReadOnly as api }
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Search & sharing",
4
4
  "id": "Crombolo.Seo",
5
- "version": "0.21.0",
5
+ "version": "0.23.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Sign-in Dialog",
4
4
  "id": "Crombolo.SignInDialog",
5
- "version": "0.21.0",
5
+ "version": "0.23.0",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo",
4
4
  "id": "Crombolo.Core",
5
- "version": "0.21.0",
5
+ "version": "0.23.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
package/src/manifests.ts CHANGED
@@ -20,6 +20,12 @@ export const MANIFEST_FILE_NAME = 'umbraco-package.json'
20
20
  */
21
21
  export const ASSISTANT_MANIFEST_ID = 'Crombolo.Assistant'
22
22
 
23
+ /**
24
+ * Preview in app (story 053), which the server omits unless the site has an app
25
+ * preview address, so the Preview button is Umbraco's own until then.
26
+ */
27
+ export const APP_PREVIEW_MANIFEST_ID = 'Crombolo.AppPreview'
28
+
23
29
  export interface PackageManifestImportmap {
24
30
  imports: Record<string, string>
25
31
  scopes?: Record<string, Record<string, string>>