Skip to content

Commit

Permalink
rename to replace
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen committed Jan 13, 2025
1 parent b1336e7 commit eb0535e
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export const manifests: Array<UmbExtensionManifest> = [
},
{
type: 'propertyAction',
kind: 'pasteFromClipboard',
alias: 'Umb.PropertyAction.BlockGrid.Clipboard.Paste',
name: 'Block Grid Paste From Clipboard Property Action',
kind: 'replaceFromClipboard',
alias: 'Umb.PropertyAction.BlockGrid.Clipboard.Replace',
name: 'Block Grid Replace From Clipboard Property Action',
forPropertyEditorUis,
conditions: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ export class UmbBlockGridEntriesContext
} else {
throw new Error('Failed to create block');
}
} else if (value?.pasteFromClipboard && value.pasteFromClipboard.selection?.length && data) {
} else if (value?.clipboard && value.clipboard.selection?.length && data) {

Check warning on line 204 in src/Umbraco.Web.UI.Client/src/packages/block/block-grid/context/block-grid-entries.context.ts

View check run for this annotation

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

❌ New issue: Complex Conditional

UmbBlockGridEntriesContext.constructor has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
const clipboardContext = await this.getContext(UMB_CLIPBOARD_PROPERTY_CONTEXT);

const propertyValues = await clipboardContext.readMultiple<UmbBlockGridValueModel>(
value.pasteFromClipboard.selection,
value.clipboard.selection,
UMB_BLOCK_GRID_PROPERTY_EDITOR_UI_ALIAS,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export const manifests: Array<UmbExtensionManifest> = [
},
{
type: 'propertyAction',
kind: 'pasteFromClipboard',
alias: 'Umb.PropertyAction.BlockList.Clipboard.Paste',
name: 'Block List Paste From Clipboard Property Action',
kind: 'replaceFromClipboard',
alias: 'Umb.PropertyAction.BlockList.Clipboard.Replace',
name: 'Block List Replace From Clipboard Property Action',
forPropertyEditorUis,
conditions: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
} else {
throw new Error('Failed to create block');
}
} else if (value?.pasteFromClipboard && value.pasteFromClipboard.selection?.length && data) {
} else if (value?.clipboard && value.clipboard.selection?.length && data) {

Check warning on line 75 in src/Umbraco.Web.UI.Client/src/packages/block/block-list/context/block-list-entries.context.ts

View check run for this annotation

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

❌ New issue: Complex Conditional

UmbBlockListEntriesContext.constructor has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
const clipboardContext = await this.getContext(UMB_CLIPBOARD_PROPERTY_CONTEXT);

const propertyValues = await clipboardContext.readMultiple<UmbBlockListValueModel>(
value.pasteFromClipboard.selection,
value.clipboard.selection,
UMB_BLOCK_LIST_PROPERTY_EDITOR_UI_ALIAS,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class UmbBlockCatalogueModalElement extends UmbModalBaseElement<
const target = event.target as any;
const selection = target?.selection || [];
this.value = {
pasteFromClipboard: {
clipboard: {
selection,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type UmbBlockCatalogueModalValue =
create?: {
contentElementTypeKey: string;
};
pasteFromClipboard?: {
clipboard?: {
selection: Array<string>;
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { manifests as copyManifests } from './copy/manifests.js';
import { manifests as pasteManifests } from './paste/manifests.js';
import { manifests as pasteManifests } from './replace/manifests.js';
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';

export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [...copyManifests, ...pasteManifests];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { UMB_PROPERTY_ACTION_DEFAULT_KIND_MANIFEST } from '@umbraco-cms/backoffi
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
{
type: 'kind',
alias: 'Umb.Kind.PropertyAction.pasteFromClipboard',
matchKind: 'pasteFromClipboard',
alias: 'Umb.Kind.PropertyAction.Clipboard.Replace',
matchKind: 'replaceFromClipboard',
matchType: 'propertyAction',
manifest: {
...UMB_PROPERTY_ACTION_DEFAULT_KIND_MANIFEST.manifest,
type: 'propertyAction',
kind: 'pasteFromClipboard',
api: () => import('./paste-from-clipboard.property-action.js'),
kind: 'replaceFromClipboard',
api: () => import('./replace-from-clipboard.property-action.js'),
weight: 1190,
meta: {
icon: 'icon-clipboard-paste',
label: 'Paste',
label: 'Replace',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { UmbClipboardEntryItemRepository } from '../../../clipboard-entry/index.js';
import { UMB_CLIPBOARD_PROPERTY_CONTEXT } from '../../context/clipboard.property-context-token.js';
import type { MetaPropertyActionPasteFromClipboardKind } from './types.js';
import type { MetaPropertyActionReplaceFromClipboardKind } from './types.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
import { UMB_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/property';
import { UmbPropertyActionBase, type UmbPropertyActionArgs } from '@umbraco-cms/backoffice/property-action';

export class UmbPasteFromClipboardPropertyAction extends UmbPropertyActionBase<MetaPropertyActionPasteFromClipboardKind> {
export class UmbReplaceFromClipboardPropertyAction extends UmbPropertyActionBase<MetaPropertyActionReplaceFromClipboardKind> {
#init: Promise<unknown>;
#propertyContext?: typeof UMB_PROPERTY_CONTEXT.TYPE;
#clipboardContext?: typeof UMB_CLIPBOARD_PROPERTY_CONTEXT.TYPE;

constructor(host: UmbControllerHost, args: UmbPropertyActionArgs<MetaPropertyActionPasteFromClipboardKind>) {
constructor(host: UmbControllerHost, args: UmbPropertyActionArgs<MetaPropertyActionReplaceFromClipboardKind>) {
super(host, args);

this.#init = Promise.all([
Expand Down Expand Up @@ -66,14 +66,14 @@ export class UmbPasteFromClipboardPropertyAction extends UmbPropertyActionBase<M

// Todo: localize
await umbConfirmModal(this, {
headline: 'Paste from clipboard',
content: `The property already contains a value. Paste from the property action will overwrite the current value.
headline: 'Replace from clipboard',
content: `The property already contains a value. Pasting will overwrite the current value.
Do you want to replace the current value with ${item.name}?`,
confirmLabel: 'Paste',
confirmLabel: 'Replace',
});
}

this.#propertyContext?.setValue(propertyValue);
}

Check warning on line 77 in src/Umbraco.Web.UI.Client/src/packages/clipboard/property/actions/replace/replace-from-clipboard.property-action.ts

View check run for this annotation

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

❌ New issue: Complex Method

UmbReplaceFromClipboardPropertyAction.execute has a cyclomatic complexity of 16, 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.
}
export { UmbPasteFromClipboardPropertyAction as api };
export { UmbReplaceFromClipboardPropertyAction as api };
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ManifestPropertyAction, MetaPropertyAction } from '@umbraco-cms/backoffice/property-action';

export interface ManifestPropertyActionReplaceFromClipboardKind
extends ManifestPropertyAction<MetaPropertyActionReplaceFromClipboardKind> {
type: 'propertyAction';
kind: 'replaceFromClipboard';
}

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface MetaPropertyActionReplaceFromClipboardKind extends MetaPropertyAction {}

declare global {
interface UmbExtensionManifestMap {
umbManifestPropertyActionReplaceFromClipboardKind: ManifestPropertyActionReplaceFromClipboardKind;
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export type * from './copy/types.js';
export type * from './paste/types.js';
export type * from './replace/types.js';

0 comments on commit eb0535e

Please sign in to comment.