-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2261 from umbraco/v15/feature/help-header-app
Feature: Help Header App + Menu
- Loading branch information
Showing
30 changed files
with
312 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/packages/core/menu/components/menu-item/link/link-menu-item.element.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { customElement, html, property } from '@umbraco-cms/backoffice/external/lit'; | ||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; | ||
import type { ManifestMenuItemLinkKind, UmbMenuItemElement } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
const elementName = 'umb-link-menu-item'; | ||
@customElement(elementName) | ||
export class UmbLinkMenuItemElement extends UmbLitElement implements UmbMenuItemElement { | ||
@property({ type: Object, attribute: false }) | ||
manifest?: ManifestMenuItemLinkKind; | ||
|
||
#getTarget() { | ||
const href = this.manifest?.meta.href; | ||
|
||
if (href && href.startsWith('http')) { | ||
return '_blank'; | ||
} | ||
|
||
return '_self'; | ||
} | ||
|
||
override render() { | ||
return html` | ||
<umb-menu-item-layout | ||
.href=${this.manifest?.meta.href} | ||
target=${this.#getTarget()} | ||
.iconName=${this.manifest?.meta.icon ?? ''} | ||
.label=${this.localize.string(this.manifest?.meta.label ?? this.manifest?.name ?? '')}> | ||
</umb-menu-item-layout> | ||
`; | ||
} | ||
} | ||
|
||
export { UmbLinkMenuItemElement as element }; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
[elementName]: UmbLinkMenuItemElement; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/packages/core/menu/components/menu-item/link/manifests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { ManifestTypes, UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [ | ||
{ | ||
type: 'kind', | ||
alias: 'Umb.Kind.MenuItem.Link', | ||
matchKind: 'link', | ||
matchType: 'menuItem', | ||
manifest: { | ||
type: 'menuItem', | ||
element: () => import('./link-menu-item.element.js'), | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { manifests as linkManifests } from './link/manifests.js'; | ||
import type { ManifestTypes, UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [...linkManifests]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { manifests as menuItemManifests } from './components/menu-item/manifests.js'; | ||
import type { ManifestTypes, UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [...menuItemManifests]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { UMB_HELP_MENU_ALIAS } from '../menu/index.js'; | ||
import type { CSSResultGroup } from '@umbraco-cms/backoffice/external/lit'; | ||
import { css, html, customElement, state, nothing } from '@umbraco-cms/backoffice/external/lit'; | ||
import { UmbHeaderAppButtonElement } from '@umbraco-cms/backoffice/components'; | ||
import { umbExtensionsRegistry, type ManifestMenu } from '@umbraco-cms/backoffice/extension-registry'; | ||
import { UmbExtensionsManifestInitializer } from '@umbraco-cms/backoffice/extension-api'; | ||
|
||
const elementName = 'umb-help-header-app'; | ||
@customElement(elementName) | ||
export class UmbHelpHeaderAppElement extends UmbHeaderAppButtonElement { | ||
@state() | ||
private _popoverOpen = false; | ||
|
||
@state() | ||
private _helpMenuHasMenuItems = false; | ||
|
||
constructor() { | ||
super(); | ||
|
||
new UmbExtensionsManifestInitializer( | ||
this, | ||
umbExtensionsRegistry, | ||
'menuItem', | ||
(manifest) => manifest.meta.menus.includes(UMB_HELP_MENU_ALIAS), | ||
(menuItems) => { | ||
const manifests = menuItems.map((menuItem) => menuItem.manifest); | ||
this._helpMenuHasMenuItems = manifests.length > 0; | ||
}, | ||
); | ||
} | ||
|
||
#onPopoverToggle(event: ToggleEvent) { | ||
// TODO: This ignorer is just neede for JSON SCHEMA TO WORK, As its not updated with latest TS jet. | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this._popoverOpen = event.newState === 'open'; | ||
} | ||
|
||
override render() { | ||
return html` ${this.#renderButton()} ${this.#renderPopover()} `; | ||
} | ||
|
||
#renderButton() { | ||
if (!this._helpMenuHasMenuItems) return nothing; | ||
|
||
return html` | ||
<uui-button popovertarget="help-menu-popover" look="primary" label="help" compact> | ||
<uui-icon name="icon-help-alt"></uui-icon> | ||
</uui-button> | ||
`; | ||
} | ||
|
||
#renderPopover() { | ||
return html` | ||
<uui-popover-container id="help-menu-popover" @toggle=${this.#onPopoverToggle}> | ||
<umb-popover-layout> | ||
<uui-scroll-container> | ||
<umb-extension-slot | ||
type="menu" | ||
.filter="${(menu: ManifestMenu) => menu.alias === UMB_HELP_MENU_ALIAS}" | ||
default-element="umb-menu"></umb-extension-slot> | ||
</uui-scroll-container> | ||
</umb-popover-layout> | ||
</uui-popover-container> | ||
`; | ||
} | ||
|
||
static override styles: CSSResultGroup = [UmbHeaderAppButtonElement.styles, css``]; | ||
} | ||
|
||
export { UmbHelpHeaderAppElement as element }; | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
[elementName]: UmbHelpHeaderAppElement; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ManifestTypes, UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [ | ||
{ | ||
type: 'headerApp', | ||
alias: 'Umb.HeaderApp.Help', | ||
name: 'Help Header App', | ||
element: () => import('./help-header-app.element.js'), | ||
weight: 500, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './menu/index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { manifests as headerAppManifests } from './header-app/manifests.js'; | ||
import { manifests as menuManifests } from './menu/manifests.js'; | ||
import type { ManifestTypes, UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [...menuManifests, ...headerAppManifests]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const UMB_HELP_MENU_ALIAS = 'Umb.Menu.Help'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './constants.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { UMB_HELP_MENU_ALIAS } from './constants.js'; | ||
import { UMB_CURRENT_USER_IS_ADMIN_CONDITION_ALIAS } from '@umbraco-cms/backoffice/current-user'; | ||
import type { ManifestTypes, UmbBackofficeManifestKind } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export const manifests: Array<ManifestTypes | UmbBackofficeManifestKind> = [ | ||
{ | ||
type: 'menu', | ||
alias: UMB_HELP_MENU_ALIAS, | ||
name: 'Help Menu', | ||
}, | ||
{ | ||
type: 'menuItem', | ||
kind: 'link', | ||
alias: 'Umb.MenuItem.Help.LearningBase', | ||
name: 'Learning Base Help Menu Item', | ||
weight: 200, | ||
meta: { | ||
menus: [UMB_HELP_MENU_ALIAS], | ||
label: 'Umbraco Learning Base', | ||
icon: 'icon-movie-alt', | ||
href: 'https://umbra.co/ulb', | ||
}, | ||
conditions: [ | ||
{ | ||
alias: UMB_CURRENT_USER_IS_ADMIN_CONDITION_ALIAS, | ||
}, | ||
], | ||
}, | ||
{ | ||
type: 'menuItem', | ||
kind: 'link', | ||
alias: 'Umb.MenuItem.Help.CommunityWebsite', | ||
name: 'Community Website Help Menu Item', | ||
weight: 100, | ||
meta: { | ||
menus: [UMB_HELP_MENU_ALIAS], | ||
label: 'Community Website', | ||
icon: 'icon-hearts', | ||
href: 'https://our.umbraco.com?utm_source=core&utm_medium=help&utm_content=link&utm_campaign=our', | ||
}, | ||
conditions: [ | ||
{ | ||
alias: UMB_CURRENT_USER_IS_ADMIN_CONDITION_ALIAS, | ||
}, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@umbraco-backoffice/help", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "vite build" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const name = 'Umbraco.Core.Help'; | ||
export const extensions = [ | ||
{ | ||
name: 'Help Bundle', | ||
alias: 'Umb.Bundle.Help', | ||
type: 'bundle', | ||
js: () => import('./manifests.js'), | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from 'vite'; | ||
import { rmSync } from 'fs'; | ||
import { getDefaultConfig } from '../../vite-config-base'; | ||
|
||
const dist = '../../../dist-cms/packages/help'; | ||
|
||
// delete the unbundled dist folder | ||
rmSync(dist, { recursive: true, force: true }); | ||
|
||
export default defineConfig({ | ||
...getDefaultConfig({ dist }), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './is-admin/index.js'; |
1 change: 1 addition & 0 deletions
1
src/packages/user/current-user/conditions/is-admin/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const UMB_CURRENT_USER_IS_ADMIN_CONDITION_ALIAS = 'Umb.Condition.CurrentUser.IsAdmin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './constants.js'; |
9 changes: 9 additions & 0 deletions
9
src/packages/user/current-user/conditions/is-admin/is-admin.condition.manifest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { UMB_CURRENT_USER_IS_ADMIN_CONDITION_ALIAS } from './constants.js'; | ||
import type { ManifestCondition } from '@umbraco-cms/backoffice/extension-api'; | ||
|
||
export const manifest: ManifestCondition = { | ||
type: 'condition', | ||
name: 'Current user is admin Condition', | ||
alias: UMB_CURRENT_USER_IS_ADMIN_CONDITION_ALIAS, | ||
api: () => import('./is-admin.condition.js'), | ||
}; |
20 changes: 20 additions & 0 deletions
20
src/packages/user/current-user/conditions/is-admin/is-admin.condition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { isCurrentUserAnAdmin } from '../../utils/is-current-user.function.js'; | ||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; | ||
import type { | ||
UmbConditionConfigBase, | ||
UmbConditionControllerArguments, | ||
UmbExtensionCondition, | ||
} from '@umbraco-cms/backoffice/extension-api'; | ||
import { UmbConditionBase } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export class UmbContentHasPropertiesWorkspaceCondition | ||
extends UmbConditionBase<UmbConditionConfigBase> | ||
implements UmbExtensionCondition | ||
{ | ||
constructor(host: UmbControllerHost, args: UmbConditionControllerArguments<UmbConditionConfigBase>) { | ||
super(host, args); | ||
isCurrentUserAnAdmin(host).then((isAdmin) => (this.permitted = isAdmin)); | ||
} | ||
} | ||
|
||
export { UmbContentHasPropertiesWorkspaceCondition as api }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { manifest as isAdminManifests } from './is-admin/is-admin.condition.manifest.js'; | ||
|
||
export const manifests = [isAdminManifests]; |
Oops, something went wrong.