mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[AAE-7101] - Introduced Eslint to ACA and added some fix to avoid errors (#2424)
* Conversion to ESlint * Fixed ESLINT for ACA * [AAE-6638] - typo in eslint file * [AAE-6638] - attempt to fix problem on linting * Check caching to improve lint speed * Improved eslint for content-app * Added new cache * Remove cache file * Removed eslintcache * Attempt to make eslint run on travis * Slow ng lint on travis * Fixed eslint error
This commit is contained in:
@@ -122,9 +122,7 @@ describe('ExtensionsDataLoaderGuard', () => {
|
||||
it('should call canActivate only once', () => {
|
||||
const subject1 = new Subject<true>();
|
||||
const extensionLoaders = {
|
||||
fct1: function () {
|
||||
return subject1.asObservable();
|
||||
}
|
||||
fct1: () => subject1.asObservable()
|
||||
};
|
||||
const extensionLoaderSpy = spyOn(extensionLoaders, 'fct1').and.callThrough();
|
||||
const guard = new ExtensionsDataLoaderGuard([extensionLoaders.fct1]);
|
||||
|
@@ -30,9 +30,7 @@ import { tap, map, catchError } from 'rxjs/operators';
|
||||
|
||||
export type ExtensionLoaderCallback = (route: ActivatedRouteSnapshot) => Observable<boolean>;
|
||||
|
||||
export function DefaultExtensionLoaderFactory() {
|
||||
return [];
|
||||
}
|
||||
export const DefaultExtensionLoaderFactory = () => [];
|
||||
|
||||
export const EXTENSION_DATA_LOADERS = new InjectionToken<ExtensionLoaderCallback[]>('EXTENSION_DATA_LOADERS', {
|
||||
providedIn: 'root',
|
||||
@@ -64,9 +62,9 @@ export class ExtensionsDataLoaderGuard implements CanActivate {
|
||||
map(() => true),
|
||||
tap(() => (this.invoked = true)),
|
||||
catchError((e) => {
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Some of the extension data loader guards has been errored.');
|
||||
// tslint:disable-next-line
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(e);
|
||||
return of(true);
|
||||
})
|
||||
|
@@ -37,7 +37,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
|
||||
private execute$: Subject<any> = new Subject();
|
||||
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
||||
|
||||
// tslint:disable-next-line:no-input-rename
|
||||
// eslint-disable-next-line
|
||||
@Input('acaContextEnable')
|
||||
enabled = true;
|
||||
|
||||
@@ -93,7 +93,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
|
||||
if (el.classList.contains(className)) {
|
||||
return el;
|
||||
}
|
||||
// tslint:disable-next-line:curly
|
||||
// eslint-disable-next-line curly
|
||||
while ((el = el.parentElement) && !el.classList.contains(className));
|
||||
return el;
|
||||
}
|
||||
|
@@ -35,9 +35,7 @@ export class AlfrescoOfficeExtensionService {
|
||||
this.appConfigService.onLoad
|
||||
.pipe(
|
||||
take(1),
|
||||
map((appConfig) => {
|
||||
return appConfig.plugins && appConfig.plugins.aosPlugin;
|
||||
})
|
||||
map((appConfig) => appConfig.plugins && appConfig.plugins.aosPlugin)
|
||||
)
|
||||
.subscribe((aosPlugin) => {
|
||||
if (aosPlugin) {
|
||||
|
@@ -218,67 +218,65 @@ export class AppExtensionService implements RuleContext {
|
||||
getApplicationNavigation(elements): Array<NavBarGroupRef> {
|
||||
return elements
|
||||
.filter((group) => this.filterVisible(group))
|
||||
.map((group) => {
|
||||
return {
|
||||
...group,
|
||||
items: (group.items || [])
|
||||
.filter((entry) => !entry.disabled)
|
||||
.filter((item) => this.filterVisible(item))
|
||||
.sort(sortByOrder)
|
||||
.map((item) => {
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children = item.children
|
||||
.filter((entry) => !entry.disabled)
|
||||
.filter((child) => this.filterVisible(child))
|
||||
.sort(sortByOrder)
|
||||
.map((child) => {
|
||||
if (child.component) {
|
||||
return {
|
||||
...child
|
||||
};
|
||||
}
|
||||
|
||||
if (!child.click) {
|
||||
const childRouteRef = this.extensions.getRouteById(child.route);
|
||||
const childUrl = `/${childRouteRef ? childRouteRef.path : child.route}`;
|
||||
return {
|
||||
...child,
|
||||
url: childUrl
|
||||
};
|
||||
}
|
||||
.map((group) => ({
|
||||
...group,
|
||||
items: (group.items || [])
|
||||
.filter((entry) => !entry.disabled)
|
||||
.filter((item) => this.filterVisible(item))
|
||||
.sort(sortByOrder)
|
||||
.map((item) => {
|
||||
if (item.children && item.children.length > 0) {
|
||||
item.children = item.children
|
||||
.filter((entry) => !entry.disabled)
|
||||
.filter((child) => this.filterVisible(child))
|
||||
.sort(sortByOrder)
|
||||
.map((child) => {
|
||||
if (child.component) {
|
||||
return {
|
||||
...child
|
||||
};
|
||||
}
|
||||
|
||||
if (!child.click) {
|
||||
const childRouteRef = this.extensions.getRouteById(child.route);
|
||||
const childUrl = `/${childRouteRef ? childRouteRef.path : child.route}`;
|
||||
return {
|
||||
...child,
|
||||
action: child.click
|
||||
url: childUrl
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
...item
|
||||
};
|
||||
}
|
||||
|
||||
if (item.component) {
|
||||
return { ...item };
|
||||
}
|
||||
|
||||
if (!item.click) {
|
||||
const routeRef = this.extensions.getRouteById(item.route);
|
||||
const url = `/${routeRef ? routeRef.path : item.route}`;
|
||||
return {
|
||||
...item,
|
||||
url
|
||||
};
|
||||
}
|
||||
return {
|
||||
...child,
|
||||
action: child.click
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
...item,
|
||||
action: item.click
|
||||
...item
|
||||
};
|
||||
})
|
||||
.reduce(reduceEmptyMenus, [])
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (item.component) {
|
||||
return { ...item };
|
||||
}
|
||||
|
||||
if (!item.click) {
|
||||
const routeRef = this.extensions.getRouteById(item.route);
|
||||
const url = `/${routeRef ? routeRef.path : item.route}`;
|
||||
return {
|
||||
...item,
|
||||
url
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...item,
|
||||
action: item.click
|
||||
};
|
||||
})
|
||||
.reduce(reduceEmptyMenus, [])
|
||||
}));
|
||||
}
|
||||
|
||||
loadContentMetadata(config: ExtensionConfig): any {
|
||||
|
@@ -124,6 +124,7 @@ export class ContentApiService {
|
||||
|
||||
/**
|
||||
* Moves a node to the trashcan.
|
||||
*
|
||||
* @param nodeId ID of the target node
|
||||
* @param options Optional parameters supported by JS-API
|
||||
* @returns Empty result that notifies when the deletion is complete
|
||||
@@ -134,6 +135,7 @@ export class ContentApiService {
|
||||
|
||||
/**
|
||||
* Gets the stored information about a node.
|
||||
*
|
||||
* @param nodeId ID of the target node
|
||||
* @param options Optional parameters supported by JS-API
|
||||
* @returns Node information
|
||||
@@ -170,6 +172,7 @@ export class ContentApiService {
|
||||
|
||||
/**
|
||||
* Gets the items contained in a folder node.
|
||||
*
|
||||
* @param nodeId ID of the target node
|
||||
* @param options Optional parameters supported by JS-API
|
||||
* @returns List of child items from the folder
|
||||
@@ -208,6 +211,7 @@ export class ContentApiService {
|
||||
|
||||
/**
|
||||
* Gets information about a user identified by their username.
|
||||
*
|
||||
* @param personId ID of the target user
|
||||
* @param options Api options
|
||||
* @returns User information
|
||||
@@ -230,6 +234,7 @@ export class ContentApiService {
|
||||
|
||||
/**
|
||||
* Gets product information for Content Services.
|
||||
*
|
||||
* @returns ProductVersionModel containing product details
|
||||
*/
|
||||
getRepositoryInformation(): Observable<DiscoveryEntry> {
|
||||
@@ -253,19 +258,17 @@ export class ContentApiService {
|
||||
...opts,
|
||||
where: '(EXISTS(target/site))'
|
||||
}).pipe(
|
||||
map((response: FavoritePaging) => {
|
||||
return {
|
||||
list: {
|
||||
entries: response.list.entries.map(({ entry }: any) => {
|
||||
entry.target.site.createdAt = entry.createdAt;
|
||||
return {
|
||||
entry: entry.target.site
|
||||
};
|
||||
}),
|
||||
pagination: response.list.pagination
|
||||
}
|
||||
};
|
||||
})
|
||||
map((response: FavoritePaging) => ({
|
||||
list: {
|
||||
entries: response.list.entries.map(({ entry }: any) => {
|
||||
entry.target.site.createdAt = entry.createdAt;
|
||||
return {
|
||||
entry: entry.target.site
|
||||
};
|
||||
}),
|
||||
pagination: response.list.pagination
|
||||
}
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -35,8 +35,13 @@ describe('RouterExtensionService', () => {
|
||||
let extensionService: ExtensionService;
|
||||
let service: RouterExtensionService;
|
||||
let router: Router;
|
||||
let component1, component2, component3, layoutComponent;
|
||||
let guard1, guard2, guard3;
|
||||
let component1;
|
||||
let component2;
|
||||
let component3;
|
||||
let layoutComponent;
|
||||
let guard1;
|
||||
let guard2;
|
||||
let guard3;
|
||||
|
||||
beforeEach(() => {
|
||||
component1 = { name: 'component-1' };
|
||||
@@ -97,17 +102,15 @@ describe('RouterExtensionService', () => {
|
||||
});
|
||||
|
||||
describe('getApplicationRoutes', () => {
|
||||
function getDummyRoute(overrides) {
|
||||
return {
|
||||
id: 'aca:routes/about',
|
||||
path: 'ext/about',
|
||||
component: 'ext:components/about',
|
||||
layout: 'aca:layouts/main',
|
||||
auth: ['aca:auth'],
|
||||
data: { title: 'Custom About' },
|
||||
...overrides
|
||||
};
|
||||
}
|
||||
const getDummyRoute = (overrides) => ({
|
||||
id: 'aca:routes/about',
|
||||
path: 'ext/about',
|
||||
component: 'ext:components/about',
|
||||
layout: 'aca:layouts/main',
|
||||
auth: ['aca:auth'],
|
||||
data: { title: 'Custom About' },
|
||||
...overrides
|
||||
});
|
||||
it('should calculate path properly', () => {
|
||||
extensionService.routes = [getDummyRoute({ path: 'aca:routes/about' })];
|
||||
|
||||
|
@@ -68,14 +68,12 @@ export class RouterExtensionService {
|
||||
parentRoute: route.parentRoute,
|
||||
children: [
|
||||
...(route['children']
|
||||
? route['children'].map(({ path, component, outlet, data }) => {
|
||||
return {
|
||||
path,
|
||||
outlet,
|
||||
data,
|
||||
component: this.getComponentById(component)
|
||||
};
|
||||
})
|
||||
? route['children'].map(({ path, component, outlet, data }) => ({
|
||||
path,
|
||||
outlet,
|
||||
data,
|
||||
component: this.getComponentById(component)
|
||||
}))
|
||||
: []),
|
||||
{
|
||||
path: '',
|
||||
@@ -87,7 +85,7 @@ export class RouterExtensionService {
|
||||
});
|
||||
}
|
||||
|
||||
private getComponentById(id: string): Type<{}> {
|
||||
private getComponentById(id: string): Type<unknown> {
|
||||
return this.extensions.getComponentById(id);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user