diff --git a/package.json b/package.json index 5a8122f56e..c236d460c6 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "./themes": "./dist-cms/packages/core/themes/index.js", "./tiny-mce": "./dist-cms/packages/rte/tiny-mce/index.js", "./tiptap": "./dist-cms/packages/rte/tiptap/index.js", + "./translation": "./dist-cms/packages/translation/index.js", "./tree": "./dist-cms/packages/core/tree/index.js", "./ufm": "./dist-cms/packages/ufm/index.js", "./user-change-password": "./dist-cms/packages/user/change-password/index.js", diff --git a/src/apps/backoffice/backoffice.element.ts b/src/apps/backoffice/backoffice.element.ts index 4129f330a7..5a7588ee2f 100644 --- a/src/apps/backoffice/backoffice.element.ts +++ b/src/apps/backoffice/backoffice.element.ts @@ -41,6 +41,7 @@ const CORE_PACKAGES = [ import('../../packages/tags/umbraco-package.js'), import('../../packages/telemetry/umbraco-package.js'), import('../../packages/templating/umbraco-package.js'), + import('../../packages/translation/umbraco-package.js'), import('../../packages/ufm/umbraco-package.js'), import('../../packages/umbraco-news/umbraco-package.js'), import('../../packages/user/umbraco-package.js'), diff --git a/src/assets/lang/en-us.ts b/src/assets/lang/en-us.ts index eb5bdaf5c7..cd803070bb 100644 --- a/src/assets/lang/en-us.ts +++ b/src/assets/lang/en-us.ts @@ -1309,7 +1309,7 @@ export default { packages: 'Packages', marketplace: 'Marketplace', settings: 'Settings', - translation: 'Dictionary', + translation: 'Translation', users: 'Users', }, help: { diff --git a/src/assets/lang/en.ts b/src/assets/lang/en.ts index 2a35ea59ae..8f9dd5999a 100644 --- a/src/assets/lang/en.ts +++ b/src/assets/lang/en.ts @@ -1329,7 +1329,7 @@ export default { packages: 'Packages', marketplace: 'Marketplace', settings: 'Settings', - translation: 'Dictionary', + translation: 'Translation', users: 'Users', }, help: { diff --git a/src/packages/core/dashboard/index.ts b/src/packages/core/dashboard/index.ts index 75d2827685..9b48ce1f79 100644 --- a/src/packages/core/dashboard/index.ts +++ b/src/packages/core/dashboard/index.ts @@ -1,2 +1,3 @@ export * from './dashboard.extension.js'; export * from './dashboard-element.interface.js'; +export * from './paths.js'; diff --git a/src/packages/core/dashboard/paths.ts b/src/packages/core/dashboard/paths.ts new file mode 100644 index 0000000000..fa9480efc0 --- /dev/null +++ b/src/packages/core/dashboard/paths.ts @@ -0,0 +1,7 @@ +import { UMB_SECTION_PATH_PATTERN } from '@umbraco-cms/backoffice/section'; +import { UmbPathPattern } from '@umbraco-cms/backoffice/router'; + +export const UMB_DASHBOARD_PATH_PATTERN = new UmbPathPattern< + { dashboardPathname: string }, + typeof UMB_SECTION_PATH_PATTERN.ABSOLUTE_PARAMS +>('dashboard/:dashboardPathname', UMB_SECTION_PATH_PATTERN); diff --git a/src/packages/dictionary/collection/views/table/dictionary-table-collection-view.element.ts b/src/packages/dictionary/collection/views/table/dictionary-table-collection-view.element.ts index 1d692afb5f..3f2e8901bf 100644 --- a/src/packages/dictionary/collection/views/table/dictionary-table-collection-view.element.ts +++ b/src/packages/dictionary/collection/views/table/dictionary-table-collection-view.element.ts @@ -1,4 +1,5 @@ import type { UmbDictionaryCollectionModel } from '../../types.js'; +import { UMB_EDIT_DICTIONARY_WORKSPACE_PATH_PATTERN } from '../../../workspace/paths.js'; import type { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection'; import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection'; import type { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components'; @@ -74,17 +75,17 @@ export class UmbDictionaryTableCollectionViewElement extends UmbLitElement { #createTableItems(dictionaries: Array, languages: Array) { this._tableItems = dictionaries.map((dictionary) => { + const editPath = UMB_EDIT_DICTIONARY_WORKSPACE_PATH_PATTERN.generateAbsolute({ + unique: dictionary.unique, + }); + return { id: dictionary.unique, icon: 'icon-book-alt-2', data: [ { columnAlias: 'name', - value: html` - ${dictionary.name} `, + value: html` ${dictionary.name} `, }, ...languages.map((language) => { return { diff --git a/src/packages/dictionary/dashboard/index.ts b/src/packages/dictionary/dashboard/index.ts new file mode 100644 index 0000000000..b3031d9a5d --- /dev/null +++ b/src/packages/dictionary/dashboard/index.ts @@ -0,0 +1 @@ +export * from './paths.js'; diff --git a/src/packages/dictionary/dashboard/manifests.ts b/src/packages/dictionary/dashboard/manifests.ts index 1f44cead79..3d3f01c245 100644 --- a/src/packages/dictionary/dashboard/manifests.ts +++ b/src/packages/dictionary/dashboard/manifests.ts @@ -1,4 +1,4 @@ -import { UMB_DICTIONARY_SECTION_ALIAS } from '../section/index.js'; +import { UMB_TRANSLATION_SECTION_ALIAS } from '@umbraco-cms/backoffice/translation'; export const manifests: Array = [ { @@ -8,12 +8,12 @@ export const manifests: Array = [ element: () => import('./dictionary-overview-dashboard.element.js'), meta: { label: '#dictionaryItem_overviewTitle', - pathname: '', + pathname: 'dictionary-overview', }, conditions: [ { alias: 'Umb.Condition.SectionAlias', - match: UMB_DICTIONARY_SECTION_ALIAS, + match: UMB_TRANSLATION_SECTION_ALIAS, }, ], }, diff --git a/src/packages/dictionary/dashboard/paths.ts b/src/packages/dictionary/dashboard/paths.ts new file mode 100644 index 0000000000..1ecab677c6 --- /dev/null +++ b/src/packages/dictionary/dashboard/paths.ts @@ -0,0 +1,9 @@ +import { UMB_DASHBOARD_PATH_PATTERN } from '@umbraco-cms/backoffice/dashboard'; +import { UMB_TRANSLATION_SECTION_PATHNAME } from '@umbraco-cms/backoffice/translation'; + +export const UMB_DICTIONARY_OVERVIEW_DASHBOARD_PATHNAME = 'dictionary-overview'; + +export const UMB_DICTIONARY_OVERVIEW_DASHBOARD_PATH = UMB_DASHBOARD_PATH_PATTERN.generateAbsolute({ + sectionName: UMB_TRANSLATION_SECTION_PATHNAME, + dashboardPathname: UMB_DICTIONARY_OVERVIEW_DASHBOARD_PATHNAME, +}); diff --git a/src/packages/dictionary/entity-action/create/create.action.ts b/src/packages/dictionary/entity-action/create/create.action.ts index 3b96e6a695..23e6bb385e 100644 --- a/src/packages/dictionary/entity-action/create/create.action.ts +++ b/src/packages/dictionary/entity-action/create/create.action.ts @@ -1,18 +1,14 @@ -import type { UmbEntityActionArgs } from '@umbraco-cms/backoffice/entity-action'; import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action'; -import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; +import { UMB_CREATE_DICTIONARY_WORKSPACE_PATH_PATTERN } from '../../workspace/index.js'; export class UmbCreateDictionaryEntityAction extends UmbEntityActionBase { - constructor(host: UmbControllerHost, args: UmbEntityActionArgs) { - super(host, args); - } - override async execute() { - history.pushState( - {}, - '', - `/section/dictionary/workspace/dictionary/create/parent/${this.args.entityType}/${this.args.unique ?? 'null'}`, - ); + const createPath = UMB_CREATE_DICTIONARY_WORKSPACE_PATH_PATTERN.generateAbsolute({ + parentEntityType: this.args.entityType, + parentUnique: this.args.unique ?? 'null', + }); + + history.pushState({}, '', createPath); } } diff --git a/src/packages/dictionary/index.ts b/src/packages/dictionary/index.ts index 5c7b94903c..c4694a0662 100644 --- a/src/packages/dictionary/index.ts +++ b/src/packages/dictionary/index.ts @@ -3,3 +3,4 @@ export * from './tree/index.js'; export * from './modals/dictionary-picker-modal.token.js'; export * from './entity.js'; export * from './components/index.js'; +export * from './workspace/paths.js'; diff --git a/src/packages/dictionary/manifests.ts b/src/packages/dictionary/manifests.ts index 29e09329db..699256e02a 100644 --- a/src/packages/dictionary/manifests.ts +++ b/src/packages/dictionary/manifests.ts @@ -1,9 +1,8 @@ import { manifests as collectionManifests } from './collection/manifests.js'; import { manifests as dashboardManifests } from './dashboard/manifests.js'; import { manifests as entityActionManifests } from './entity-action/manifests.js'; -import { manifests as menuManifests } from './menu/manifests.js'; +import { manifests as menuItemManifests } from './menu-item/manifests.js'; import { manifests as repositoryManifests } from './repository/manifests.js'; -import { manifests as sectionManifests } from './section/manifests.js'; import { manifests as treeManifests } from './tree/manifests.js'; import { manifests as workspaceManifests } from './workspace/manifests.js'; @@ -11,9 +10,8 @@ export const manifests: Array = [ ...collectionManifests, ...dashboardManifests, ...entityActionManifests, - ...menuManifests, + ...menuItemManifests, ...repositoryManifests, - ...sectionManifests, ...treeManifests, ...workspaceManifests, ]; diff --git a/src/packages/dictionary/menu/dictionary-menu-structure.context.ts b/src/packages/dictionary/menu-item/dictionary-menu-structure.context.ts similarity index 100% rename from src/packages/dictionary/menu/dictionary-menu-structure.context.ts rename to src/packages/dictionary/menu-item/dictionary-menu-structure.context.ts diff --git a/src/packages/dictionary/menu/manifests.ts b/src/packages/dictionary/menu-item/manifests.ts similarity index 85% rename from src/packages/dictionary/menu/manifests.ts rename to src/packages/dictionary/menu-item/manifests.ts index f1aa21d016..447eb8727b 100644 --- a/src/packages/dictionary/menu/manifests.ts +++ b/src/packages/dictionary/menu-item/manifests.ts @@ -1,13 +1,8 @@ import { UMB_DICTIONARY_ENTITY_TYPE } from '../entity.js'; import { UMB_DICTIONARY_TREE_ALIAS } from '../tree/index.js'; -import { UMB_DICTIONARY_MENU_ALIAS } from './constants.js'; +import { UMB_TRANSLATION_MENU_ALIAS } from '@umbraco-cms/backoffice/translation'; export const manifests: Array = [ - { - type: 'menu', - alias: UMB_DICTIONARY_MENU_ALIAS, - name: 'Dictionary Menu', - }, { type: 'menuItem', kind: 'tree', @@ -18,7 +13,7 @@ export const manifests: Array = [ label: 'Dictionary', icon: 'icon-book-alt', entityType: UMB_DICTIONARY_ENTITY_TYPE, - menus: [UMB_DICTIONARY_MENU_ALIAS], + menus: [UMB_TRANSLATION_MENU_ALIAS], treeAlias: UMB_DICTIONARY_TREE_ALIAS, hideTreeRoot: true, }, diff --git a/src/packages/dictionary/menu/constants.ts b/src/packages/dictionary/menu/constants.ts deleted file mode 100644 index b92f703ad3..0000000000 --- a/src/packages/dictionary/menu/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const UMB_DICTIONARY_MENU_ALIAS = 'Umb.Menu.Dictionary'; diff --git a/src/packages/dictionary/menu/index.ts b/src/packages/dictionary/menu/index.ts deleted file mode 100644 index 2751aebdd2..0000000000 --- a/src/packages/dictionary/menu/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { UMB_DICTIONARY_MENU_ALIAS } from './constants.js'; diff --git a/src/packages/dictionary/section/constants.ts b/src/packages/dictionary/section/constants.ts deleted file mode 100644 index 62ab444161..0000000000 --- a/src/packages/dictionary/section/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const UMB_DICTIONARY_SECTION_ALIAS = 'Umb.Section.Translation'; diff --git a/src/packages/dictionary/section/index.ts b/src/packages/dictionary/section/index.ts deleted file mode 100644 index 0390f90107..0000000000 --- a/src/packages/dictionary/section/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { UMB_DICTIONARY_SECTION_ALIAS } from './constants.js'; diff --git a/src/packages/dictionary/section/manifests.ts b/src/packages/dictionary/section/manifests.ts deleted file mode 100644 index 857f53d0cc..0000000000 --- a/src/packages/dictionary/section/manifests.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { UMB_DICTIONARY_ROOT_ENTITY_TYPE } from '../entity.js'; -import { UMB_DICTIONARY_MENU_ALIAS } from '../menu/index.js'; -import { UMB_DICTIONARY_SECTION_ALIAS } from './constants.js'; - -export const manifests: Array = [ - { - type: 'section', - alias: UMB_DICTIONARY_SECTION_ALIAS, - name: 'Dictionary Section', - weight: 400, - meta: { - label: '#sections_translation', - pathname: 'dictionary', - }, - conditions: [ - { - alias: 'Umb.Condition.SectionUserPermission', - match: UMB_DICTIONARY_SECTION_ALIAS, - }, - ], - }, - { - type: 'sectionSidebarApp', - kind: 'menuWithEntityActions', - alias: 'Umb.SidebarMenu.Dictionary', - name: 'Dictionary Sidebar Menu', - weight: 100, - meta: { - label: '#sections_translation', - menu: UMB_DICTIONARY_MENU_ALIAS, - entityType: UMB_DICTIONARY_ROOT_ENTITY_TYPE, - }, - conditions: [ - { - alias: 'Umb.Condition.SectionAlias', - match: UMB_DICTIONARY_SECTION_ALIAS, - }, - ], - }, -]; diff --git a/src/packages/dictionary/workspace/dictionary-workspace-editor.element.ts b/src/packages/dictionary/workspace/dictionary-workspace-editor.element.ts index 4a6fdadbc4..68314a2296 100644 --- a/src/packages/dictionary/workspace/dictionary-workspace-editor.element.ts +++ b/src/packages/dictionary/workspace/dictionary-workspace-editor.element.ts @@ -1,3 +1,4 @@ +import { UMB_DICTIONARY_OVERVIEW_DASHBOARD_PATH } from '../dashboard/index.js'; import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; @@ -5,7 +6,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; export class UmbDictionaryWorkspaceEditorElement extends UmbLitElement { override render() { return html` - + `; diff --git a/src/packages/dictionary/workspace/index.ts b/src/packages/dictionary/workspace/index.ts new file mode 100644 index 0000000000..b3031d9a5d --- /dev/null +++ b/src/packages/dictionary/workspace/index.ts @@ -0,0 +1 @@ +export * from './paths.js'; diff --git a/src/packages/dictionary/workspace/paths.ts b/src/packages/dictionary/workspace/paths.ts new file mode 100644 index 0000000000..227fc080ef --- /dev/null +++ b/src/packages/dictionary/workspace/paths.ts @@ -0,0 +1,19 @@ +import { UMB_DICTIONARY_ENTITY_TYPE } from '../entity.js'; +import { UmbPathPattern } from '@umbraco-cms/backoffice/router'; +import { UMB_TRANSLATION_SECTION_PATHNAME } from '@umbraco-cms/backoffice/translation'; +import { UMB_WORKSPACE_PATH_PATTERN } from '@umbraco-cms/backoffice/workspace'; +import type { UmbEntityModel, UmbEntityUnique } from '@umbraco-cms/backoffice/entity'; + +export const UMB_DICTIONARY_WORKSPACE_PATH = UMB_WORKSPACE_PATH_PATTERN.generateAbsolute({ + sectionName: UMB_TRANSLATION_SECTION_PATHNAME, + entityType: UMB_DICTIONARY_ENTITY_TYPE, +}); + +export const UMB_CREATE_DICTIONARY_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ + parentEntityType: UmbEntityModel['entityType']; + parentUnique: UmbEntityUnique; +}>('create/parent/:parentEntityType/:parentUnique', UMB_DICTIONARY_WORKSPACE_PATH); + +export const UMB_EDIT_DICTIONARY_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ + unique: UmbEntityUnique; +}>('edit/:unique', UMB_DICTIONARY_WORKSPACE_PATH); diff --git a/src/packages/translation/index.ts b/src/packages/translation/index.ts new file mode 100644 index 0000000000..0aa63cbd85 --- /dev/null +++ b/src/packages/translation/index.ts @@ -0,0 +1,2 @@ +export * from './section/index.js'; +export * from './menu/index.js'; diff --git a/src/packages/translation/manifests.ts b/src/packages/translation/manifests.ts new file mode 100644 index 0000000000..58afeb83a5 --- /dev/null +++ b/src/packages/translation/manifests.ts @@ -0,0 +1,4 @@ +import { manifests as sectionManifests } from './section/manifests.js'; +import { manifests as menuManifests } from './menu/manifests.js'; + +export const manifests: Array = [...sectionManifests, ...menuManifests]; diff --git a/src/packages/translation/menu/constants.ts b/src/packages/translation/menu/constants.ts new file mode 100644 index 0000000000..5e223d54cf --- /dev/null +++ b/src/packages/translation/menu/constants.ts @@ -0,0 +1 @@ +export const UMB_TRANSLATION_MENU_ALIAS = 'Umb.Menu.Translation'; diff --git a/src/packages/translation/menu/index.ts b/src/packages/translation/menu/index.ts new file mode 100644 index 0000000000..4f07201dcf --- /dev/null +++ b/src/packages/translation/menu/index.ts @@ -0,0 +1 @@ +export * from './constants.js'; diff --git a/src/packages/translation/menu/manifests.ts b/src/packages/translation/menu/manifests.ts new file mode 100644 index 0000000000..3759c9de91 --- /dev/null +++ b/src/packages/translation/menu/manifests.ts @@ -0,0 +1,28 @@ +import { UMB_TRANSLATION_SECTION_ALIAS } from '../section/index.js'; +import { UMB_TRANSLATION_MENU_ALIAS } from './constants.js'; + +export const manifests: Array = [ + { + type: 'menu', + alias: UMB_TRANSLATION_MENU_ALIAS, + name: 'Translation Menu', + }, + { + type: 'sectionSidebarApp', + kind: 'menuWithEntityActions', + alias: 'Umb.SidebarMenu.Translation', + name: 'Translation Sidebar Menu', + weight: 100, + meta: { + label: '#sections_translation', + menu: UMB_TRANSLATION_MENU_ALIAS, + entityType: 'dictionary-root', // hard-coded on purpose to avoid circular dependency. We need another way to add actions to a menu kind. + }, + conditions: [ + { + alias: 'Umb.Condition.SectionAlias', + match: UMB_TRANSLATION_SECTION_ALIAS, + }, + ], + }, +]; diff --git a/src/packages/translation/section/constants.ts b/src/packages/translation/section/constants.ts new file mode 100644 index 0000000000..da4a87bd38 --- /dev/null +++ b/src/packages/translation/section/constants.ts @@ -0,0 +1 @@ +export const UMB_TRANSLATION_SECTION_ALIAS = 'Umb.Section.Translation'; diff --git a/src/packages/translation/section/index.ts b/src/packages/translation/section/index.ts new file mode 100644 index 0000000000..14b140114e --- /dev/null +++ b/src/packages/translation/section/index.ts @@ -0,0 +1,2 @@ +export * from './constants.js'; +export * from './paths.js'; diff --git a/src/packages/translation/section/manifests.ts b/src/packages/translation/section/manifests.ts new file mode 100644 index 0000000000..ec0d675b77 --- /dev/null +++ b/src/packages/translation/section/manifests.ts @@ -0,0 +1,20 @@ +import { UMB_TRANSLATION_SECTION_ALIAS } from './constants.js'; + +export const manifests: Array = [ + { + type: 'section', + alias: UMB_TRANSLATION_SECTION_ALIAS, + name: 'Translation Section', + weight: 400, + meta: { + label: '#sections_translation', + pathname: 'translation', + }, + conditions: [ + { + alias: 'Umb.Condition.SectionUserPermission', + match: UMB_TRANSLATION_SECTION_ALIAS, + }, + ], + }, +]; diff --git a/src/packages/translation/section/paths.ts b/src/packages/translation/section/paths.ts new file mode 100644 index 0000000000..7007c30aec --- /dev/null +++ b/src/packages/translation/section/paths.ts @@ -0,0 +1,6 @@ +import { UMB_SECTION_PATH_PATTERN } from '@umbraco-cms/backoffice/section'; + +export const UMB_TRANSLATION_SECTION_PATHNAME = 'translation'; +export const UMB_TRANSLATION_SECTION_PATH = UMB_SECTION_PATH_PATTERN.generateAbsolute({ + sectionName: UMB_TRANSLATION_SECTION_PATHNAME, +}); diff --git a/src/packages/translation/umbraco-package.ts b/src/packages/translation/umbraco-package.ts new file mode 100644 index 0000000000..31d727ab8e --- /dev/null +++ b/src/packages/translation/umbraco-package.ts @@ -0,0 +1,9 @@ +export const name = 'Umbraco.Core.Translation'; +export const extensions = [ + { + name: 'Umbraco Translation Bundle', + alias: 'Umb.Bundle.Translation', + type: 'bundle', + js: () => import('./manifests.js'), + }, +]; diff --git a/src/packages/translation/vite.config.ts b/src/packages/translation/vite.config.ts new file mode 100644 index 0000000000..d34f1799f5 --- /dev/null +++ b/src/packages/translation/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite'; +import { rmSync } from 'fs'; +import { getDefaultConfig } from '../../vite-config-base'; + +const dist = '../../../dist-cms/packages/translation'; + +// delete the unbundled dist folder +rmSync(dist, { recursive: true, force: true }); + +export default defineConfig({ + ...getDefaultConfig({ dist }), +}); diff --git a/tsconfig.json b/tsconfig.json index 84328daca5..08f7cd7734 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -123,6 +123,7 @@ DON'T EDIT THIS FILE DIRECTLY. It is generated by /devops/tsconfig/index.js "@umbraco-cms/backoffice/themes": ["./src/packages/core/themes/index.ts"], "@umbraco-cms/backoffice/tiny-mce": ["./src/packages/rte/tiny-mce/index.ts"], "@umbraco-cms/backoffice/tiptap": ["./src/packages/rte/tiptap/index.ts"], + "@umbraco-cms/backoffice/translation": ["./src/packages/translation/index.ts"], "@umbraco-cms/backoffice/tree": ["./src/packages/core/tree/index.ts"], "@umbraco-cms/backoffice/ufm": ["./src/packages/ufm/index.ts"], "@umbraco-cms/backoffice/user-change-password": ["./src/packages/user/change-password/index.ts"],