Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(edit-content) show files according to host/folder #30612

Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
34b8103
chore(edit-content): implement endpoint to fetch sites #30215
nicobytes Nov 4, 2024
b4dd221
Merge branch 'main' into 30215-select-existing-file-show-hostfolder-o…
nicobytes Nov 4, 2024
54cd5e4
chore(edit-content): Load sites for select existing file dialog #30215
nicobytes Nov 5, 2024
4748500
Merge branch '30215-select-existing-file-show-hostfolder-on-the-left'…
nicobytes Nov 5, 2024
49da66b
Merge branch 'main' into 30215-select-existing-file-show-hostfolder-o…
nicobytes Nov 5, 2024
473820a
chore(edit-content): Add docs #30215
nicobytes Nov 5, 2024
ff9c63f
chore(edit-content): Fix unit tests #30215
nicobytes Nov 5, 2024
23cdfc5
chore(edit-content): Fix sonar issue #30215
nicobytes Nov 5, 2024
9364dd5
chore(edit-content): add unit tests #30215
nicobytes Nov 5, 2024
6b1bf9d
chore(edit-content): add unit tests #30215
nicobytes Nov 5, 2024
10142c3
Merge branch 'main' into 30215-select-existing-file-show-hostfolder-o…
nicobytes Nov 5, 2024
0aac381
chore(edit-content): fix error #30215
nicobytes Nov 5, 2024
d64565e
Merge branch 'main' into 30215-select-existing-file-show-hostfolder-o…
nicobytes Nov 6, 2024
dbbe0b8
chore(edit-content): apply feedback #30215
nicobytes Nov 6, 2024
55ababe
Merge branch '30215-select-existing-file-show-hostfolder-on-the-left'…
nicobytes Nov 6, 2024
e29e890
chore(edit-content): fix error #30215
nicobytes Nov 6, 2024
f87007a
chore(edit-content): create logic to services #30216
nicobytes Nov 8, 2024
8d4f59b
chore(edit-content): sync with master #30216
nicobytes Nov 8, 2024
efa2947
chore(edit-content): enable search #30216
nicobytes Nov 8, 2024
b74e5d4
Merge branch 'main' into 30216-select-existing-file-show-files-accord…
nicobytes Nov 8, 2024
b850bff
chore(edit-content): truncate side panel #30216
nicobytes Nov 8, 2024
6a85a90
chore(edit-content): add docs #30216
nicobytes Nov 8, 2024
b74acca
chore(edit-content): fix problem with linter #30216
nicobytes Nov 8, 2024
24f7789
chore(edit-content): fix unit tests #30216
nicobytes Nov 8, 2024
6ddf93e
chore(edit-content): fix unit tests #30216
nicobytes Nov 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions core-web/libs/data-access/src/lib/dot-site/dot-site.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@ import { Injectable, inject } from '@angular/core';
import { pluck } from 'rxjs/operators';

import { Site } from '@dotcms/dotcms-js';
import { DotCMSContentlet } from '@dotcms/dotcms-models';

export interface SiteParams {
archived: boolean;
live: boolean;
system: boolean;
}

export interface ContentByFolderParams {
hostFolderId: string;
showLinks?: boolean;
showDotAssets?: boolean;
showArchived?: boolean;
sortByDesc?: boolean;
showPages?: boolean;
showFiles?: boolean;
showFolders?: boolean;
showWorking?: boolean;
extensions?: string[];
mimeTypes?: string[];
}

export const BASE_SITE_URL = '/api/v1/site';

export const DEFAULT_PER_PAGE = 10;
Expand Down Expand Up @@ -73,4 +88,16 @@ export class DotSiteService {
.get<{ entity: Site }>(`${BASE_SITE_URL}/currentSite`)
.pipe(pluck('entity'));
}

nicobytes marked this conversation as resolved.
Show resolved Hide resolved
/**
* Retrieves contentlets from a specified folder.
*
* @param params - Parameters defining the folder and retrieval options.
* @returns An observable emitting an array of `DotCMSContentlet` items.
*/
getContentByFolder(params: ContentByFolderParams) {
return this.#http
.post<{ entity: { list: DotCMSContentlet[] } }>('/api/v1/browser', params)
.pipe(pluck('entity', 'list'));
}
}
6 changes: 6 additions & 0 deletions core-web/libs/dotcms-scss/angular/dotcms-theme/_misc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ a.p-button {
width: $icon-lg-box;
font-size: $icon-lg;
}

.truncate-text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ import { catchError } from 'rxjs/operators';

import { DotResourceLinksService } from '@dotcms/data-access';
import { DotCMSBaseTypesContentTypes, DotCMSContentlet } from '@dotcms/dotcms-models';
import {
DotPreviewResourceLink,
UploadedFile
} from '@dotcms/edit-content/models/dot-edit-content-file.model';
import {
DotTempFileThumbnailComponent,
DotFileSizeFormatPipe,
DotMessagePipe,
DotCopyButtonComponent
} from '@dotcms/ui';

import { DotPreviewResourceLink, UploadedFile } from '../../models';
import { getFileMetadata } from '../../utils';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { NgClass } from '@angular/common';
import { ChangeDetectionStrategy, Component, input } from '@angular/core';

