Skip to content

Commit

Permalink
[AAE-7244] fix process services cloud eslint warnings (#7503)
Browse files Browse the repository at this point in the history
* fix process services cloud eslint warnings

* fix export of private consts

* improve constant export

* fix unit tests
  • Loading branch information
DenysVuika committed Feb 17, 2022
1 parent e017423 commit 5b7f255
Show file tree
Hide file tree
Showing 95 changed files with 2,500 additions and 2,617 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Component, OnInit, OnDestroy } from '@angular/core';
import { EditProcessFilterCloudComponent, ProcessFilterAction, ProcessFilterCloudModel } from '@alfresco/adf-process-services-cloud';
import { ProcessFilterAction, ProcessFilterCloudModel, PROCESS_FILTER_ACTION_DELETE, PROCESS_FILTER_ACTION_SAVE, PROCESS_FILTER_ACTION_SAVE_AS } from '@alfresco/adf-process-services-cloud';
import { ActivatedRoute, Router } from '@angular/router';
import { UserPreferencesService, DataCellEvent } from '@alfresco/adf-core';
import { CloudLayoutService, CloudServiceSettings } from './services/cloud-layout.service';
Expand Down Expand Up @@ -124,13 +124,13 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
}

onProcessFilterAction(filterAction: ProcessFilterAction) {
if (filterAction.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) {
if (filterAction.actionType === PROCESS_FILTER_ACTION_DELETE) {
this.cloudLayoutService.setCurrentProcessFilterParam({ index: 0 });
} else {
this.cloudLayoutService.setCurrentProcessFilterParam({ id: filterAction.filter.id });
}

if ([EditProcessFilterCloudComponent.ACTION_SAVE, EditProcessFilterCloudComponent.ACTION_SAVE_AS].includes(filterAction.actionType)) {
if ([PROCESS_FILTER_ACTION_SAVE, PROCESS_FILTER_ACTION_SAVE_AS].includes(filterAction.actionType)) {
this.onFilterChange(filterAction.filter);
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/process-services-cloud/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"no-underscore-dangle": "warn",
"@typescript-eslint/member-ordering": "off",
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
"no-shadow": "warn",
"quote-props": "warn",
"object-shorthand": "warn",
"prefer-const": "warn",
"arrow-body-style": "warn",
"@angular-eslint/no-output-native": "warn",
"@angular-eslint/no-output-native": "off",
"space-before-function-paren": "warn",

"@angular-eslint/component-selector": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class AppDetailsCloudComponent {

/**
* Pass the selected app as next
*
* @param app
*/
onSelectApp(app: ApplicationInstanceModel): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs';

import { fakeApplicationInstance } from '../mock/app-model.mock';
import { AppListCloudComponent } from './app-list-cloud.component';
import { AppListCloudComponent, LAYOUT_GRID, LAYOUT_LIST } from './app-list-cloud.component';
import { AppsProcessCloudService } from '../services/apps-process-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
import { TranslateModule } from '@ngx-translate/core';
Expand All @@ -38,9 +38,7 @@ describe('AppListCloudComponent', () => {
oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
},
isEcmLoggedIn() {
return false;
},
isEcmLoggedIn: () => false,
reply: jasmine.createSpy('reply')
};

Expand Down Expand Up @@ -155,7 +153,7 @@ describe('AppListCloudComponent', () => {
});

it('should display a grid when configured to', () => {
component.layoutType = AppListCloudComponent.LAYOUT_GRID;
component.layoutType = LAYOUT_GRID;
fixture.detectChanges();
expect(component.isGrid()).toBe(true);
expect(component.isList()).toBe(false);
Expand All @@ -170,7 +168,7 @@ describe('AppListCloudComponent', () => {
describe('List Layout ', () => {

beforeEach(() => {
component.layoutType = AppListCloudComponent.LAYOUT_LIST;
component.layoutType = LAYOUT_LIST;
});

it('should display a LIST when configured to', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,24 @@ import { AppsProcessCloudService } from '../services/apps-process-cloud.service'
import { ApplicationInstanceModel } from '../models/application-instance.model';
import { catchError } from 'rxjs/operators';

export const LAYOUT_LIST: string = 'LIST';
export const LAYOUT_GRID: string = 'GRID';
export const RUNNING_STATUS: string = 'RUNNING';

@Component({
selector: 'adf-cloud-app-list',
templateUrl: './app-list-cloud.component.html',
styleUrls: ['./app-list-cloud.component.scss']
})
export class AppListCloudComponent implements OnInit, AfterContentInit {

public static LAYOUT_LIST: string = 'LIST';
public static LAYOUT_GRID: string = 'GRID';
public static RUNNING_STATUS: string = 'RUNNING';

@ContentChild(CustomEmptyContentTemplateDirective)
emptyCustomContent: CustomEmptyContentTemplateDirective;

/** (**required**) Defines the layout of the apps. There are two possible
* values, "GRID" and "LIST".
*/
@Input()
layoutType: string = AppListCloudComponent.LAYOUT_GRID;
layoutType: string = LAYOUT_GRID;

/** Emitted when an app entry is clicked. */
@Output()
Expand All @@ -57,7 +56,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
this.setDefaultLayoutType();
}

this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(AppListCloudComponent.RUNNING_STATUS)
this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(RUNNING_STATUS)
.pipe(
catchError(() => {
this.loadingError$.next(true);
Expand All @@ -80,7 +79,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
* Check if the value of the layoutType property is an allowed value
*/
isValidType(): boolean {
if (this.layoutType && (this.layoutType === AppListCloudComponent.LAYOUT_LIST || this.layoutType === AppListCloudComponent.LAYOUT_GRID)) {
if (this.layoutType && (this.layoutType === LAYOUT_LIST || this.layoutType === LAYOUT_GRID)) {
return true;
}
return false;
Expand All @@ -90,20 +89,20 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
* Assign the default value to LayoutType
*/
setDefaultLayoutType(): void {
this.layoutType = AppListCloudComponent.LAYOUT_GRID;
this.layoutType = LAYOUT_GRID;
}

/**
* Return true if the layout type is LIST
*/
isList(): boolean {
return this.layoutType === AppListCloudComponent.LAYOUT_LIST;
return this.layoutType === LAYOUT_LIST;
}

/**
* Return true if the layout type is GRID
*/
isGrid(): boolean {
return this.layoutType === AppListCloudComponent.LAYOUT_GRID;
return this.layoutType === LAYOUT_GRID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ describe('AppsProcessCloudService', () => {
oauth2Auth: {
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }})
},
isEcmLoggedIn() {
return false;
},
isEcmLoggedIn: () => false,
reply: jasmine.createSpy('reply')
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('DateRangeFilterComponent', () => {

it('should not emit any date change events when any type is selected', () => {
spyOn(component.dateChanged, 'emit');
const value = <MatSelectChange> { value: DateCloudFilterType.RANGE };
const value = { value: DateCloudFilterType.RANGE } as MatSelectChange;
component.onSelectionChange(value);
expect(component.dateChanged.emit).not.toHaveBeenCalled();
});
Expand All @@ -114,7 +114,7 @@ describe('DateRangeFilterComponent', () => {
});

it('should show date-range picker when type is range', async () => {
const value = <MatSelectChange> { value: DateCloudFilterType.RANGE };
const value = { value: DateCloudFilterType.RANGE } as MatSelectChange;
component.onSelectionChange(value);
fixture.detectChanges();
await fixture.whenStable();
Expand All @@ -127,7 +127,9 @@ describe('DateRangeFilterComponent', () => {
component.ngOnInit();
fixture.detectChanges();

// eslint-disable-next-line no-underscore-dangle
expect(component.dateRangeForm.get('from').value).toEqual(moment(mockFilterProperty.value._startFrom));
// eslint-disable-next-line no-underscore-dangle
expect(component.dateRangeForm.get('to').value).toEqual(moment(mockFilterProperty.value._startTo));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export class CloudFormRenderingService extends FormRenderingService {
super();

this.register({
'upload': () => AttachFileCloudWidgetComponent,
'dropdown': () => DropdownCloudWidgetComponent,
'date': () => DateCloudWidgetComponent,
'people': () => PeopleCloudWidgetComponent,
upload: () => AttachFileCloudWidgetComponent,
dropdown: () => DropdownCloudWidgetComponent,
date: () => DateCloudWidgetComponent,
people: () => PeopleCloudWidgetComponent,
'functional-group': () => GroupCloudWidgetComponent,
'properties-viewer': () => PropertiesViewerWidgetComponent,
'radio-buttons': () => RadioButtonsCloudWidgetComponent
Expand Down

0 comments on commit 5b7f255

Please sign in to comment.