Skip to content
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

updated the link picker modal and the property editors using it. #18059

Merged
merged 6 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI.Client/src/assets/lang/da-dk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ export default {
selectIcon: 'Vælg ikon',
selectItem: 'Vælg item',
selectLink: 'Vælg link',
addLink: 'Tilføj Link',
updateLink: 'Opdater Link',
selectMacro: 'Vælg makro',
selectContent: 'Vælg indhold',
selectContentType: 'Vælg indholdstype',
Expand Down
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ export default {
selectIcon: 'Select icon',
selectItem: 'Select item',
selectLink: 'Configure link',
addLink: 'Add Link',
updateLink: 'Update Link',
selectMacro: 'Select macro',
selectContent: 'Select content',
selectContentType: 'Select content type',
Expand Down
2 changes: 2 additions & 0 deletions src/Umbraco.Web.UI.Client/src/assets/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ export default {
selectIcon: 'Select icon',
selectItem: 'Select item',
selectLink: 'Configure link',
addLink: 'Add Link',
updateLink: 'Update Link',
selectMacro: 'Select macro',
selectContent: 'Select content',
selectContentType: 'Select content type',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class UmbInputMultiUrlElement extends UUIFormControlMixin(UmbLitElement,
},
data: {
index: index,
isNew: index === null,
config: {
hideAnchor: this.hideAnchor,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker

override render() {
return html`
<umb-body-layout headline=${this.localize.term('defaultdialogs_selectLink')}>
<umb-body-layout
headline=${this.localize.term(
this.modalContext?.data.isNew ? 'defaultdialogs_addLink' : 'defaultdialogs_updateLink',
)}>
<uui-box>
${this.#renderLinkType()} ${this.#renderLinkAnchorInput()} ${this.#renderLinkTitleInput()}
${this.#renderLinkTargetInput()}
Expand All @@ -210,7 +213,7 @@ export class UmbLinkPickerModalElement extends UmbModalBaseElement<UmbLinkPicker
<uui-button
color="positive"
look="primary"
label=${this.localize.term('general_submit')}
label=${this.localize.term(this.modalContext?.data.isNew ? 'general_add' : 'general_update')}
?disabled=${!this.value.link.type}
@click=${this.#onSubmit}></uui-button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
export interface UmbLinkPickerModalData {
config: UmbLinkPickerConfig;
index: number | null;
isNew: boolean;
}

export type UmbLinkPickerModalValue = { link: UmbLinkPickerLink };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class UmbUrlPickerMonacoMarkdownEditorAction extends UmbControllerBase {
modal: { size: overlaySize },
data: {
index: null,
isNew: selectedValue === '',
config: {},
},
value: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default class UmbTinyMceMultiUrlPickerPlugin extends UmbTinyMcePluginBase
data: {
config: {},
index: null,
isNew: currentTarget?.url === undefined,
},
value: {
link: currentTarget ?? {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UmbTiptapToolbarElementApiBase } from '../base.js';

Check notice on line 1 in src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/toolbar/link.tiptap-toolbar-api.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 5.25 to 5.38, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
import { UmbLink } from '@umbraco-cms/backoffice/external/tiptap';
import { UMB_LINK_PICKER_MODAL } from '@umbraco-cms/backoffice/multi-url-picker';
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
Expand All @@ -10,7 +10,7 @@
override async execute(editor?: Editor) {
const attrs = editor?.getAttributes(UmbLink.name) ?? {};
const link = this.#getLinkData(attrs);
const data = { config: {}, index: null };
const data = { config: {}, index: null, isNew: link?.url === undefined };

Check notice on line 13 in src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/toolbar/link.tiptap-toolbar-api.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

ℹ Getting worse: Complex Method

UmbTiptapToolbarLinkExtensionApi.execute increases in cyclomatic complexity from 10 to 11, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
const value = { link };

const overlaySize = this.configuration?.getValueByAlias<UUIModalSidebarSize>('overlaySize') ?? 'small';
Expand Down
Loading