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

[ACS-7389][ADF] Break Viewer dependency on Material Module #9631

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,55 @@
* limitations under the License.
*/

import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange, QueryList, Component, ViewChild, SimpleChanges } from '@angular/core';
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import {
DataColumnListComponent,
DataColumnComponent,
AppConfigService,
AuthenticationService,
DataColumn,
DataColumnComponent,
DataColumnListComponent,
DataTableComponent,
DataTableModule,
ObjectDataTableAdapter,
ShowHeaderMode,
ThumbnailService,
AppConfigService,
AuthenticationService
ThumbnailService
} from '@alfresco/adf-core';
import { ContentService } from '../../common/services/content.service';
import { Subject, of, throwError } from 'rxjs';
import { FavoritePaging, FavoritePagingList, Node, NodeEntry, NodePaging } from '@alfresco/js-api';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { Component, CUSTOM_ELEMENTS_SCHEMA, QueryList, SimpleChange, SimpleChanges, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { MatDialog } from '@angular/material/dialog';
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';
import { By } from '@angular/platform-browser';
import { of, Subject, throwError } from 'rxjs';
import { ContentService } from '../../common';
import {
FileNode,
FolderNode,
fakeGetSiteMembership,
fakeGetSitesAnswer,
fakeNodeAnswerWithNOEntries,
fakeNodeWithNoPermission,
fakeGetSitesAnswer,
fakeGetSiteMembership,
mockPreselectedNodes,
mockNodePagingWithPreselectedNodes,
FileNode,
FolderNode,
mockNode1,
mockNode2,
mockNode3
mockNode3,
mockNodePagingWithPreselectedNodes,
mockPreselectedNodes
} from '../../mock';
import { ContentActionModel } from '../models/content-action.model';
import { ImageResolver } from './../data/image-resolver.model';
import { RowFilter } from './../data/row-filter.model';
import { DocumentListService } from './../services/document-list.service';
import { CustomResourcesService } from './../services/custom-resources.service';
import { DocumentListComponent } from './document-list.component';
import { ContentTestingModule } from '../../testing/content.testing.module';
import { FavoritePaging, NodeEntry, NodePaging, Node, FavoritePagingList } from '@alfresco/js-api';
import { By } from '@angular/platform-browser';
import { DocumentListModule } from '../document-list.module';
import { domSanitizerMock } from '../../testing/dom-sanitizer-mock';
import { matIconRegistryMock } from '../../testing/mat-icon-registry-mock';
import { ImageResolver } from '../data/image-resolver.model';
import { RowFilter } from '../data/row-filter.model';
import { ShareDataRow } from '../data/share-data-row.model';
import { ShareDataTableAdapter } from '../data/share-datatable-adapter';
import { DocumentListModule } from '../document-list.module';
import { ContentActionModel } from '../models/content-action.model';
import { DocumentLoaderNode } from '../models/document-folder.model';
import { matIconRegistryMock } from '../../testing/mat-icon-registry-mock';
import { domSanitizerMock } from '../../testing/dom-sanitizer-mock';
import { MatDialog } from '@angular/material/dialog';
import { CustomResourcesService } from '../services/custom-resources.service';
import { DocumentListService } from '../services/document-list.service';
import { DocumentListComponent } from './document-list.component';
import { FileAutoDownloadComponent } from './file-auto-download/file-auto-download.component';
import { ShareDataTableAdapter } from '../data/share-datatable-adapter';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';

const mockDialog = {
open: jasmine.createSpy('open')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@
/* eslint-disable rxjs/no-subject-value */
/* eslint-disable @typescript-eslint/naming-convention */

import {
AlfrescoApiService,
AppConfigService,
CustomEmptyContentTemplateDirective,
CustomLoadingContentTemplateDirective,
CustomNoPermissionTemplateDirective,
DataCellEvent,
DataColumn,
DataColumnListComponent,
DataRow,
DataRowActionEvent,
DataSorting,
DataTableComponent,
DataTableSchema,
DataTableService,
PaginatedComponent,
PaginationModel,
RequestPaginationModel,
ShowHeaderMode,
ThumbnailService,
UserPreferencesService,
UserPreferenceValues
} from '@alfresco/adf-core';
import { Node, NodeEntry, NodePaging, NodesApi, Pagination } from '@alfresco/js-api';
import {
AfterContentInit,
Component,
Expand All @@ -34,50 +58,23 @@ import {
ViewChild,
ViewEncapsulation
} from '@angular/core';
import { ContentService } from '../../common/services/content.service';

import {
DataCellEvent,
DataRowActionEvent,
DataSorting,
DataTableComponent,
ShowHeaderMode,
PaginatedComponent,
AppConfigService,
DataColumnListComponent,
UserPreferencesService,
PaginationModel,
ThumbnailService,
CustomLoadingContentTemplateDirective,
CustomNoPermissionTemplateDirective,
CustomEmptyContentTemplateDirective,
RequestPaginationModel,
AlfrescoApiService,
UserPreferenceValues,
DataRow,
DataTableService,
DataTableSchema,
DataColumn,
ViewerComponentConfig
} from '@alfresco/adf-core';
import { NodesApiService } from '../../common/services/nodes-api.service';
import { Node, NodeEntry, NodePaging, NodesApi, Pagination } from '@alfresco/js-api';
import { Subject, BehaviorSubject, of } from 'rxjs';
import { ShareDataRow } from './../data/share-data-row.model';
import { ShareDataTableAdapter } from './../data/share-datatable-adapter';
import { presetsDefaultModel } from '../models/preset.model';
import { ContentActionModel } from './../models/content-action.model';
import { PermissionStyleModel } from './../models/permissions-style.model';
import { NodeEntityEvent, NodeEntryEvent } from './node.event';
import { FilterSearch } from './../../search/models/filter-search.interface';
import { MatDialog } from '@angular/material/dialog';
import { BehaviorSubject, of, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { ContentService, NodesApiService } from '../../common';
import { FilterSearch } from '../../search';
import { RowFilter } from '../data/row-filter.model';
import { ShareDataRow } from '../data/share-data-row.model';
import { ShareDataTableAdapter } from '../data/share-datatable-adapter';
import { ContentActionModel } from '../models/content-action.model';
import { DocumentLoaderNode } from '../models/document-folder.model';
import { PermissionStyleModel } from '../models/permissions-style.model';
import { presetsDefaultModel } from '../models/preset.model';
import { DocumentListService } from '../services/document-list.service';
import { LockService } from '../services/lock.service';
import { DocumentLoaderNode } from '../models/document-folder.model';
import { takeUntil } from 'rxjs/operators';
import { ADF_DOCUMENT_PARENT_COMPONENT } from './document-list.token';
import { MatDialog } from '@angular/material/dialog';
import { FileAutoDownloadComponent } from './file-auto-download/file-auto-download.component';
import { NodeEntityEvent, NodeEntryEvent } from './node.event';

const BYTES_TO_MB_CONVERSION_VALUE = 1048576;

Expand Down Expand Up @@ -524,6 +521,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
this.createDatatableSchema();
this.data.setColumns(this.columns);
}

ngOnChanges(changes: SimpleChanges) {
if (!changes['preselectNodes']) {
this.resetSelection();
Expand Down Expand Up @@ -790,10 +788,8 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
onPreviewFile(node: NodeEntry) {
if (node) {
const sizeInMB = node.entry?.content?.sizeInBytes / BYTES_TO_MB_CONVERSION_VALUE;
const config = this.appConfig.get<ViewerComponentConfig>('viewer');

const fileAutoDownloadFlag = config?.enableFileAutoDownload ?? true;
const sizeThreshold = config?.fileAutoDownloadSizeThresholdInMB ?? 15;
const fileAutoDownloadFlag: boolean = this.appConfig.get('viewer.enableFileAutoDownload', true);
const sizeThreshold: number = this.appConfig.get('viewer.fileAutoDownloadSizeThresholdInMB', 15);

if (fileAutoDownloadFlag && sizeInMB && sizeInMB > sizeThreshold) {
this.dialog.open(FileAutoDownloadComponent, { disableClose: true, data: node });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
*/

import { ComponentFixture, TestBed } from '@angular/core/testing';

import { By } from '@angular/platform-browser';
import { MatDialogRef } from '@angular/material/dialog';
import { DownloadPromptDialogComponent } from './download-prompt-dialog.component';
import { CoreTestingModule } from '../../../testing/core.testing.module';
import { By } from '@angular/platform-browser';
import { CoreTestingModule } from '../../../testing';
import { DownloadPromptActions } from '../../models/download-prompt.actions';
import { DownloadPromptDialogComponent } from './download-prompt-dialog.component';

const mockDialog = {
close: jasmine.createSpy('close')
Expand All @@ -35,8 +34,7 @@ describe('DownloadPromptDialogComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [DownloadPromptDialogComponent],
imports: [CoreTestingModule],
imports: [CoreTestingModule, DownloadPromptDialogComponent],
providers: [{ provide: MatDialogRef, useValue: mockDialog }]
});
matDialogRef = TestBed.inject(MatDialogRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
*/

import { Component } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
import { TranslateModule } from '@ngx-translate/core';
import { DownloadPromptActions } from '../../models/download-prompt.actions';

@Component({
selector: 'adf-download-prompt-dialog',
standalone: true,
imports: [MatDialogModule, TranslateModule, MatButtonModule],
templateUrl: './download-prompt-dialog.component.html'
})
export class DownloadPromptDialogComponent {
Expand Down
86 changes: 0 additions & 86 deletions lib/core/src/lib/viewer/components/img-viewer.component.html

This file was deleted.

Loading
Loading