From e6a12abdfbc9d656f8d0104e9ffb6b47f804bbf9 Mon Sep 17 00:00:00 2001 From: Nicolas Molina Date: Thu, 26 Sep 2024 14:13:08 -0400 Subject: [PATCH] feat(editor-content): fix error with sonar #29872 --- ...=> dot-edit-content-file-field.stories.ts} | 29 +++-- .../stories/binary-field.stories.ts | 104 ------------------ .../stories/image-field.stories.ts | 104 ------------------ 3 files changed, 22 insertions(+), 215 deletions(-) rename core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/{stories/file-field.stories.ts => dot-edit-content-file-field.stories.ts} (79%) delete mode 100644 core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts delete mode 100644 core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/image-field.stories.ts diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/file-field.stories.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.stories.ts similarity index 79% rename from core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/file-field.stories.ts rename to core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.stories.ts index 8798787f2ca4..035469200a06 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/file-field.stories.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.stories.ts @@ -14,13 +14,14 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { DotMessageService, DotUploadFileService } from '@dotcms/data-access'; import { DotCMSContentTypeField } from '@dotcms/dotcms-models'; -import { DotEditContentService } from '../../../services/dot-edit-content.service'; -import { FILE_FIELD_MOCK, NEW_FILE_MOCK } from '../../../utils/mocks'; -import { DotEditContentFileFieldComponent } from '../dot-edit-content-file-field.component'; -import { UIMessage } from '../models'; -import { DotFileFieldUploadService } from '../services/upload-file/upload-file.service'; -import { FileFieldStore } from '../store/file-field.store'; -import { MessageServiceMock } from '../utils/mocks'; +import { DotEditContentFileFieldComponent } from './dot-edit-content-file-field.component'; +import { UIMessage } from './models'; +import { DotFileFieldUploadService } from './services/upload-file/upload-file.service'; +import { FileFieldStore } from './store/file-field.store'; +import { MessageServiceMock } from './utils/mocks'; + +import { DotEditContentService } from '../../services/dot-edit-content.service'; +import { BINARY_FIELD_MOCK, FILE_FIELD_MOCK, IMAGE_FIELD_MOCK, NEW_FILE_MOCK } from '../../utils/mocks'; type Args = DotEditContentFileFieldComponent & { field: DotCMSContentTypeField; @@ -89,6 +90,20 @@ export const FileField: Story = { } }; +export const BinaryField: Story = { + args: { + value: '', + field: { ...BINARY_FIELD_MOCK } + } +}; + +export const ImageField: Story = { + args: { + value: '', + field: { ...IMAGE_FIELD_MOCK } + } +}; + export const ResposiveFileField: Story = { args: { value: '', diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts deleted file mode 100644 index 0b38939a7924..000000000000 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { - moduleMetadata, - StoryObj, - Meta, - applicationConfig, - argsToTemplate -} from '@storybook/angular'; -import { of } from 'rxjs'; - -import { provideHttpClient } from '@angular/common/http'; -import { FormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; - -import { DotMessageService, DotUploadFileService } from '@dotcms/data-access'; -import { DotCMSContentTypeField } from '@dotcms/dotcms-models'; - -import { DotEditContentService } from '../../../services/dot-edit-content.service'; -import { BINARY_FIELD_MOCK, NEW_FILE_MOCK } from '../../../utils/mocks'; -import { DotEditContentFileFieldComponent } from '../dot-edit-content-file-field.component'; -import { DotFileFieldUploadService } from '../services/upload-file/upload-file.service'; -import { FileFieldStore } from '../store/file-field.store'; -import { MessageServiceMock } from '../utils/mocks'; - -type Args = DotEditContentFileFieldComponent & { - field: DotCMSContentTypeField; - value: string; -}; - -const meta: Meta = { - title: 'Library / Edit Content / New Binary Field', - component: DotEditContentFileFieldComponent, - decorators: [ - applicationConfig({ - providers: [ - provideHttpClient(), - { - provide: DotMessageService, - useValue: MessageServiceMock - } - ] - }), - moduleMetadata({ - imports: [BrowserAnimationsModule, FormsModule], - providers: [ - { - provide: DotUploadFileService, - useValue: {} - }, - { - provide: DotEditContentService, - useValue: {} - }, - { - provide: DotFileFieldUploadService, - useValue: { - uploadDotAsset: () => of(NEW_FILE_MOCK.entity), - getContentById: () => of(NEW_FILE_MOCK.entity) - } - }, - FileFieldStore - ] - }) - ], - render: (args) => { - const { value, ...newArgs } = args; - - return { - props: { - ...newArgs, - value - }, - template: ` - -

Current value: {{ value }}

- ` - }; - } -}; -export default meta; - -type Story = StoryObj; - -export const BinaryField: Story = { - args: { - value: '', - field: { ...BINARY_FIELD_MOCK } - } -}; - -export const ResposiveBinaryField: Story = { - args: { - value: '', - field: { ...BINARY_FIELD_MOCK } - }, - render: (args) => ({ - props: args, - template: ` -
- -

Current value: {{ value }}

-
- ` - }) -}; diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/image-field.stories.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/image-field.stories.ts deleted file mode 100644 index 336ed4c2bee5..000000000000 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/image-field.stories.ts +++ /dev/null @@ -1,104 +0,0 @@ -import { - moduleMetadata, - StoryObj, - Meta, - applicationConfig, - argsToTemplate -} from '@storybook/angular'; -import { of } from 'rxjs'; - -import { provideHttpClient } from '@angular/common/http'; -import { FormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; - -import { DotMessageService, DotUploadFileService } from '@dotcms/data-access'; -import { DotCMSContentTypeField } from '@dotcms/dotcms-models'; - -import { DotEditContentService } from '../../../services/dot-edit-content.service'; -import { IMAGE_FIELD_MOCK, NEW_FILE_MOCK } from '../../../utils/mocks'; -import { DotEditContentFileFieldComponent } from '../dot-edit-content-file-field.component'; -import { DotFileFieldUploadService } from '../services/upload-file/upload-file.service'; -import { FileFieldStore } from '../store/file-field.store'; -import { MessageServiceMock } from '../utils/mocks'; - -type Args = DotEditContentFileFieldComponent & { - field: DotCMSContentTypeField; - value: string; -}; - -const meta: Meta = { - title: 'Library / Edit Content / Image Field', - component: DotEditContentFileFieldComponent, - decorators: [ - applicationConfig({ - providers: [ - provideHttpClient(), - { - provide: DotMessageService, - useValue: MessageServiceMock - } - ] - }), - moduleMetadata({ - imports: [BrowserAnimationsModule, FormsModule], - providers: [ - { - provide: DotUploadFileService, - useValue: {} - }, - { - provide: DotEditContentService, - useValue: {} - }, - { - provide: DotFileFieldUploadService, - useValue: { - uploadDotAsset: () => of(NEW_FILE_MOCK.entity), - getContentById: () => of(NEW_FILE_MOCK.entity) - } - }, - FileFieldStore - ] - }) - ], - render: (args) => { - const { value, ...newArgs } = args; - - return { - props: { - ...newArgs, - value - }, - template: ` - -

Current value: {{ value }}

- ` - }; - } -}; -export default meta; - -type Story = StoryObj; - -export const ImageField: Story = { - args: { - value: '', - field: { ...IMAGE_FIELD_MOCK } - } -}; - -export const ResposiveImageField: Story = { - args: { - value: '', - field: { ...IMAGE_FIELD_MOCK } - }, - render: (args) => ({ - props: args, - template: ` -
- -

Current value: {{ value }}

-
- ` - }) -};