Various code fixes (#1704)

* fix typings and missing lib

* fix i18n typo, add typings

* code improvements

* fix missing awaits

* more fixes

* fix bug in the evaluators, simplify code

* more fixes
This commit is contained in:
Denys Vuika 2020-10-04 18:09:27 +01:00 committed by GitHub
parent bf11489e0f
commit 9c7ac17161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 133 additions and 142 deletions

View File

@ -106,7 +106,7 @@ import { Router } from '@angular/router';
@Component({...}) @Component({...})
export class CustomComponent { export class CustomComponent {
constructor(private store: Store<AppStore>, private router: Router) constructor(private store: Store<AppStore>, private router: Router) {}
viewNode(nodeId: string) { viewNode(nodeId: string) {
this.store.dispatch(new ViewNodeAction(nodeId, { location: this.router.url })); this.store.dispatch(new ViewNodeAction(nodeId, { location: this.router.url }));

View File

@ -84,7 +84,7 @@ describe('Extensions - DocumentList presets', () => {
const expectedColumns = testData.filter((item) => !item.disabled).map((data) => data.label); const expectedColumns = testData.filter((item) => !item.disabled).map((data) => data.label);
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C286699] Disabled items are not shown', async () => { it('[C286699] Disabled items are not shown', async () => {

View File

@ -88,14 +88,14 @@ describe('Favorites', () => {
const expectedColumns = ['Name', 'Location', 'Size', 'Modified', 'Modified by']; const expectedColumns = ['Name', 'Location', 'Size', 'Modified', 'Modified by'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C213226] displays the favorite files and folders', async () => { it('[C213226] displays the favorite files and folders', async () => {
expect(await dataTable.getRowsCount()).toEqual(4, 'Incorrect number of items displayed'); await expect(await dataTable.getRowsCount()).toEqual(4, 'Incorrect number of items displayed');
expect(await dataTable.isItemPresent(fileName1)).toBe(true, `${fileName1} not displayed`); await expect(await dataTable.isItemPresent(fileName1)).toBe(true, `${fileName1} not displayed`);
expect(await dataTable.isItemPresent(fileName2)).toBe(true, `${fileName2} not displayed`); await expect(await dataTable.isItemPresent(fileName2)).toBe(true, `${fileName2} not displayed`);
expect(await dataTable.isItemPresent(favFolderName)).toBe(true, `${favFolderName} not displayed`); await expect(await dataTable.isItemPresent(favFolderName)).toBe(true, `${favFolderName} not displayed`);
}); });
it(`[C213228] deleted favorite file does not appear`, async () => { it(`[C213228] deleted favorite file does not appear`, async () => {
@ -120,12 +120,12 @@ describe('Favorites', () => {
it('[C213650] Location column redirect - item in user Home', async () => { it('[C213650] Location column redirect - item in user Home', async () => {
await dataTable.clickItemLocation(favFolderName); await dataTable.clickItemLocation(favFolderName);
expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']); await expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']);
}); });
it('[C280484] Location column redirect - file in folder', async () => { it('[C280484] Location column redirect - file in folder', async () => {
await dataTable.clickItemLocation(fileName2); await dataTable.clickItemLocation(fileName2);
expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', parentFolder]); await expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', parentFolder]);
}); });
it('[C280485] Location column redirect - file in site', async () => { it('[C280485] Location column redirect - file in site', async () => {

View File

@ -103,7 +103,7 @@ describe('File Libraries', () => {
const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility']; const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C280501] User can see only the sites he is a member of', async () => { it('[C280501] User can see only the sites he is a member of', async () => {
@ -123,7 +123,7 @@ describe('File Libraries', () => {
const sitesList = await dataTable.getSitesNameAndVisibility(); const sitesList = await dataTable.getSitesNameAndVisibility();
for (const site of Object.keys(expectedSitesVisibility)) { for (const site of Object.keys(expectedSitesVisibility)) {
expect(sitesList[site]).toEqual(expectedSitesVisibility[site]); await expect(sitesList[site]).toEqual(expectedSitesVisibility[site]);
} }
}); });
@ -138,14 +138,14 @@ describe('File Libraries', () => {
const sitesList = await dataTable.getSitesNameAndRole(); const sitesList = await dataTable.getSitesNameAndRole();
for (const site of Object.keys(expectedSitesRoles)) { for (const site of Object.keys(expectedSitesRoles)) {
expect(sitesList[site]).toEqual(expectedSitesRoles[site]); await expect(sitesList[site]).toEqual(expectedSitesRoles[site]);
} }
}); });
it('[C217098] Site ID is displayed when two sites have the same name', async () => { it('[C217098] Site ID is displayed when two sites have the same name', async () => {
const expectedSites = [`${siteName} (${siteId1})`, `${siteName} (${siteId2})`]; const expectedSites = [`${siteName} (${siteId1})`, `${siteName} (${siteId2})`];
const actualSites = await dataTable.getCellsContainingName(siteName); const actualSites = await dataTable.getCellsContainingName(siteName);
expect(actualSites.sort()).toEqual(expectedSites.sort()); await expect(actualSites.sort()).toEqual(expectedSites.sort());
}); });
it('[C217096] Tooltip for sites without description', async () => { it('[C217096] Tooltip for sites without description', async () => {
@ -169,7 +169,7 @@ describe('File Libraries', () => {
const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility']; const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C289897] User can see only his favorite sites', async () => { it('[C289897] User can see only his favorite sites', async () => {

View File

@ -88,15 +88,15 @@ describe('Personal Files', () => {
const expectedColumns = ['Name', 'Size', 'Modified', 'Modified by']; const expectedColumns = ['Name', 'Size', 'Modified', 'Modified by'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C217143] has default sorted column', async () => { it('[C217143] has default sorted column', async () => {
expect(await dataTable.getSortedColumnHeaderText()).toBe('Name'); await expect(await dataTable.getSortedColumnHeaderText()).toBe('Name');
}); });
it('[C213242] has user created content', async () => { it('[C213242] has user created content', async () => {
expect(await dataTable.isItemPresent(userFolder)).toBe(true, 'user folder not displayed'); await expect(await dataTable.isItemPresent(userFolder)).toBe(true, 'user folder not displayed');
}); });
it('[C213244] navigates to folder', async () => { it('[C213244] navigates to folder', async () => {

View File

@ -84,7 +84,7 @@ describe('Recent Files', () => {
const expectedColumns = ['Name', 'Location', 'Size', 'Modified']; const expectedColumns = ['Name', 'Location', 'Size', 'Modified'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C213171] default sorting column', async () => { it('[C213171] default sorting column', async () => {
@ -117,7 +117,7 @@ describe('Recent Files', () => {
it('[C213176] Location column redirect - file in user Home', async () => { it('[C213176] Location column redirect - file in user Home', async () => {
await dataTable.clickItemLocation(fileName2); await dataTable.clickItemLocation(fileName2);
expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']); await expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']);
}); });
it('[C280486] Location column redirect - file in folder', async () => { it('[C280486] Location column redirect - file in folder', async () => {

View File

@ -97,7 +97,7 @@ describe('Shared Files', () => {
const expectedColumns = ['Name', 'Location', 'Size', 'Modified', 'Modified by', 'Shared by']; const expectedColumns = ['Name', 'Location', 'Size', 'Modified', 'Modified by', 'Shared by'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C213115] default sorting column', async () => { it('[C213115] default sorting column', async () => {
@ -126,7 +126,7 @@ describe('Shared Files', () => {
it('[C213666] Location column redirect - file in user Home', async () => { it('[C213666] Location column redirect - file in user Home', async () => {
await dataTable.clickItemLocation(file4User); await dataTable.clickItemLocation(file4User);
expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']); await expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']);
}); });
it('[C280490] Location column redirect - file in folder', async () => { it('[C280490] Location column redirect - file in folder', async () => {

View File

@ -108,7 +108,7 @@ describe('Trash', () => {
const expectedColumns = ['Name', 'Location', 'Size', 'Deleted', 'Deleted by']; const expectedColumns = ['Name', 'Location', 'Size', 'Deleted', 'Deleted by'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C280493] displays the files and folders deleted by everyone', async () => { it('[C280493] displays the files and folders deleted by everyone', async () => {
@ -135,7 +135,7 @@ describe('Trash', () => {
const expectedColumns = ['Name', 'Location', 'Size', 'Deleted']; const expectedColumns = ['Name', 'Location', 'Size', 'Deleted'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C213218] displays the files and folders deleted by the user', async () => { it('[C213218] displays the files and folders deleted by the user', async () => {

View File

@ -80,7 +80,7 @@ describe('Pagination on multiple pages : ', () => {
describe('on Search Results', () => { describe('on Search Results', () => {
beforeAll(async () => { beforeAll(async () => {
userApi.search.waitForApi(username, { expect: initialSearchTotalItems + 101 }); await userApi.search.waitForApi(username, { expect: initialSearchTotalItems + 101 });
}, 120000); }, 120000);
searchResultsTests(username); searchResultsTests(username);
}); });

View File

@ -172,7 +172,7 @@ describe('Search results - libraries', () => {
const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility']; const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility'];
const actualColumns = await dataTable.getColumnHeadersText(); const actualColumns = await dataTable.getColumnHeadersText();
expect(actualColumns).toEqual(expectedColumns); await expect(actualColumns).toEqual(expectedColumns);
}); });
it('[C290017] Library visibility is correctly displayed', async () => { it('[C290017] Library visibility is correctly displayed', async () => {

View File

@ -86,6 +86,7 @@
"ajv-cli": "^3.3.0", "ajv-cli": "^3.3.0",
"codelyzer": "^6.0.0", "codelyzer": "^6.0.0",
"commander": "^6.0.0", "commander": "^6.0.0",
"connect-history-api-fallback": "^1.6.0",
"cpr": "^3.0.1", "cpr": "^3.0.1",
"cspell": "^4.1.0", "cspell": "^4.1.0",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",

View File

@ -103,7 +103,7 @@ export function isShared(context: RuleContext): boolean {
return true; return true;
} }
if ((navigation.isNotTrashcan(context), !context.selection.isEmpty && context.selection.file)) { if (navigation.isNotTrashcan(context) && !context.selection.isEmpty && context.selection.file) {
return !!(context.selection.file.entry && context.selection.file.entry.properties && context.selection.file.entry.properties['qshare:sharedId']); return !!(context.selection.file.entry && context.selection.file.entry.properties && context.selection.file.entry.properties['qshare:sharedId']);
} }

View File

@ -126,6 +126,7 @@ export class ContentApiService {
/** /**
* Gets information about a user identified by their username. * Gets information about a user identified by their username.
* @param personId ID of the target user * @param personId ID of the target user
* @param options Api options
* @returns User information * @returns User information
*/ */
getPerson(personId: string, options?: { fields?: Array<string> }): Observable<PersonEntry> { getPerson(personId: string, options?: { fields?: Array<string> }): Observable<PersonEntry> {
@ -138,6 +139,7 @@ export class ContentApiService {
* @param nodeId The id of the node to be copied * @param nodeId The id of the node to be copied
* @param targetParentId The id of the folder-node where the node have to be copied to * @param targetParentId The id of the folder-node where the node have to be copied to
* @param name The new name for the copy that would be added on the destination folder * @param name The new name for the copy that would be added on the destination folder
* @param opts Api options
*/ */
copyNode(nodeId: string, targetParentId: string, name?: string, opts?: { include?: Array<string>; fields?: Array<string> }): Observable<NodeEntry> { copyNode(nodeId: string, targetParentId: string, name?: string, opts?: { include?: Array<string>; fields?: Array<string> }): Observable<NodeEntry> {
return from(this.api.nodesApi.copyNode(nodeId, { targetParentId, name }, opts)); return from(this.api.nodesApi.copyNode(nodeId, { targetParentId, name }, opts));

View File

@ -77,9 +77,9 @@ describe('RouterExtensionService', () => {
] ]
}); });
extensionService = TestBed.get(ExtensionService); extensionService = TestBed.inject(ExtensionService);
service = TestBed.get(RouterExtensionService); service = TestBed.inject(RouterExtensionService);
router = TestBed.get(Router); router = TestBed.inject(Router);
router.config = [ router.config = [
{ path: 'login', component: {} as Type<any> }, { path: 'login', component: {} as Type<any> },
{ path: 'settings', component: {} as Type<any> }, { path: 'settings', component: {} as Type<any> },

View File

@ -34,11 +34,10 @@ export class Breadcrumb extends Component {
} }
async getAllItems(): Promise<string[]> { async getAllItems(): Promise<string[]> {
const items: string[] = await this.items.map(async (elem) => { return this.items.map(async (elem) => {
const str = await elem.getText(); const str = await elem.getText();
return str.split('\nchevron_right')[0]; return str.split('\nchevron_right')[0];
}); });
return items;
} }
async clickItem(name: string): Promise<void> { async clickItem(name: string): Promise<void> {

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { by, browser } from 'protractor'; import { browser, by } from 'protractor';
import { Component } from '../component'; import { Component } from '../component';
import { waitForPresence, waitForStaleness } from '../../utilities/utils'; import { waitForPresence, waitForStaleness } from '../../utilities/utils';
@ -57,9 +57,8 @@ export class DropDownBreadcrumb extends Component {
} }
async getPathItems(): Promise<string[]> { async getPathItems(): Promise<string[]> {
const items: string[] = await this.pathItems.map(async (elem) => { return this.pathItems.map(async (elem) => {
return elem.getText(); return elem.getText();
}); });
return items;
} }
} }

View File

@ -45,7 +45,7 @@ export abstract class Component {
return root.all(by.css(css)); return root.all(by.css(css));
} }
constructor(selector: string, ancestor?: string) { protected constructor(selector: string, ancestor?: string) {
const locator = selector; const locator = selector;
this.component = ancestor ? browser.$$(ancestor).first().$$(locator).first() : browser.$$(locator).first(); this.component = ancestor ? browser.$$(ancestor).first().$$(locator).first() : browser.$$(locator).first();

View File

@ -23,12 +23,12 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { ElementFinder, ElementArrayFinder, by, browser, protractor } from 'protractor'; import { browser, by, ElementArrayFinder, ElementFinder, protractor } from 'protractor';
import { Logger } from '@alfresco/adf-testing'; import { Logger } from '@alfresco/adf-testing';
import { BROWSER_WAIT_TIMEOUT } from '../../configs'; import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Component } from '../component'; import { Component } from '../component';
import { Menu } from '../menu/menu'; import { Menu } from '../menu/menu';
import { Utils, waitForPresence, waitForClickable } from '../../utilities/utils'; import { Utils, waitForClickable, waitForPresence } from '../../utilities/utils';
export class DataTable extends Component { export class DataTable extends Component {
private static selectors = { private static selectors = {
@ -146,10 +146,9 @@ export class DataTable extends Component {
} }
async getSelectedRowsNames(): Promise<string[]> { async getSelectedRowsNames(): Promise<string[]> {
const rowsText: string[] = await this.getSelectedRows().map((row) => { return this.getSelectedRows().map((row) => {
return row.element(by.css('.adf-datatable-cell[title="Name"]')).getText(); return row.element(by.css('.adf-datatable-cell[title="Name"]')).getText();
}); });
return rowsText;
} }
async getSelectedRowsCount(): Promise<number> { async getSelectedRowsCount(): Promise<number> {
@ -358,10 +357,9 @@ export class DataTable extends Component {
async getCellsContainingName(name: string): Promise<string[]> { async getCellsContainingName(name: string): Promise<string[]> {
const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name)); const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name));
const cellsText: string[] = await rows.map(async (cell) => { return rows.map(async (cell) => {
return cell.getText(); return cell.getText();
}); });
return cellsText;
} }
async hasContextMenu(): Promise<boolean> { async hasContextMenu(): Promise<boolean> {
@ -378,12 +376,11 @@ export class DataTable extends Component {
} }
private async getEntireDataTableText(): Promise<string[]> { private async getEntireDataTableText(): Promise<string[]> {
const text: string[] = await this.getRows().map((row) => { return this.getRows().map((row) => {
return row.all(by.css(DataTable.selectors.cell)).map(async (cell) => { return row.all(by.css(DataTable.selectors.cell)).map(async (cell) => {
return cell.getText(); return cell.getText();
}); });
}); });
return text;
} }
async getSitesNameAndVisibility(): Promise<any> { async getSitesNameAndVisibility(): Promise<any> {

View File

@ -27,7 +27,7 @@ import { ElementFinder, by, browser, Locator } from 'protractor';
import { isPresentAndDisplayed, waitForPresence, waitForVisibility, waitForStaleness } from '../../utilities/utils'; import { isPresentAndDisplayed, waitForPresence, waitForVisibility, waitForStaleness } from '../../utilities/utils';
export abstract class GenericDialog { export abstract class GenericDialog {
constructor(private rootCssSelector?: string) {} protected constructor(private rootCssSelector?: string) {}
get rootElem(): ElementFinder { get rootElem(): ElementFinder {
return browser.element(by.css(this.rootCssSelector)); return browser.element(by.css(this.rootCssSelector));

View File

@ -117,11 +117,10 @@ export class Menu extends Component {
} }
async getMenuItems(): Promise<string[]> { async getMenuItems(): Promise<string[]> {
const items: string[] = await this.items.map(async (elem) => { return this.items.map(async (elem) => {
const span = elem.element(by.css('span')); const span = elem.element(by.css('span'));
return span.getText(); return span.getText();
}); });
return items;
} }
async clickNthItem(nth: number): Promise<void> { async clickNthItem(nth: number): Promise<void> {
@ -194,8 +193,7 @@ export class Menu extends Component {
async isMenuItemDisabled(title: string): Promise<string | null> { async isMenuItemDisabled(title: string): Promise<string | null> {
try { try {
const item = this.getItemByLabel(title); const item = this.getItemByLabel(title);
const disabled = await item.getAttribute('disabled'); return await item.getAttribute('disabled');
return disabled;
} catch (error) { } catch (error) {
Logger.error('----- isMenuItemDisabled catch: ', error); Logger.error('----- isMenuItemDisabled catch: ', error);
return null; return null;

View File

@ -79,8 +79,7 @@ export class CreatedDateFilter extends GenericFilterPanel {
async getFromValue(): Promise<string> { async getFromValue(): Promise<string> {
try { try {
const value = await this.fromInput.getAttribute('value'); return await this.fromInput.getAttribute('value');
return value;
} catch (error) { } catch (error) {
return ''; return '';
} }
@ -88,8 +87,7 @@ export class CreatedDateFilter extends GenericFilterPanel {
async getFromError(): Promise<string> { async getFromError(): Promise<string> {
try { try {
const error = await this.fromFieldError.getText(); return await this.fromFieldError.getText();
return error;
} catch (err) { } catch (err) {
return ''; return '';
} }
@ -97,8 +95,7 @@ export class CreatedDateFilter extends GenericFilterPanel {
async getToValue(): Promise<string> { async getToValue(): Promise<string> {
try { try {
const value = await this.toInput.getAttribute('value'); return await this.toInput.getAttribute('value');
return value;
} catch (err) { } catch (err) {
return ''; return '';
} }
@ -106,8 +103,7 @@ export class CreatedDateFilter extends GenericFilterPanel {
async getToError(): Promise<string> { async getToError(): Promise<string> {
try { try {
const error = await this.toFieldError.getText(); return await this.toFieldError.getText();
return error;
} catch (err) { } catch (err) {
return ''; return '';
} }

View File

@ -52,17 +52,15 @@ export class FacetFilter extends GenericFilterPanel {
} }
async getFiltersValues(): Promise<string[]> { async getFiltersValues(): Promise<string[]> {
const list: string[] = await this.facets.map((option) => { return this.facets.map((option) => {
return option.getText(); return option.getText();
}); });
return list;
} }
async getFiltersCheckedValues(): Promise<string[]> { async getFiltersCheckedValues(): Promise<string[]> {
const list: string[] = await this.selectedFacets.map((option) => { return this.selectedFacets.map((option) => {
return option.getText(); return option.getText();
}); });
return list;
} }
async resetPanel(): Promise<void> { async resetPanel(): Promise<void> {

View File

@ -36,17 +36,15 @@ export class SizeFilter extends GenericFilterPanel {
clearButton: ElementFinder = this.panel.element(by.cssContainingText('.adf-facet-buttons button', 'Clear all')); clearButton: ElementFinder = this.panel.element(by.cssContainingText('.adf-facet-buttons button', 'Clear all'));
async getFiltersValues(): Promise<string[]> { async getFiltersValues(): Promise<string[]> {
const list: string[] = await this.facets.map((option) => { return this.facets.map((option) => {
return option.getText(); return option.getText();
}); });
return list;
} }
async getFiltersCheckedValues(): Promise<string[]> { async getFiltersCheckedValues(): Promise<string[]> {
const list: string[] = await this.selectedFacets.map((option) => { return this.selectedFacets.map((option) => {
return option.getText(); return option.getText();
}); });
return list;
} }
async resetPanel(): Promise<void> { async resetPanel(): Promise<void> {

View File

@ -78,10 +78,9 @@ export class SearchSortingPicker extends Component {
} }
async getSortByOptionsList(): Promise<string[]> { async getSortByOptionsList(): Promise<string[]> {
const list: string[] = await this.sortByList.map(async (option) => { return this.sortByList.map(async (option) => {
return option.getText(); return option.getText();
}); });
return list;
} }
async sortBy(option: SortByType): Promise<void> { async sortBy(option: SortByType): Promise<void> {

View File

@ -46,10 +46,9 @@ export class SearchResultsPage extends BrowsingPage {
async getResultsChipsValues(): Promise<string[]> { async getResultsChipsValues(): Promise<string[]> {
const chips = this.chipList.all(by.css('.mat-chip')); const chips = this.chipList.all(by.css('.mat-chip'));
const chipsValues: string[] = await chips.map(async (elem) => { return chips.map(async (elem) => {
return (await elem.getText()).replace(`\ncancel`, ''); return (await elem.getText()).replace(`\ncancel`, '');
}); });
return chipsValues;
} }
async removeChip(chipName: string): Promise<void> { async removeChip(chipName: string): Promise<void> {

View File

@ -128,7 +128,7 @@ export class FavoritesApi extends RepoApi {
} }
async isFavoriteWithRetry(nodeId: string, data: { expect: boolean }) { async isFavoriteWithRetry(nodeId: string, data: { expect: boolean }) {
let isFavorite: boolean; let isFavorite = false;
try { try {
const favorite = async () => { const favorite = async () => {
isFavorite = await this.isFavorite(nodeId); isFavorite = await this.isFavorite(nodeId);

View File

@ -49,8 +49,7 @@ export class NodesApi extends RepoApi {
async getNodeById(id: string): Promise<NodeEntry | null> { async getNodeById(id: string): Promise<NodeEntry | null> {
try { try {
await this.apiAuth(); await this.apiAuth();
const node = await this.nodesApi.getNode(id); return await this.nodesApi.getNode(id);
return node;
} catch (error) { } catch (error) {
this.handleError(`${this.constructor.name} ${this.getNodeById.name}`, error); this.handleError(`${this.constructor.name} ${this.getNodeById.name}`, error);
return null; return null;
@ -525,7 +524,7 @@ export class NodesApi extends RepoApi {
expect: expect, expect: expect,
retry: 5 retry: 5
}; };
let isLocked: boolean; let isLocked = false;
try { try {
const locked = async () => { const locked = async () => {
isLocked = (await this.getLockType(nodeId)) === 'WRITE_LOCK'; isLocked = (await this.getLockType(nodeId)) === 'WRITE_LOCK';

View File

@ -30,7 +30,7 @@ import { Logger } from '@alfresco/adf-testing';
export abstract class RepoApi { export abstract class RepoApi {
alfrescoJsApi = new AlfrescoApi(); alfrescoJsApi = new AlfrescoApi();
constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) { protected constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) {
this.alfrescoJsApi.setConfig(browser.params.config); this.alfrescoJsApi.setConfig(browser.params.config);
} }

View File

@ -28,13 +28,13 @@ const MAX_RETRIES = process.env.MAX_RETRIES || 1;
function rmDir(dirPath) { function rmDir(dirPath) {
try { try {
var files = fs.readdirSync(dirPath); const files = fs.readdirSync(dirPath);
} catch (e) { } catch (e) {
return; return;
} }
if (files.length > 0) if (files.length > 0)
for (var i = 0; i < files.length; i++) { for (let i = 0; i < files.length; i++) {
var filePath = dirPath + '/' + files[i]; const filePath = dirPath + '/' + files[i];
if (fs.statSync(filePath).isFile()) fs.unlinkSync(filePath); if (fs.statSync(filePath).isFile()) fs.unlinkSync(filePath);
else rmDir(filePath); else rmDir(filePath);
} }

View File

@ -7,7 +7,7 @@
*/ */
import { ParamType } from './params'; import { ParamType } from './params';
import { BaseParamOptions, CommanderOptionParams, BaseParam } from './base-param'; import { CommanderOptionParams, BaseParam } from './base-param';
export class BooleanParam extends BaseParam { export class BooleanParam extends BaseParam {
protected type = ParamType.confirm; protected type = ParamType.confirm;

View File

@ -7,7 +7,7 @@
*/ */
import { ParamType } from './params'; import { ParamType } from './params';
import { BaseParam, BaseParamOptions, CommanderOptionParams } from './base-param'; import { BaseParam, CommanderOptionParams } from './base-param';
export class InputParam extends BaseParam { export class InputParam extends BaseParam {
protected type = ParamType.input; protected type = ParamType.input;

View File

@ -36,6 +36,7 @@ import { SetCurrentFolderAction, isAdmin, AppStore, UploadFileVersionAction } fr
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { debounceTime, takeUntil } from 'rxjs/operators'; import { debounceTime, takeUntil } from 'rxjs/operators';
import { FilterSearch, ShareDataRow } from '@alfresco/adf-content-services'; import { FilterSearch, ShareDataRow } from '@alfresco/adf-content-services';
import { DocumentListPresetRef } from '@alfresco/adf-extensions';
@Component({ @Component({
templateUrl: './files.component.html' templateUrl: './files.component.html'
@ -49,7 +50,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
private nodePath: PathElement[]; private nodePath: PathElement[];
columns: any[] = []; columns: DocumentListPresetRef[] = [];
constructor( constructor(
private router: Router, private router: Router,

View File

@ -28,6 +28,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AppTestingModule } from '../../../testing/app-testing.module'; import { AppTestingModule } from '../../../testing/app-testing.module';
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { NodePermissionService } from '@alfresco/aca-shared'; import { NodePermissionService } from '@alfresco/aca-shared';
import { Node } from '@alfresco/js-api';
describe('CommentsTabComponent', () => { describe('CommentsTabComponent', () => {
let component: CommentsTabComponent; let component: CommentsTabComponent;
@ -66,44 +67,40 @@ describe('CommentsTabComponent', () => {
}); });
it('should return [false] if node selected is neither file or folder', () => { it('should return [false] if node selected is neither file or folder', () => {
const testNode: any = { component.node = {
id: 'test-node-id', id: 'test-node-id',
isFile: false, isFile: false,
isFolder: false isFolder: false
}; } as Node;
component.node = testNode;
expect(component.canUpdateNode).toBe(false); expect(component.canUpdateNode).toBe(false);
}); });
it('should return [false] if node selected is a locked file', () => { it('should return [false] if node selected is a locked file', () => {
const testNode: any = { component.node = {
id: 'test-node-id', id: 'test-node-id',
isFile: true, isFile: true,
isFolder: false, isFolder: false,
isLocked: true isLocked: true
}; } as Node;
component.node = testNode;
expect(component.canUpdateNode).toBe(false); expect(component.canUpdateNode).toBe(false);
}); });
it('should check [update] permission if node selected is a not locked file', () => { it('should check [update] permission if node selected is a not locked file', () => {
const testNode: any = { component.node = {
id: 'test-node-id', id: 'test-node-id',
isFile: true, isFile: true,
isFolder: false isFolder: false
}; } as Node;
component.node = testNode;
expect(component.canUpdateNode).toBe(true); expect(component.canUpdateNode).toBe(true);
expect(checked).toContain('update'); expect(checked).toContain('update');
}); });
it('should check [update] permission if node selected is a folder', () => { it('should check [update] permission if node selected is a folder', () => {
const testNode: any = { component.node = {
id: 'test-node-id', id: 'test-node-id',
isFile: false, isFile: false,
isFolder: true isFolder: true
}; } as Node;
component.node = testNode;
expect(component.canUpdateNode).toBe(true); expect(component.canUpdateNode).toBe(true);
expect(checked).toContain('update'); expect(checked).toContain('update');
}); });

View File

@ -70,7 +70,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
protected subscriptions: Subscription[] = []; protected subscriptions: Subscription[] = [];
constructor(protected store: Store<AppStore>, protected extensions: AppExtensionService, protected content: ContentManagementService) {} protected constructor(protected store: Store<AppStore>, protected extensions: AppExtensionService, protected content: ContentManagementService) {}
ngOnInit() { ngOnInit() {
this.sharedPreviewUrl$ = this.store.select(getSharedUrl); this.sharedPreviewUrl$ = this.store.select(getSharedUrl);

View File

@ -177,10 +177,10 @@ export class PreviewComponent extends PageComponent implements OnInit, OnDestroy
this.nodeId = this.node.id; this.nodeId = this.node.id;
return; return;
} }
this.router.navigate([this.previewLocation, id]); await this.router.navigate([this.previewLocation, id]);
} catch (err) { } catch (err) {
if (!err || err.status !== 401) { if (!err || err.status !== 401) {
this.router.navigate([this.previewLocation, id]); await this.router.navigate([this.previewLocation, id]);
} }
} }
} }

View File

@ -31,7 +31,7 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { forkJoin, from, of } from 'rxjs'; import { forkJoin, from, of } from 'rxjs';
import { catchError, flatMap } from 'rxjs/operators'; import { catchError, mergeMap } from 'rxjs/operators';
import { AppExtensionService } from '@alfresco/aca-shared'; import { AppExtensionService } from '@alfresco/aca-shared';
@Component({ @Component({
@ -55,8 +55,10 @@ export class SharedLinkViewComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.route.params this.route.params
.pipe( .pipe(
flatMap((params) => mergeMap((params) =>
forkJoin(from(this.alfrescoApiService.sharedLinksApi.getSharedLink(params.id)), of(params.id)).pipe(catchError(() => of([null, params.id]))) forkJoin([from(this.alfrescoApiService.sharedLinksApi.getSharedLink(params.id)), of(params.id)]).pipe(
catchError(() => of([null, params.id]))
)
) )
) )
.subscribe(([sharedEntry, sharedId]: [SharedLinkEntry, string]) => { .subscribe(([sharedEntry, sharedId]: [SharedLinkEntry, string]) => {

View File

@ -56,7 +56,10 @@ describe('ButtonMenuComponent', () => {
it('should render action item', () => { it('should render action item', () => {
component.item = { component.item = {
id: 'test-action-button', id: 'test-action-button',
url: 'dummy' url: 'dummy',
icon: null,
title: null,
route: null
}; };
fixture.detectChanges(); fixture.detectChanges();
@ -68,16 +71,23 @@ describe('ButtonMenuComponent', () => {
it('should render action item with children', () => { it('should render action item with children', () => {
component.item = { component.item = {
id: 'test-action-button', id: 'test-action-button',
icon: null,
title: null,
route: null,
children: [ children: [
{ {
id: 'child-1', id: 'child-1',
title: 'child-1', title: 'child-1',
url: 'dummy' url: 'dummy',
icon: null,
route: null
}, },
{ {
id: 'child-2', id: 'child-2',
title: 'child-2', title: 'child-2',
url: 'dummy' url: 'dummy',
icon: null,
route: null
} }
] ]
}; };

View File

@ -25,6 +25,7 @@
import { Component, Input, ViewEncapsulation, OnInit, ChangeDetectorRef } from '@angular/core'; import { Component, Input, ViewEncapsulation, OnInit, ChangeDetectorRef } from '@angular/core';
import { OverlayContainer } from '@angular/cdk/overlay'; import { OverlayContainer } from '@angular/cdk/overlay';
import { NavBarLinkRef } from '@alfresco/adf-extensions';
@Component({ @Component({
selector: 'app-button-menu', selector: 'app-button-menu',
@ -33,7 +34,8 @@ import { OverlayContainer } from '@angular/cdk/overlay';
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class ButtonMenuComponent implements OnInit { export class ButtonMenuComponent implements OnInit {
@Input() item; @Input()
item: NavBarLinkRef;
constructor(private cd: ChangeDetectorRef, private overlayContainer: OverlayContainer) { constructor(private cd: ChangeDetectorRef, private overlayContainer: OverlayContainer) {
this.overlayContainer.getContainerElement().classList.add('aca-menu-panel'); this.overlayContainer.getContainerElement().classList.add('aca-menu-panel');

View File

@ -52,7 +52,7 @@ import { SharedLinkEntry } from '@alfresco/js-api';
host: { class: 'app-view-node' } host: { class: 'app-view-node' }
}) })
export class ViewNodeComponent { export class ViewNodeComponent {
@Input() data: any; @Input() data: { title?: string; menuButton?: boolean; iconButton?: boolean };
constructor(private store: Store<AppStore>, private router: Router) {} constructor(private store: Store<AppStore>, private router: Router) {}

View File

@ -102,7 +102,7 @@ describe('ContentManagementService', () => {
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
subject.next('OPERATION.SUCCES.CONTENT.COPY'); subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR'); expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR');
@ -116,7 +116,7 @@ describe('ContentManagementService', () => {
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
subject.next('OPERATION.SUCCES.CONTENT.COPY'); subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL'); expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL');
@ -130,7 +130,7 @@ describe('ContentManagementService', () => {
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
subject.next('OPERATION.SUCCES.CONTENT.COPY'); subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR'); expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR');
@ -148,7 +148,7 @@ describe('ContentManagementService', () => {
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
subject.next('OPERATION.SUCCES.CONTENT.COPY'); subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL'); expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL');
@ -166,7 +166,7 @@ describe('ContentManagementService', () => {
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
subject.next('OPERATION.SUCCES.CONTENT.COPY'); subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_PLURAL'); expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_PLURAL');
@ -180,7 +180,7 @@ describe('ContentManagementService', () => {
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
subject.next('OPERATION.SUCCES.CONTENT.COPY'); subject.next('OPERATION.SUCCESS.CONTENT.COPY');
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_SINGULAR'); expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_SINGULAR');
@ -242,7 +242,7 @@ describe('ContentManagementService', () => {
const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }];
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.copyNodes(null).next('OPERATION.SUCCES.CONTENT.COPY'); nodeActions.copyNodes(null).next('OPERATION.SUCCESS.CONTENT.COPY');
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
@ -279,7 +279,7 @@ describe('ContentManagementService', () => {
]; ];
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.copyNodes(null).next('OPERATION.SUCCES.CONTENT.COPY'); nodeActions.copyNodes(null).next('OPERATION.SUCCESS.CONTENT.COPY');
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
@ -299,7 +299,7 @@ describe('ContentManagementService', () => {
const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }];
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.copyNodes(null).next('OPERATION.SUCCES.CONTENT.COPY'); nodeActions.copyNodes(null).next('OPERATION.SUCCESS.CONTENT.COPY');
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
@ -314,7 +314,7 @@ describe('ContentManagementService', () => {
const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }];
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.copyNodes(null).next('OPERATION.SUCCES.CONTENT.COPY'); nodeActions.copyNodes(null).next('OPERATION.SUCCESS.CONTENT.COPY');
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
@ -329,7 +329,7 @@ describe('ContentManagementService', () => {
const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }];
store.dispatch(new CopyNodesAction(selection)); store.dispatch(new CopyNodesAction(selection));
nodeActions.copyNodes(null).next('OPERATION.SUCCES.CONTENT.COPY'); nodeActions.copyNodes(null).next('OPERATION.SUCCESS.CONTENT.COPY');
nodeActions.contentCopied.next(createdItems); nodeActions.contentCopied.next(createdItems);
expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(nodeActions.copyNodes).toHaveBeenCalled();
@ -375,7 +375,7 @@ describe('ContentManagementService', () => {
const selection: any = node; const selection: any = node;
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(moveResponse); nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();
@ -396,7 +396,7 @@ describe('ContentManagementService', () => {
const selection: any = nodes; const selection: any = nodes;
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(moveResponse); nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();
@ -414,10 +414,8 @@ describe('ContentManagementService', () => {
spyOn(nodeActions, 'moveNodes').and.returnValue(subject); spyOn(nodeActions, 'moveNodes').and.returnValue(subject);
spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse); spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse);
const selection = nodes; store.dispatch(new MoveNodesAction(nodes));
nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE');
nodeActions.contentMoved.next(moveResponse); nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();
@ -435,10 +433,8 @@ describe('ContentManagementService', () => {
spyOn(nodeActions, 'moveNodes').and.returnValue(subject); spyOn(nodeActions, 'moveNodes').and.returnValue(subject);
spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse); spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse);
const selection = nodes; store.dispatch(new MoveNodesAction(nodes));
nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE');
nodeActions.contentMoved.next(moveResponse); nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();
@ -457,7 +453,7 @@ describe('ContentManagementService', () => {
spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse); spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse);
store.dispatch(new MoveNodesAction(nodes)); store.dispatch(new MoveNodesAction(nodes));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(moveResponse); nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();
@ -476,7 +472,7 @@ describe('ContentManagementService', () => {
spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse); spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse);
store.dispatch(new MoveNodesAction(nodes)); store.dispatch(new MoveNodesAction(nodes));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(moveResponse); nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();
@ -546,7 +542,7 @@ describe('ContentManagementService', () => {
spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse); spyOn(nodeActions, 'processResponse').and.returnValue(moveResponse);
store.dispatch(new MoveNodesAction(nodes)); store.dispatch(new MoveNodesAction(nodes));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(moveResponse); nodeActions.contentMoved.next(moveResponse);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();
@ -592,7 +588,7 @@ describe('ContentManagementService', () => {
spyOn(nodeActions, 'moveNodeAction').and.returnValue(of({})); spyOn(nodeActions, 'moveNodeAction').and.returnValue(of({}));
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
const movedItems = { const movedItems = {
failed: [], failed: [],
partiallySucceeded: [], partiallySucceeded: [],
@ -625,7 +621,7 @@ describe('ContentManagementService', () => {
}; };
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(movedItems); nodeActions.contentMoved.next(movedItems);
expect(nodeActions.moveNodeAction).toHaveBeenCalledWith(node.entry, initialParent); expect(nodeActions.moveNodeAction).toHaveBeenCalledWith(node.entry, initialParent);
@ -657,7 +653,7 @@ describe('ContentManagementService', () => {
}; };
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(movedItems); nodeActions.contentMoved.next(movedItems);
expect(contentApi.restoreNode).toHaveBeenCalled(); expect(contentApi.restoreNode).toHaveBeenCalled();
@ -699,7 +695,7 @@ describe('ContentManagementService', () => {
}; };
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(movedItems); nodeActions.contentMoved.next(movedItems);
expect(contentApi.restoreNode).toHaveBeenCalled(); expect(contentApi.restoreNode).toHaveBeenCalled();
@ -731,7 +727,7 @@ describe('ContentManagementService', () => {
}; };
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(movedItems); nodeActions.contentMoved.next(movedItems);
expect(contentApi.restoreNode).toHaveBeenCalled(); expect(contentApi.restoreNode).toHaveBeenCalled();
@ -763,7 +759,7 @@ describe('ContentManagementService', () => {
}; };
store.dispatch(new MoveNodesAction(selection)); store.dispatch(new MoveNodesAction(selection));
nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.moveNodes(null).next('OPERATION.SUCCESS.CONTENT.MOVE');
nodeActions.contentMoved.next(movedItems); nodeActions.contentMoved.next(movedItems);
expect(nodeActions.moveNodes).toHaveBeenCalled(); expect(nodeActions.moveNodes).toHaveBeenCalled();

View File

@ -59,7 +59,7 @@ import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar'; import { MatSnackBar } from '@angular/material/snack-bar';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { forkJoin, Observable, of, Subject, zip } from 'rxjs'; import { forkJoin, Observable, of, Subject, zip } from 'rxjs';
import { catchError, flatMap, map, mergeMap, take, tap } from 'rxjs/operators'; import { catchError, map, mergeMap, take, tap } from 'rxjs/operators';
import { NodePermissionsDialogComponent } from '../components/permissions/permission-dialog/node-permissions.dialog'; import { NodePermissionsDialogComponent } from '../components/permissions/permission-dialog/node-permissions.dialog';
import { NodeVersionsDialogComponent } from '../dialogs/node-versions/node-versions.dialog'; import { NodeVersionsDialogComponent } from '../dialogs/node-versions/node-versions.dialog';
import { NodeActionsService } from './node-actions.service'; import { NodeActionsService } from './node-actions.service';
@ -1031,7 +1031,7 @@ export class ContentManagementService {
getNodeInfo(): Observable<MinimalNodeEntryEntity> { getNodeInfo(): Observable<MinimalNodeEntryEntity> {
return this.store.select(getAppSelection).pipe( return this.store.select(getAppSelection).pipe(
take(1), take(1),
flatMap(({ file }) => { mergeMap(({ file }) => {
const id = (file as any).entry.nodeId || (file as any).entry.guid; const id = (file as any).entry.nodeId || (file as any).entry.guid;
if (!id) { if (!id) {
return of(file.entry); return of(file.entry);

View File

@ -356,7 +356,7 @@ describe('NodeActionsService', () => {
const spyOnDestinationPicker = spyOn(service, 'getContentNodeSelection').and.callThrough(); const spyOnDestinationPicker = spyOn(service, 'getContentNodeSelection').and.callThrough();
spyOn(service, 'getEntryParentId').and.returnValue('parent-id'); spyOn(service, 'getEntryParentId').and.returnValue('parent-id');
let dialogData: any; let dialogData = null;
const spyOnDialog = spyOn(dialog, 'open').and.callFake((_contentNodeSelectorComponent: any, data: any) => { const spyOnDialog = spyOn(dialog, 'open').and.callFake((_contentNodeSelectorComponent: any, data: any) => {
dialogData = data; dialogData = data;
return { componentInstance: {} } as MatDialogRef<any>; return { componentInstance: {} } as MatDialogRef<any>;

View File

@ -118,7 +118,7 @@ export class NodeActionsService {
} }
action$.subscribe((newContent) => { action$.subscribe((newContent) => {
observable.next(`OPERATION.SUCCES.${type.toUpperCase()}.${action.toUpperCase()}`); observable.next(`OPERATION.SUCCESS.${type.toUpperCase()}.${action.toUpperCase()}`);
const processedData = this.processResponse(newContent); const processedData = this.processResponse(newContent);
if (action === BatchOperationType.copy) { if (action === BatchOperationType.copy) {

View File

@ -62,7 +62,7 @@ export class AppEffects {
}) })
); );
private redirectToLogin() { private redirectToLogin(): Promise<boolean> {
this.router.navigate(['login']); return this.router.navigate(['login']);
} }
} }

View File

@ -212,7 +212,7 @@ function updateSelectedNodes(state: AppState, action: SetSelectedNodesAction): A
if (nodes.length === 1) { if (nodes.length === 1) {
file = nodes.find((entity: any) => { file = nodes.find((entity: any) => {
// workaround Shared // workaround Shared
return entity.entry.isFile || entity.entry.nodeId || entity.entry.sharedByUser ? true : false; return !!(entity.entry.isFile || entity.entry.nodeId || entity.entry.sharedByUser);
}); });
folder = nodes.find((entity: any) => entity.entry.isFolder); folder = nodes.find((entity: any) => entity.entry.isFolder);
} }
@ -266,7 +266,7 @@ function handleSettingsUpdate(state: AppState, action: SetSettingsParameterActio
const { payload } = action; const { payload } = action;
if (payload.name === 'languagePicker') { if (payload.name === 'languagePicker') {
newState.languagePicker = payload.value ? true : false; newState.languagePicker = !!payload.value;
} }
return newState; return newState;
} }

2
src/typings.d.ts vendored
View File

@ -28,5 +28,3 @@ declare var module: NodeModule;
interface NodeModule { interface NodeModule {
id: string; id: string;
} }
interface WebKitFileEntry {}