import { UIMessage } from '@dotcms/edit-content/models/dot-edit-content-file.model';
import { DotMessagePipe } from '@dotcms/ui';

import { UIMessage } from '../../models';

@Component({
selector: 'dot-file-field-ui-message',
standalone: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ import { InputTextModule } from 'primeng/inputtext';

import { debounceTime, distinctUntilChanged, filter } from 'rxjs/operators';

import { UploadedFile } from '@dotcms/edit-content/models/dot-edit-content-file.model';
import { DotMessagePipe, DotFieldValidationMessageComponent } from '@dotcms/ui';

import { FormFileEditorStore } from './store/form-file-editor.store';

import { UploadedFile } from '../../models';

type DialogProps = {
allowFileNameEdit: boolean;
userMonacoOptions: Partial<MonacoEditorConstructionOptions>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { switchMap, tap } from 'rxjs/operators';

import { ComponentStatus, DotHttpErrorResponse } from '@dotcms/dotcms-models';

import { UPLOAD_TYPE, UploadedFile } from '../../../models';
import { UPLOAD_TYPE, UploadedFile } from '../../../../../models/dot-edit-content-file.model';
import { DotFileFieldUploadService } from '../../../services/upload-file/upload-file.service';
import { extractFileExtension, getInfoByLang } from '../../../utils/editor';
import { DEFAULT_MONACO_CONFIG } from '../dot-form-file-editor.conts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { DialogService, DynamicDialogConfig, DynamicDialogRef } from 'primeng/dy

import { DotMessageService } from '@dotcms/data-access';
import { ComponentStatus } from '@dotcms/dotcms-models';
import { UploadedFile } from '@dotcms/edit-content/models/dot-edit-content-file.model';

import { DotFormImportUrlComponent } from './dot-form-import-url.component';
import { FormImportUrlStore } from './store/form-import-url.store';

import { NEW_FILE_MOCK } from '../../../../utils/mocks';
import { UploadedFile } from '../../models';
import { DotFileFieldUploadService } from '../../services/upload-file/upload-file.service';

describe('DotFormImportUrlComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import { ButtonModule } from 'primeng/button';
import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';
import { InputTextModule } from 'primeng/inputtext';

import { INPUT_TYPES } from '@dotcms/edit-content/models/dot-edit-content-file.model';
import { DotMessagePipe, DotFieldValidationMessageComponent, DotValidators } from '@dotcms/ui';

import { FormImportUrlStore } from './store/form-import-url.store';

import { INPUT_TYPE } from '../../../dot-edit-content-text-field/utils';

@Component({
selector: 'dot-form-import-url',
standalone: true,
Expand All @@ -38,7 +37,7 @@ export class DotFormImportUrlComponent implements OnInit {
readonly #formBuilder = inject(FormBuilder);
readonly #dialogRef = inject(DynamicDialogRef);
readonly #dialogConfig = inject(
DynamicDialogConfig<{ inputType: INPUT_TYPE; acceptedFiles: string[] }>
DynamicDialogConfig<{ inputType: INPUT_TYPES; acceptedFiles: string[] }>
);
#abortController: AbortController | null = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { switchMap, tap } from 'rxjs/operators';

import { ComponentStatus, DotHttpErrorResponse } from '@dotcms/dotcms-models';

import { UploadedFile, UPLOAD_TYPE } from '../../../models';
import { UploadedFile, UPLOAD_TYPE } from '../../../../../models/dot-edit-content-file.model';
import { DotFileFieldUploadService } from '../../../services/upload-file/upload-file.service';

export interface FormImportUrlState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
@let loading = $loading();
@let data = $data();
@let rowsPerPage = $rowsPerPage();

<p-table
[value]="$data()"
[loading]="$loading()"
[paginator]="true"
[rows]="7"
styleClass="p-datatable-lg flex flex-column h-full justify-content-between">
#datatable
[value]="data"
[loading]="loading"
[paginator]="data.length >= rowsPerPage"
[rows]="rowsPerPage"
selectionMode="single"
dataKey="identifier"
[(selection)]="$selectedProduct"
(onRowSelect)="onRowSelect.emit($event.data)"
[globalFilterFields]="['title', 'modUserName']"
styleClass="flex flex-column h-full justify-content-between">
<ng-template pTemplate="emptymessage">
<tr>
<td colspan="4">
{{ 'dot.file.field.dialog.select.existing.file.table.emptymessage' | dm }}
</td>
</tr>
</ng-template>
<ng-template pTemplate="caption">
<div class="flex">
<p-iconField iconPosition="left">
<p-inputIcon styleClass="pi pi-search" />
<input pInputText type="text" placeholder="Search keyword" />
<input
#searchInput
pInputText
type="search"
[placeholder]="'dot.file.field.dialog.select.existing.file.table.search' | dm"
(input)="datatable.filterGlobal(searchInput.value, 'contains')" />
</p-iconField>
</div>
</ng-template>
<ng-template pTemplate="header">
<tr class="file-selector__table_header">
<th scope="col">
{{ 'dot.file.field.dialog.select.existing.file.table.thumbnail' | dm }}
</th>
<th scope="col">{{ 'dot.file.field.dialog.select.existing.file.table.title' | dm }}</th>
<th scope="col">
{{ 'dot.file.field.dialog.select.existing.file.table.modified.by' | dm }}
Expand All @@ -24,31 +49,21 @@
</tr>
</ng-template>
<ng-template pTemplate="body" let-content>
<tr class="h-4rem">
<td>
<div class="flex gap-1 align-items-center">
<p-image
loading="lazy"
[preview]="true"
styleClass="image"
[src]="content.image"
[alt]="content.title"
width="40" />

<p class="m-0">{{ content.title }}</p>
<tr class="h-3rem" [pSelectableRow]="content">
<td class="max-w-2rem">
<div class="dataview-thumbnail">
<dot-contentlet-thumbnail
[iconSize]="'48px'"
[contentlet]="content"
[playableVideo]="false"
data-testId="contentlet-thumbnail" />
</div>
</td>
<td>{{ content.modifiedBy }}</td>
<td>{{ content.lastModified | date }}</td>
</tr>
</ng-template>
<ng-template pTemplate="loadingbody" let-columns="columns">
<tr class="h-4rem">
@for (col of columns; track $index) {
<td>
<p-skeleton />
</td>
}
<td class="max-w-12rem">
<p class="truncate-text">{{ content.title }}</p>
</td>
<td>{{ content.modUserName }}</td>
<td>{{ content.modDate | date }}</td>
</tr>
</ng-template>
</p-table>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@
}
::ng-deep {
p-table {
.p-datatable .p-datatable-header {
background-color: $color-palette-gray-100;
.p-datatable {
.p-datatable-header {
background-color: $color-palette-gray-100;
}
.p-datatable-wrapper {
height: 100%;
}
}
}
}

.dataview-thumbnail {
width: 100%;
max-height: 3rem;
overflow: hidden;
position: relative;
}

.file-selector__table_header {
th {
font-weight: $font-weight-bold;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,74 @@
import { DatePipe, NgOptimizedImage } from '@angular/common';
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { DatePipe } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
CUSTOM_ELEMENTS_SCHEMA,
input,
model,
output,
signal
} from '@angular/core';

import { ButtonModule } from 'primeng/button';
import { DataViewModule } from 'primeng/dataview';
import { IconFieldModule } from 'primeng/iconfield';
import { ImageModule } from 'primeng/image';
import { InputIconModule } from 'primeng/inputicon';
import { InputTextModule } from 'primeng/inputtext';
import { SkeletonModule } from 'primeng/skeleton';
import { TableModule } from 'primeng/table';
import { TagModule } from 'primeng/tag';

import { DotCMSContentlet } from '@dotcms/dotcms-models';
import { DotMessagePipe } from '@dotcms/ui';

import { Content } from '../../store/select-existing-file.store';

@Component({
selector: 'dot-dataview',
standalone: true,
imports: [
DataViewModule,
TagModule,
ButtonModule,
TableModule,
IconFieldModule,
InputIconModule,
InputTextModule,
SkeletonModule,
ImageModule,
NgOptimizedImage,
DatePipe,
DotMessagePipe
],
templateUrl: './dot-dataview.component.html',
styleUrls: ['./dot-dataview.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
changeDetection: ChangeDetectionStrategy.OnPush,
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class DotDataViewComponent {
/**
* Represents an observable stream of content data.
*
* @type {Observable<Content[]>}
* @type {Observable<DotCMSContentlet[]>}
* @alias data
* @required
*/
$data = input.required<Content[]>({ alias: 'data' });
$data = input.required<DotCMSContentlet[]>({ alias: 'data' });
/**
* A boolean observable that indicates the loading state.
* This is typically used to show or hide a loading indicator in the UI.
*
* @type {boolean}
*/
$loading = input.required<boolean>({ alias: 'loading' });

/**
* Signal representing the number of rows per page in the data view.
*
* @type {number}
*/
$rowsPerPage = signal<number>(9);

/**
* Reactive model holding the currently selected product.
* Can be a `DotCMSContentlet` or `null`.
*/
$selectedProduct = model<DotCMSContentlet | null>(null);

/**
* Emits the selected `DotCMSContentlet` when a row is selected.
*/
onRowSelect = output<DotCMSContentlet>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

@if (!loading) {
<p-tree
[value]="$folders()"
[value]="$state().folders"
[loading]="loading"
selectionMode="single"
[(selection)]="$state().selectedFile"
loadingMode="icon"
class="w-full h-full"
styleClass="flex h-full"
styleClass="w-full h-full"
loadingMode="icon"
(onNodeSelect)="onNodeSelect.emit($event)"
(onNodeExpand)="onNodeExpand.emit($event)">
<ng-template let-node pTemplate="default">
<span>{{ node.label | truncatePath | slice: 0 : 18 }}</span>
<span>{{ node.label | truncatePath }}</span>
</ng-template>
</p-tree>
} @else {
Expand Down
Loading