Skip to content

Commit

Permalink
rename data to value and don't force an array
Browse files Browse the repository at this point in the history
  • Loading branch information
madsrasmussen committed Dec 16, 2024
1 parent 4531f15 commit 88d0da9
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('UmbClipboardEntryDetailLocalStorageDataSource', () => {
let dataSource: UmbClipboardEntryDetailLocalStorageDataSource;
const clipboardEntry: UmbClipboardEntryDetailModel = {
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test'],
value: ['test'],
icons: ['icon'],
meta: {},
name: 'Test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class UmbClipboardEntryDetailLocalStorageDataSource
*/
async createScaffold(preset: Partial<UmbClipboardEntryDetailModel> = {}) {
const data: UmbClipboardEntryDetailModel = {
data: [],
value: [],
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
icons: [],
meta: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('UmbClipboardEntryDetailRepository', () => {
let repository: UmbClipboardEntryDetailRepository;
const detailData: UmbClipboardEntryDetailModel = {
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test'],
value: ['test'],
icons: ['icon'],
meta: {},
name: 'Test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { UmbClipboardEntryEntityType } from './entity.js';
* A Clipboard entry is a composed set of data representing one entry in the clipboard.
* The entry has enough knowledge for the context of the clipboard to filter away unsupported entries.
*/
export interface UmbClipboardEntryDetailModel<Type extends string = string, MetaType = object, DataType = unknown> {
export interface UmbClipboardEntryDetailModel<Type extends string = string, MetaType = object, ValueType = unknown> {
entityType: UmbClipboardEntryEntityType;
/**
* The type of clipboard entry, this determines the data type of the entry. Making the entry as general as possible.
Expand All @@ -28,9 +28,9 @@ export interface UmbClipboardEntryDetailModel<Type extends string = string, Meta
*/
meta: MetaType;
/**
* The data of the copied pieces for this clipboard entry.
* The value of the clipboard entry.
*/
data: Array<DataType>;
value: ValueType;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { expect } from '@open-wc/testing';
import { Observable } from '@umbraco-cms/backoffice/external/rxjs';
import { customElement } from '@umbraco-cms/backoffice/external/lit';
import { UmbControllerHostElementMixin } from '@umbraco-cms/backoffice/controller-api';
import { UmbClipboardLocalStorageManager } from './clipboard-local-storage.manager.js';
import { UMB_CLIPBOARD_ENTRY_ENTITY_TYPE } from './clipboard-entry/entity.js';
import type { UmbClipboardEntryDetailModel } from './clipboard-entry/index.js';

type UmbTestClipboardEntryType = 'test1' | 'test2' | 'test3' | 'test4';
interface UmbTestClipboardEntryDetailModel
extends UmbClipboardEntryDetailModel<UmbTestClipboardEntryType, object, string> {}

describe('UmbClipboardLocalStorageManager', () => {
let manager: UmbClipboardLocalStorageManager;
const clipboardEntries: Array<UmbClipboardEntryDetailModel> = [
const clipboardEntries: Array<UmbTestClipboardEntryDetailModel> = [
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test1'],
value: 'test1',
icons: ['icon1'],
meta: {},
name: 'Test1',
Expand All @@ -20,7 +21,7 @@ describe('UmbClipboardLocalStorageManager', () => {
},
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test2'],
value: 'test2',
icons: ['icon2'],
meta: {},
name: 'Test2',
Expand All @@ -29,7 +30,7 @@ describe('UmbClipboardLocalStorageManager', () => {
},
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test3'],
value: 'test3',
icons: ['icon3'],
meta: {},
name: 'Test3',
Expand Down Expand Up @@ -79,7 +80,7 @@ describe('UmbClipboardLocalStorageManager', () => {
it('sets entries in local storage', () => {
const newEntry: UmbClipboardEntryDetailModel = {
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test4'],
value: 'test4',
icons: ['icon4'],
meta: {},
name: 'Test4',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('UmbClipboardLocalStorageDataSource', () => {
const clipboardEntries: Array<UmbClipboardEntryDetailModel> = [
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test1'],
value: ['test1'],
icons: ['icon1'],
meta: {},
name: 'Test1',
Expand All @@ -35,7 +35,7 @@ describe('UmbClipboardLocalStorageDataSource', () => {
},
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test2'],
value: ['test2'],
icons: ['icon2'],
meta: {},
name: 'Test2',
Expand All @@ -44,7 +44,7 @@ describe('UmbClipboardLocalStorageDataSource', () => {
},
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test3'],
value: ['test3'],
icons: ['icon3'],
meta: {},
name: 'Test3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('UmbClipboardLocalStorageDataSource', () => {
const clipboardEntries: Array<UmbClipboardEntryDetailModel> = [
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test1'],
value: ['test1'],
icons: ['icon1'],
meta: {},
name: 'Test1',
Expand All @@ -35,7 +35,7 @@ describe('UmbClipboardLocalStorageDataSource', () => {
},
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test2'],
value: ['test2'],
icons: ['icon2'],
meta: {},
name: 'Test2',
Expand All @@ -44,7 +44,7 @@ describe('UmbClipboardLocalStorageDataSource', () => {
},
{
entityType: UMB_CLIPBOARD_ENTRY_ENTITY_TYPE,
data: ['test3'],
value: ['test3'],
icons: ['icon3'],
meta: {},
name: 'Test3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class UmbColorPickerCopyToClipboardPropertyAction extends UmbPropertyActi
name: entryName,
icons: ['icon-color'], // TODO: make this value dynamic
meta: {},
data: [propertyValue],
value: [propertyValue],
});

if (data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class UmbColorPickerPasteFromClipboardPropertyAction extends UmbPropertyA
if (clipboardEntryUnique) {
const { data: entry } = await this.#detailRepository.requestByUnique(clipboardEntryUnique);

const entryValue = entry?.data[0];
const entryValue = entry?.value;

if (entryValue) {
this.#propertyContext?.setValue(entryValue);
Expand Down
Loading

0 comments on commit 88d0da9

Please sign in to comment.