From 56392615a5319e50d98f83c2db5dbf034190b234 Mon Sep 17 00:00:00 2001 From: VitoAlbano Date: Fri, 23 Aug 2024 00:00:52 +0100 Subject: [PATCH] [MIGRATION] - Something happened on the way to heaven --- .eslintignore | 1 + .../content-auth-loader-factory.ts | 1 - .../lib/common/services/rendition.service.ts | 4 +- .../content-metadata.component.ts | 4 +- .../content-node-share.dialog.ts | 4 +- .../components/document-list.component.ts | 4 +- .../tree-view/data/tree-view-datasource.ts | 45 +++++++++---------- .../version-compatibility-factory.ts | 1 - .../src/lib/clipboard/clipboard.service.ts | 8 +++- lib/core/src/lib/common/utils/file-utils.ts | 40 +++++++++-------- lib/process-services-cloud/.storybook/main.js | 6 +-- .../content-cloud-node-selector.service.ts | 8 +++- .../identity/group-identity.service.ts | 8 ++-- .../core/pages/data-table-component.page.ts | 8 +++- .../lib/protractor/core/pages/login.page.ts | 3 +- .../lib/protractor/core/pages/viewer.page.ts | 4 +- 16 files changed, 84 insertions(+), 65 deletions(-) diff --git a/.eslintignore b/.eslintignore index 9bea255a96..0e67ef1d7f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -9,3 +9,4 @@ scripts /angular.json docs/**/*.md lib/js-api/docs/**/*.md +.storybook diff --git a/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts b/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts index f252cfe844..2c38e49b4c 100644 --- a/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts +++ b/lib/content-services/src/lib/auth-loader/content-auth-loader-factory.ts @@ -17,7 +17,6 @@ import { ContentAuthLoaderService } from './content-auth-loader.service'; -// eslint-disable-next-line prefer-arrow/prefer-arrow-functions /** * Create a content auth factory * diff --git a/lib/content-services/src/lib/common/services/rendition.service.ts b/lib/content-services/src/lib/common/services/rendition.service.ts index 03d239dc50..53465e5dc8 100644 --- a/lib/content-services/src/lib/common/services/rendition.service.ts +++ b/lib/content-services/src/lib/common/services/rendition.service.ts @@ -115,7 +115,9 @@ export class RenditionService { try { await this.renditionsApi.createRendition(nodeId, { id: renditionId }); rendition = await this.waitRendition(nodeId, renditionId, 0); - } catch {} + } catch { + return null; + } } } return new Promise((resolve) => resolve(rendition)); diff --git a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts index beb90feec4..3264294291 100644 --- a/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts +++ b/lib/content-services/src/lib/content-metadata/components/content-metadata/content-metadata.component.ts @@ -238,7 +238,9 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy { try { statusCode = JSON.parse(error.message).error.statusCode; - } catch {} + } catch { + /* empty */ + } let message = `METADATA.ERRORS.${statusCode}`; diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts index 31f4a3da91..041d6f3a2c 100644 --- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts +++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts @@ -252,7 +252,9 @@ export class ShareDialogComponent implements OnInit, OnDestroy { try { statusCode = JSON.parse(error.message).error.statusCode; - } catch {} + } catch { + /* empty */ + } if (statusCode === 403) { message = 'SHARE.UNSHARE_PERMISSION_ERROR'; diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index c09e9dddb6..22930be07c 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -1049,7 +1049,9 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On if (JSON.parse(err.message).error.statusCode === 403) { this.noPermission = true; } - } catch (error) {} + } catch (error) { + /* empty */ + } } this.setLoadingState(false); this.error.emit(err); diff --git a/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts b/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts index 89797d6347..046d353a56 100644 --- a/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts +++ b/lib/content-services/src/lib/tree-view/data/tree-view-datasource.ts @@ -25,7 +25,6 @@ import { TreeViewService } from '../services/tree-view.service'; @Injectable() export class TreeViewDataSource { - treeNodes: TreeBaseNode[]; dataChange = new BehaviorSubject([]); childrenSubscription = null; @@ -40,15 +39,13 @@ export class TreeViewDataSource { this.dataChange.next(value); } - constructor(private treeControl: FlatTreeControl, - private treeViewService: TreeViewService) { - this.dataChange.subscribe((treeNodes) => this.treeNodes = treeNodes); + constructor(private treeControl: FlatTreeControl, private treeViewService: TreeViewService) { + this.dataChange.subscribe((treeNodes) => (this.treeNodes = treeNodes)); } connect(collectionViewer: CollectionViewer): Observable { this.changeSubscription = this.treeControl.expansionModel.changed.subscribe((change) => { - if ((change as SelectionChange).added && - (change as SelectionChange).added.length > 0) { + if ((change as SelectionChange).added && (change as SelectionChange).added.length > 0) { this.expandTreeNodes(change as SelectionChange); } else if ((change as SelectionChange).removed) { this.reduceTreeNodes(change as SelectionChange); @@ -71,33 +68,35 @@ export class TreeViewDataSource { } private reduceTreeNodes(change: SelectionChange) { - change.removed.slice().reverse().forEach((node) => this.toggleNode(node)); + change.removed + .slice() + .reverse() + .forEach((node) => this.toggleNode(node)); } private expandNode(node: TreeBaseNode) { - this.childrenSubscription = this.treeViewService.getTreeNodes(node.nodeId) - .subscribe((children) => { - const index = this.data.indexOf(node); - if (!children || index < 0) { - node.expandable = false; - return; - } - const nodes = children.map((actualNode) => { - actualNode.level = node.level + 1; - return actualNode; - }); - this.data.splice(index + 1, 0, ...nodes); - this.dataChange.next(this.data); + this.childrenSubscription = this.treeViewService.getTreeNodes(node.nodeId).subscribe((children) => { + const index = this.data.indexOf(node); + if (!children || index < 0) { + node.expandable = false; + return; + } + const nodes = children.map((actualNode) => { + actualNode.level = node.level + 1; + return actualNode; }); + this.data.splice(index + 1, 0, ...nodes); + this.dataChange.next(this.data); + }); } toggleNode(node: TreeBaseNode) { const index = this.data.indexOf(node); let count = 0; - for (let i = index + 1; i < this.data.length - && this.data[i].level > node.level; i++ , count++) { } + for (let i = index + 1; i < this.data.length && this.data[i].level > node.level; i++, count++) { + /* empty */ + } this.data.splice(index + 1, count); this.dataChange.next(this.data); } - } diff --git a/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts b/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts index 8b907f2fab..ddfe20f11e 100644 --- a/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts +++ b/lib/content-services/src/lib/version-compatibility/version-compatibility-factory.ts @@ -17,7 +17,6 @@ import { VersionCompatibilityService } from './version-compatibility.service'; -// eslint-disable-next-line prefer-arrow/prefer-arrow-functions /** * Create a version compatibility factory * diff --git a/lib/core/src/lib/clipboard/clipboard.service.ts b/lib/core/src/lib/clipboard/clipboard.service.ts index 2a877e05d4..48d9cf5cb6 100644 --- a/lib/core/src/lib/clipboard/clipboard.service.ts +++ b/lib/core/src/lib/clipboard/clipboard.service.ts @@ -53,7 +53,9 @@ export class ClipboardService { this.document.execCommand('copy'); } this.notify(message); - } catch {} + } catch { + /* empty */ + } } } @@ -76,7 +78,9 @@ export class ClipboardService { document.execCommand('copy'); } this.notify(message); - } catch {} + } catch { + /* empty */ + } } private notify(message) { diff --git a/lib/core/src/lib/common/utils/file-utils.ts b/lib/core/src/lib/common/utils/file-utils.ts index 7f75c01ea3..09ae601353 100644 --- a/lib/core/src/lib/common/utils/file-utils.ts +++ b/lib/core/src/lib/common/utils/file-utils.ts @@ -22,36 +22,38 @@ export interface FileInfo { } export class FileUtils { - static flatten(folder: any): Promise { const reader = folder.createReader(); const files: FileInfo[] = []; return new Promise((resolve) => { const iterations = []; - // eslint-disable-next-line prefer-arrow/prefer-arrow-functions (function traverse() { reader.readEntries((entries) => { if (!entries.length) { Promise.all(iterations).then(() => resolve(files)); } else { - iterations.push(Promise.all(entries.map((entry) => { - if (entry.isFile) { - return new Promise((resolveFile) => { - entry.file((file: File) => { - files.push({ - entry, - file, - relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '') + iterations.push( + Promise.all( + entries.map((entry) => { + if (entry.isFile) { + return new Promise((resolveFile) => { + entry.file((file: File) => { + files.push({ + entry, + file, + relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '') + }); + resolveFile(); + }); }); - resolveFile(); - }); - }); - } else { - return FileUtils.flatten(entry).then((result) => { - files.push(...result); - }); - } - }))); + } else { + return FileUtils.flatten(entry).then((result) => { + files.push(...result); + }); + } + }) + ) + ); // Try calling traverse() again for the same dir, according to spec traverse(); } diff --git a/lib/process-services-cloud/.storybook/main.js b/lib/process-services-cloud/.storybook/main.js index 14a3aaa1ba..6436dca16b 100644 --- a/lib/process-services-cloud/.storybook/main.js +++ b/lib/process-services-cloud/.storybook/main.js @@ -4,11 +4,7 @@ module.exports = { rootMain: rootPath, stories: [...rootPath.stories, '../**/*.stories.@(js|jsx|ts|tsx)'], - staticDirs: [ - ...rootPath.staticDirs, - { from: __dirname + '/../src/lib/i18n', to: 'assets/adf-core/i18n' }, - { from: __dirname + '/../src/lib/assets/images', to: 'assets/images' } - ], + staticDirs: [...rootPath.staticDirs, { from: __dirname + '/../src/lib/i18n', to: 'assets/adf-core/i18n' }], addons: ['@storybook/addon-essentials', ...rootPath.addons], diff --git a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts index d860e7eef3..18ef24aedd 100644 --- a/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts +++ b/lib/process-services-cloud/src/lib/form/services/content-cloud-node-selector.service.ts @@ -66,7 +66,9 @@ export class ContentCloudNodeSelectorService { if (destinationFolderPath.alias && destinationFolderPath.path) { try { return await this.getNodeId(destinationFolderPath.alias, destinationFolderPath.path).toPromise(); - } catch {} + } catch { + /*empty*/ + } } return this.getNodeId(destinationFolderPath.alias).toPromise(); @@ -82,7 +84,9 @@ export class ContentCloudNodeSelectorService { if (nodeId) { try { isExistingNode = await this.getNodeId(nodeId).pipe(mapTo(true)).toPromise(); - } catch {} + } catch { + /*empty*/ + } } return isExistingNode; } diff --git a/lib/testing/src/lib/protractor/core/actions/identity/group-identity.service.ts b/lib/testing/src/lib/protractor/core/actions/identity/group-identity.service.ts index e38b3586ef..6b6428321c 100644 --- a/lib/testing/src/lib/protractor/core/actions/identity/group-identity.service.ts +++ b/lib/testing/src/lib/protractor/core/actions/identity/group-identity.service.ts @@ -22,7 +22,6 @@ import { Logger } from '../../utils/logger'; import { browser } from 'protractor'; export class GroupIdentityService { - api: ApiService; constructor(api: ApiService) { @@ -75,9 +74,11 @@ export class GroupIdentityService { Logger.log(`Data ${JSON.stringify(data)}`); - return data[0]; Logger.error('Group not found'); - + return data[0]; + Logger.error('Group not found'); } catch (error) { + Logger.error('Group not found'); + return null; } }; @@ -135,5 +136,4 @@ export class GroupIdentityService { const data = await this.api.performIdentityOperation(path, method, queryParams, postBody); return data[0].id; } - } diff --git a/lib/testing/src/lib/protractor/core/pages/data-table-component.page.ts b/lib/testing/src/lib/protractor/core/pages/data-table-component.page.ts index 4738dae8cd..dcf1dc402f 100644 --- a/lib/testing/src/lib/protractor/core/pages/data-table-component.page.ts +++ b/lib/testing/src/lib/protractor/core/pages/data-table-component.page.ts @@ -388,7 +388,9 @@ export class DataTableComponentPage { this.rootElement.element(by.tagName(materialLocators.Progress.spinner.root)), MAX_LOADING_TIME ); - } catch (error) {} + } catch (error) { + Logger.error('Loading spinner is not present'); + } if (await this.isEmpty()) { Logger.log('empty page'); @@ -414,7 +416,9 @@ export class DataTableComponentPage { try { Logger.log('wait datatable loading spinner is present'); await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName(materialLocators.Progress.bar.root))); - } catch (error) {} + } catch (error) { + Logger.error('Infinite pagination spinner is not present'); + } if (await this.isEmpty()) { Logger.log('empty page'); } else { diff --git a/lib/testing/src/lib/protractor/core/pages/login.page.ts b/lib/testing/src/lib/protractor/core/pages/login.page.ts index 934fb02bab..3c556de137 100644 --- a/lib/testing/src/lib/protractor/core/pages/login.page.ts +++ b/lib/testing/src/lib/protractor/core/pages/login.page.ts @@ -43,6 +43,7 @@ export class LoginPage { try { currentUrl = await browser.getCurrentUrl(); } catch (e) { + /* do nothing */ } if (!currentUrl || currentUrl.indexOf(this.loginUrl) === -1) { @@ -87,7 +88,7 @@ export class LoginPage { if (oauth2 && oauth2.silentLogin === false) { Logger.log(`Login SSO`); await this.clickOnSSOButton(); - }else{ + } else { Logger.log(`Login SSO silent login`); } diff --git a/lib/testing/src/lib/protractor/core/pages/viewer.page.ts b/lib/testing/src/lib/protractor/core/pages/viewer.page.ts index 27e12d49c7..2efd2c10ed 100644 --- a/lib/testing/src/lib/protractor/core/pages/viewer.page.ts +++ b/lib/testing/src/lib/protractor/core/pages/viewer.page.ts @@ -75,7 +75,9 @@ export class ViewerPage { Logger.log('wait spinner is present'); await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName(materialLocators.Progress.spinner.root))); await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName(materialLocators.Progress.spinner.root)), MAX_LOADING_TIME); - } catch (error) {} + } catch (error) { + Logger.error('Spinner is not present'); + } } }