-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Redirect Url Management: Implement workspace #22624
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
Merged
leekelleher
merged 13 commits into
main
from
v17/bugfix/22619-redirect-url-management-info-app
Apr 28, 2026
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3e70001
add redirect tracking workspace
Zeegaan 50ca37f
change weight to match v13 order
Zeegaan a2f2797
add missing alignment and text colour
Zeegaan 696567c
Align closer with referency by element
Zeegaan a33c2a2
Ad repository pattern from review
Zeegaan c9c8dcd
remove obsolete
Zeegaan 4b0afd0
Update src/Umbraco.Web.UI.Client/src/packages/documents/documents/red…
Zeegaan f1acf22
Adds JSDocs
leekelleher f028183
Removed unused `created` and `documentUnique` from `UmbDocumentRedire…
leekelleher 8a8d733
Align `setStatus` and `delete` return shape with other data source me…
leekelleher d06b1d5
Align workspace context observer with sibling info-app pattern
leekelleher cfd4c0d
Polish dashboard and info-app: localize hardcoded strings, tidy templ…
leekelleher 9f3c027
Apply review simplifications
leekelleher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
242 changes: 242 additions & 0 deletions
242
...s/redirect-management/info-app/document-redirect-management-workspace-info-app.element.ts
This file contains hidden or 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,242 @@ | ||
| import { UMB_DOCUMENT_WORKSPACE_CONTEXT } from '../../workspace/constants.js'; | ||
| import { | ||
| css, | ||
| customElement, | ||
| html, | ||
| ifDefined, | ||
| nothing, | ||
| repeat, | ||
| state, | ||
| when, | ||
| } from '@umbraco-cms/backoffice/external/lit'; | ||
| import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; | ||
| import type { UmbEntityActionEvent } from '@umbraco-cms/backoffice/entity-action'; | ||
| import { UmbRequestReloadStructureForEntityEvent } from '@umbraco-cms/backoffice/entity-action'; | ||
| import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action'; | ||
| import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; | ||
| import { debounce } from '@umbraco-cms/backoffice/utils'; | ||
| import { tryExecute } from '@umbraco-cms/backoffice/resources'; | ||
| import { | ||
| RedirectManagementService, | ||
| RedirectStatusModel, | ||
| type RedirectUrlResponseModel, | ||
| } from '@umbraco-cms/backoffice/external/backend-api'; | ||
|
|
||
| @customElement('umb-document-redirect-management-workspace-info-app') | ||
| export class UmbDocumentRedirectManagementWorkspaceInfoAppElement extends UmbLitElement { | ||
| @state() | ||
| private _isNew = false; | ||
|
|
||
| @state() | ||
| private _unique?: string; | ||
|
|
||
| @state() | ||
| private _trackerEnabled = true; | ||
|
|
||
| @state() | ||
| private _loading = false; | ||
|
|
||
| @state() | ||
| private _redirects: Array<RedirectUrlResponseModel> = []; | ||
|
|
||
| #documentWorkspaceContext?: typeof UMB_DOCUMENT_WORKSPACE_CONTEXT.TYPE; | ||
| #eventContext?: typeof UMB_ACTION_EVENT_CONTEXT.TYPE; | ||
|
|
||
| constructor() { | ||
| super(); | ||
|
|
||
| this.consumeContext(UMB_ACTION_EVENT_CONTEXT, (context) => { | ||
| this.#eventContext = context; | ||
|
|
||
| this.#eventContext?.removeEventListener( | ||
| UmbRequestReloadStructureForEntityEvent.TYPE, | ||
| this.#onReloadRequest as unknown as EventListener, | ||
| ); | ||
|
|
||
| this.#eventContext?.addEventListener( | ||
| UmbRequestReloadStructureForEntityEvent.TYPE, | ||
| this.#onReloadRequest as unknown as EventListener, | ||
| ); | ||
| }); | ||
|
|
||
| this.consumeContext(UMB_DOCUMENT_WORKSPACE_CONTEXT, (context) => { | ||
| this.#documentWorkspaceContext = context; | ||
|
|
||
| this.observe( | ||
| context?.isNew, | ||
| (isNew) => { | ||
| this._isNew = isNew === true; | ||
| }, | ||
| 'observeIsNew', | ||
| ); | ||
|
|
||
| this.observe( | ||
| context?.unique, | ||
| (unique) => { | ||
| if (!unique || unique === this._unique) return; | ||
| this._unique = unique; | ||
| this.#requestRedirects(); | ||
| }, | ||
| 'observeUnique', | ||
| ); | ||
| }); | ||
|
|
||
| this.#requestTrackerStatus(); | ||
| } | ||
|
|
||
| async #requestTrackerStatus() { | ||
| const { data } = await tryExecute(this, RedirectManagementService.getRedirectManagementStatus()); | ||
| if (data?.status) { | ||
| this._trackerEnabled = data.status === RedirectStatusModel.ENABLED; | ||
| } | ||
| } | ||
|
|
||
| async #requestRedirects() { | ||
| if (this._isNew) return; | ||
| if (!this._unique) return; | ||
|
|
||
| this._loading = true; | ||
|
|
||
| const { data } = await tryExecute( | ||
| this, | ||
| RedirectManagementService.getRedirectManagementById({ path: { id: this._unique } }), | ||
| ); | ||
|
|
||
| this._redirects = data?.items ?? []; | ||
| this._loading = false; | ||
| } | ||
|
|
||
| #debounceRequestRedirects = debounce(() => this.#requestRedirects(), 50); | ||
|
|
||
| #onReloadRequest = (event: UmbEntityActionEvent) => { | ||
| if (event.getUnique() !== this.#documentWorkspaceContext?.getUnique()) return; | ||
| if (event.getEntityType() !== this.#documentWorkspaceContext.getEntityType()) return; | ||
| this.#debounceRequestRedirects(); | ||
| }; | ||
|
|
||
| #getTargetUrl(url: string | undefined) { | ||
| if (!url || url.length === 0) return url; | ||
|
Zeegaan marked this conversation as resolved.
Outdated
|
||
| if (url.includes('.') && !url.includes('//')) return '//' + url; | ||
| return url; | ||
| } | ||
|
|
||
| override render() { | ||
| if (!this._trackerEnabled) return nothing; | ||
| if (this._isNew) return nothing; | ||
| if (!this._loading && this._redirects.length === 0) return nothing; | ||
|
|
||
| return html` | ||
| <umb-workspace-info-app-layout headline="#redirectUrls_redirectUrlManagement"> | ||
| <div id="content"> | ||
| ${when( | ||
| this._loading, | ||
| () => this.#renderLoading(), | ||
| () => this.#renderContent(), | ||
| )} | ||
| </div> | ||
| </umb-workspace-info-app-layout> | ||
| `; | ||
| } | ||
|
|
||
| #renderLoading() { | ||
| return html`<div id="loader-container"><uui-loader></uui-loader></div>`; | ||
| } | ||
|
|
||
| #renderContent() { | ||
| return html` | ||
| <umb-localize class="panel-information" key="redirectUrls_panelInformation"> | ||
| The following URLs redirect to this content item: | ||
| </umb-localize> | ||
| ${repeat( | ||
| this._redirects, | ||
| (redirect) => redirect.id, | ||
| (redirect) => this.#renderRedirect(redirect), | ||
| )} | ||
| `; | ||
| } | ||
|
|
||
| #renderRedirect(redirect: RedirectUrlResponseModel) { | ||
| return html` | ||
| <a | ||
| class="redirect-item" | ||
| href=${ifDefined(this.#getTargetUrl(redirect.originalUrl))} | ||
| target="_blank" | ||
| rel="noopener"> | ||
| <span> | ||
| ${redirect.culture ? html`<span class="culture">${redirect.culture}</span>` : nothing} | ||
| <span>${redirect.originalUrl}</span> | ||
| </span> | ||
| <uui-icon name="icon-out"></uui-icon> | ||
| </a> | ||
| `; | ||
| } | ||
|
|
||
| override disconnectedCallback(): void { | ||
| super.disconnectedCallback(); | ||
|
|
||
| this.#eventContext?.removeEventListener( | ||
| UmbRequestReloadStructureForEntityEvent.TYPE, | ||
| this.#onReloadRequest as unknown as EventListener, | ||
| ); | ||
| } | ||
|
|
||
| static override styles = [ | ||
| UmbTextStyles, | ||
| css` | ||
| :host { | ||
| display: contents; | ||
| } | ||
|
|
||
| #content { | ||
| display: block; | ||
| padding: var(--uui-size-space-3) var(--uui-size-space-4); | ||
| } | ||
|
|
||
| #loader-container { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| padding: var(--uui-size-space-2); | ||
| } | ||
|
|
||
| .panel-information { | ||
| display: block; | ||
| margin: var(--uui-size-space-2); | ||
| } | ||
|
|
||
| .redirect-item { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| gap: var(--uui-size-6); | ||
| padding: var(--uui-size-space-4) var(--uui-size-space-5); | ||
| margin: 0 calc(var(--uui-size-space-4) * -1); | ||
| cursor: pointer; | ||
| color: inherit; | ||
| text-decoration: none; | ||
|
|
||
| &:hover { | ||
| background: var(--uui-color-divider); | ||
| } | ||
|
|
||
| & > span { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: var(--uui-size-6); | ||
| } | ||
|
|
||
| .culture { | ||
| color: var(--uui-color-divider-emphasis); | ||
| } | ||
| } | ||
| `, | ||
| ]; | ||
| } | ||
|
|
||
| export default UmbDocumentRedirectManagementWorkspaceInfoAppElement; | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'umb-document-redirect-management-workspace-info-app': UmbDocumentRedirectManagementWorkspaceInfoAppElement; | ||
| } | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
....Web.UI.Client/src/packages/documents/documents/redirect-management/info-app/manifests.ts
This file contains hidden or 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,25 @@ | ||
| import { UMB_DOCUMENT_WORKSPACE_ALIAS } from '../../workspace/constants.js'; | ||
| import { | ||
| UMB_WORKSPACE_CONDITION_ALIAS, | ||
| UMB_WORKSPACE_ENTITY_IS_NEW_CONDITION_ALIAS, | ||
| } from '@umbraco-cms/backoffice/workspace'; | ||
|
|
||
| export const manifests: Array<UmbExtensionManifest> = [ | ||
| { | ||
| type: 'workspaceInfoApp', | ||
| name: 'Document Redirect Management Workspace Info App', | ||
| alias: 'Umb.WorkspaceInfoApp.Document.RedirectManagement', | ||
| element: () => import('./document-redirect-management-workspace-info-app.element.js'), | ||
| weight: 85, | ||
| conditions: [ | ||
| { | ||
| alias: UMB_WORKSPACE_CONDITION_ALIAS, | ||
| match: UMB_DOCUMENT_WORKSPACE_ALIAS, | ||
| }, | ||
| { | ||
| alias: UMB_WORKSPACE_ENTITY_IS_NEW_CONDITION_ALIAS, | ||
| match: false, | ||
| }, | ||
| ], | ||
| }, | ||
| ]; |
3 changes: 3 additions & 0 deletions
3
src/Umbraco.Web.UI.Client/src/packages/documents/documents/redirect-management/manifests.ts
This file contains hidden or 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 { manifests as infoAppManifests } from './info-app/manifests.js'; | ||
|
|
||
| export const manifests: Array<UmbExtensionManifest> = [...infoAppManifests]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.