Skip to content

Commit

Permalink
chore(edit-content): fix error #30215
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobytes committed Nov 22, 2024
1 parent 53b4ca5 commit 1315692
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ import { getUiMessage } from './utils/messages';
ButtonModule,
DotMessagePipe,
DotDropZoneComponent,
DotAIImagePromptComponent,
DotSpinnerModule,
DotFileFieldUiMessageComponent,
DotFileFieldPreviewComponent,
DotFormImportUrlComponent,
TooltipModule
],
providers: [
Expand Down Expand Up @@ -389,7 +387,17 @@ export class DotEditContentFileFieldComponent implements ControlValueAccessor, O
this.store.setPreviewFile(file);
});
}

/**
* Shows the select existing file dialog.
*
* Opens the dialog with the `DotSelectExistingFileComponent` component
* and passes the field type and accepted files as data to the component.
*
* When the dialog is closed, gets the uploaded file from the component
* and sets it as the preview file in the store.
*
* @memberof DotEditContentFileFieldComponent
*/
showSelectExistingFileDialog() {
const header = this.#dotMessageService.get(
'dot.file.field.dialog.select.existing.file.header'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@ngneat/spectator/jest';
import { of } from 'rxjs';

import { DotContentTypeService, DotWorkflowActionsFireService } from '@dotcms/data-access';
import { DotContentTypeService, DotSiteService, DotWorkflowActionsFireService } from '@dotcms/data-access';

import { DotEditContentService } from './dot-edit-content.service';

Expand All @@ -20,10 +20,12 @@ describe('DotEditContentService', () => {
let spectator: SpectatorHttp<DotEditContentService>;
let dotContentTypeService: SpyObject<DotContentTypeService>;
let dotWorkflowActionsFireService: SpyObject<DotWorkflowActionsFireService>;
let dotSiteService: SpyObject<DotSiteService>;

const createHttp = createHttpFactory({
service: DotEditContentService,
providers: [
mockProvider(DotSiteService),
mockProvider(DotContentTypeService),
mockProvider(DotWorkflowActionsFireService)
]
Expand All @@ -32,6 +34,7 @@ describe('DotEditContentService', () => {
spectator = createHttp();
dotContentTypeService = spectator.inject(DotContentTypeService);
dotWorkflowActionsFireService = spectator.inject(DotWorkflowActionsFireService);
dotSiteService = spectator.inject(DotSiteService);
});

describe('Endpoints', () => {
Expand Down Expand Up @@ -69,4 +72,24 @@ describe('DotEditContentService', () => {
});
});
});

describe('getContentByFolder', () => {
it('should call siteService with correct params when only folderId is provided', () => {
dotSiteService.getContentByFolder.mockReturnValue(of([]));
spectator.service.getContentByFolder({ folderId: '123' });

expect(dotSiteService.getContentByFolder).toHaveBeenCalledWith({
mimeTypes: [],
hostFolderId: '123',
showLinks: false,
showDotAssets: true,
showPages: false,
showFiles: true,
showFolders: false,
showWorking: true,
sortByDesc: true,
showArchived: false
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,14 @@ export class DotEditContentService {
.get<{ entity: { count: number } }>(`/api/v1/content/${identifier}/references/count`)
.pipe(map((response) => response.entity.count));
}


/**
* Get content by folder
*
* @param {{ folderId: string; mimeTypes?: string[] }} { folderId, mimeTypes }
* @return {*}
* @memberof DotEditContentService
*/
getContentByFolder({ folderId, mimeTypes }: { folderId: string; mimeTypes?: string[] }) {
const params = {
hostFolderId: folderId,
Expand All @@ -238,7 +245,7 @@ export class DotEditContentService {
showWorking: true,
showArchived: false,
sortByDesc: true,
mimeTypes
mimeTypes: mimeTypes || []
};

return this.#siteService.getContentByFolder(params);
Expand Down

0 comments on commit 1315692

Please sign in to comment.