Skip to content

Commit

Permalink
chore(edit-content): fix error with folder id #29873
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobytes committed Nov 27, 2024
1 parent e15f58e commit eef66a6
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@
align-items: center;
}

.p-dialog-mask.p-dialog-mask-transparent-ai.p-component-overlay {
background-color: transparent;
-webkit-backdrop-filter: blur($blur-md);
backdrop-filter: blur($blur-md);
.p-dialog-mask.p-dialog-mask-dynamic.p-component-overlay {
padding: 0;
align-items: center;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import { ButtonModule } from 'primeng/button';
import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';

import { DotFileFieldUploadService } from '@dotcms/edit-content/fields/dot-edit-content-file-field/services/upload-file/upload-file.service';
import { INPUT_TYPE, INPUT_TYPES } from '@dotcms/edit-content/models/dot-edit-content-file.model';
import { DotMessagePipe } from '@dotcms/ui';

import { DotDataViewComponent } from './components/dot-dataview/dot-dataview.component';
import { DotSideBarComponent } from './components/dot-sidebar/dot-sidebar.component';
import { SelectExisingFileStore } from './store/select-existing-file.store';

type DialogData = {
inputType: INPUT_TYPE;
mimeTypes: string[];
};

@Component({
Expand Down Expand Up @@ -74,8 +73,8 @@ export class DotSelectExistingFileComponent implements OnInit {

ngOnInit() {
const data = this.#dialogConfig?.data as DialogData;
const inputType = data?.inputType === INPUT_TYPES.Image ? ['image'] : [];
this.store.setMimeTypes(inputType);
const mimeTypes = data?.mimeTypes ?? [];
this.store.setMimeTypes(mimeTypes);
this.store.loadContent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const SelectExisingFileStore = signalStore(
content: { ...store.content(), status: ComponentStatus.LOADING }
})
),
map((event) => (event ? event?.node?.data?.identifier : SYSTEM_HOST_ID)),
map((event) => (event ? event?.node?.data?.id : SYSTEM_HOST_ID)),
filter((identifier) => {
const hasIdentifier = !!identifier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import { filter, map } from 'rxjs/operators';

import { DotAiService, DotMessageService } from '@dotcms/data-access';
import { DotCMSContentTypeField, DotGeneratedAIImage } from '@dotcms/dotcms-models';
import { INPUT_TYPE, UploadedFile } from '@dotcms/edit-content/models/dot-edit-content-file.model';
import {
INPUT_TYPE,
INPUT_TYPES,
UploadedFile
} from '@dotcms/edit-content/models/dot-edit-content-file.model';
import {
DotDropZoneComponent,
DotMessagePipe,
Expand Down Expand Up @@ -282,7 +286,6 @@ export class DotEditContentFileFieldComponent implements ControlValueAccessor, O
closeOnEscape: false,
draggable: false,
keepInViewport: false,
maskStyleClass: 'p-dialog-mask-transparent',
modal: true,
resizable: false,
position: 'center',
Expand Down Expand Up @@ -323,7 +326,7 @@ export class DotEditContentFileFieldComponent implements ControlValueAccessor, O
closeOnEscape: false,
draggable: false,
keepInViewport: false,
maskStyleClass: 'p-dialog-mask-transparent-ai',
maskStyleClass: 'p-dialog-mask-dynamic',
resizable: false,
modal: true,
width: '90%',
Expand Down Expand Up @@ -367,7 +370,7 @@ export class DotEditContentFileFieldComponent implements ControlValueAccessor, O
closeOnEscape: false,
draggable: false,
keepInViewport: false,
maskStyleClass: 'p-dialog-mask-transparent-ai',
maskStyleClass: 'p-dialog-mask-dynamic',
resizable: false,
modal: true,
width: '90%',
Expand Down Expand Up @@ -399,24 +402,28 @@ export class DotEditContentFileFieldComponent implements ControlValueAccessor, O
* @memberof DotEditContentFileFieldComponent
*/
showSelectExistingFileDialog() {
const header = this.#dotMessageService.get(
'dot.file.field.dialog.select.existing.file.header'
);
const fieldType = this.$field().fieldType;
const title =
fieldType === INPUT_TYPES.Image
? 'dot.file.field.dialog.select.existing.image.header'
: 'dot.file.field.dialog.select.existing.file.header';
const mimeTypes = fieldType === INPUT_TYPES.Image ? ['image'] : [];

const header = this.#dotMessageService.get(title);

this.#dialogRef = this.#dialogService.open(DotSelectExistingFileComponent, {
header,
appendTo: 'body',
closeOnEscape: false,
draggable: false,
keepInViewport: false,
maskStyleClass: 'p-dialog-mask-transparent-ai',
maskStyleClass: 'p-dialog-mask-dynamic',
resizable: false,
modal: true,
width: '90%',
style: { 'max-width': '1040px' },
data: {
inputType: this.$field().fieldType,
acceptedFiles: this.store.acceptedFiles()
mimeTypes
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type TreeNodeData = {
type: 'site' | 'folder';
path: string;
hostname: string;
identifier: string;
id: string;
};

export type TreeNodeItem = TreeNode<TreeNodeData>;
Expand All @@ -27,7 +27,7 @@ export interface TreeNodeSelectEvent<T> {
}

export interface DotFolder {
identifier: string;
id: string;
hostName: string;
path: string;
addChildrenAllowed: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class DotEditContentService {
key: site.hostname,
label: `//${site.hostname}`,
data: {
identifier: site.identifier,
id: site.identifier,
hostname: `//${site.hostname}`,
path: '',
type: 'site'
Expand Down Expand Up @@ -133,7 +133,7 @@ export class DotEditContentService {
key: `${folder.hostName}${folder.path}`.replace(/[/]/g, ''),
label: `//${folder.hostName}${folder.path}`,
data: {
identifier: folder.identifier,
id: folder.id,
hostname: `//${folder.hostName}`,
path: folder.path,
type: 'folder'
Expand Down Expand Up @@ -204,7 +204,7 @@ export class DotEditContentService {
key: site.hostname,
label: `//${site.hostname}`,
data: {
identifier: site.identifier,
id: site.identifier,
hostname: `//${site.hostname}`,
path: '',
type: 'site'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ dot.file.field.action.import.from.url=Import from URL
dot.file.field.action.import.from.url.error.message=The URL you requested is not valid. Please try again.
dot.file.field.action.remove=Remove
dot.file.field.dialog.select.existing.file.header=Select Existing File
dot.file.field.dialog.select.existing.image.header=Select Existing Image
dot.file.field.dialog.select.existing.file.table.emptymessage=No content found
dot.file.field.dialog.select.existing.file.table.thumbnail=Thumbnail
dot.file.field.dialog.select.existing.file.table.search=Search content
Expand Down

0 comments on commit eef66a6

Please sign in to comment.