[ACA-3506] - Filter are kept when reloaded (#5885)

* [ADF] - saving in the url the filter values

* Fixed filter status on refresh

* Fixed filter status on refresh

* [ACA-3506] - added url filtering save

* [ACA-3506] - fixed spellcheck

* improve log

* more log

* fix scripts

* Added documentation for allowUpdateOnChange setting

* Added default value in description for docs

Co-authored-by: Vito Albano <vitoalbano@Vitos-MacBook-Pro.local>
Co-authored-by: Eugenio Romano <eugenio.romano@alfresco.com>
This commit is contained in:
Vito
2020-07-20 11:39:51 +01:00
committed by GitHub
parent 44c5472fa2
commit 3b7f3a5762
33 changed files with 316 additions and 122 deletions

View File

@@ -460,7 +460,8 @@
"pattern": "cm:name:'(.*?)'", "pattern": "cm:name:'(.*?)'",
"field": "cm:name", "field": "cm:name",
"placeholder": "SEARCH.SEARCH_HEADER.FILTERS.NAME.PLACEHOLDER", "placeholder": "SEARCH.SEARCH_HEADER.FILTERS.NAME.PLACEHOLDER",
"searchSuffix" : "*" "searchSuffix" : "*",
"allowUpdateOnChange" : false
} }
} }
}, },
@@ -473,6 +474,7 @@
"selector": "check-list", "selector": "check-list",
"settings": { "settings": {
"pageSize": 5, "pageSize": 5,
"allowUpdateOnChange" : false,
"operator": "OR", "operator": "OR",
"options": [ "options": [
{ {
@@ -495,6 +497,7 @@
"component": { "component": {
"selector": "check-list", "selector": "check-list",
"settings": { "settings": {
"allowUpdateOnChange" : false,
"options": [ "options": [
{ {
"name": "SEARCH.SEARCH_HEADER.FILTERS.SIZE.SMALL", "name": "SEARCH.SEARCH_HEADER.FILTERS.SIZE.SMALL",
@@ -524,6 +527,7 @@
"component": { "component": {
"selector": "date-range", "selector": "date-range",
"settings": { "settings": {
"allowUpdateOnChange" : false,
"field": "cm:created", "field": "cm:created",
"dateFormat": "DD-MMM-YY", "dateFormat": "DD-MMM-YY",
"maxDate": "today" "maxDate": "today"

View File

@@ -240,11 +240,13 @@
<adf-custom-header-filter-template *ngIf="enableCustomHeaderFilter"> <adf-custom-header-filter-template *ngIf="enableCustomHeaderFilter">
<ng-template let-col> <ng-template let-col>
<adf-search-header [col]="col" <adf-search-header [col]="col"
[value]="paramValues? paramValues[col.key] : null"
[currentFolderNodeId]="currentFolderId" [currentFolderNodeId]="currentFolderId"
[maxItems]="pagination?.maxItems" [maxItems]="pagination?.maxItems"
[skipCount]="pagination?.skipCount" [skipCount]="pagination?.skipCount"
(update)="onFilterUpdate($event)" (update)="onFilterUpdate($event)"
(clear)="onAllFilterCleared()"> (clear)="onAllFilterCleared()"
(selection)="onFilterSelected($event)">
</adf-search-header> </adf-search-header>
</ng-template> </ng-template>
</adf-custom-header-filter-template> </adf-custom-header-filter-template>

View File

@@ -163,6 +163,9 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
@Input() @Input()
enableCustomHeaderFilter = false; enableCustomHeaderFilter = false;
@Input()
paramValues: Map <any, any> = null;
@Output() @Output()
documentListReady: EventEmitter<any> = new EventEmitter(); documentListReady: EventEmitter<any> = new EventEmitter();
@@ -655,7 +658,27 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
onAllFilterCleared() { onAllFilterCleared() {
this.documentList.node = null; this.documentList.node = null;
if (this.currentFolderId === '-my-') {
this.router.navigate([this.navigationRoute, '']);
} else {
this.router.navigate([this.navigationRoute, this.currentFolderId, 'display', this.displayMode]);
}
this.documentList.reload(); this.documentList.reload();
} }
onFilterSelected(currentActiveFilters: Map<string, string>) {
const objectFromMap = {};
currentActiveFilters.forEach((value: any, key) => {
let paramValue = null;
if (value && value.from && value.to) {
paramValue = `${value.from}||${value.to}`;
} else {
paramValue = value;
}
objectFromMap[key] = paramValue;
});
this.router.navigate([], { relativeTo: this.route, queryParams: objectFromMap });
}
} }

View File

@@ -4,5 +4,6 @@
[showSettingsPanel]="false" [showSettingsPanel]="false"
[navigationRoute]="navigationRoute" [navigationRoute]="navigationRoute"
[currentFolderId]="currentFolderId" [currentFolderId]="currentFolderId"
[enableCustomHeaderFilter]="true"> [enableCustomHeaderFilter]="true"
[paramValues]="queryParams">
</app-files-component> </app-files-component>

View File

@@ -29,13 +29,20 @@ export class FilteredSearchComponent {
navigationRoute = '/filtered-search'; navigationRoute = '/filtered-search';
currentFolderId = '-my-'; currentFolderId = '-my-';
queryParams = null;
constructor(@Optional() private route: ActivatedRoute) { constructor(@Optional() private route: ActivatedRoute) {
if (this.route) { if (this.route) {
this.route.params.forEach((params: Params) => { this.route.params.forEach((params: Params) => {
if (params['id'] && this.currentFolderId !== params['id']) { if (params['id'] && this.currentFolderId !== params['id']) {
this.currentFolderId = params['id']; this.currentFolderId = params['id'];
} }
}); });
this.route.queryParamMap.subscribe((queryMap: Params) => {
this.queryParams = queryMap.params;
});
} }
} }

View File

@@ -26,6 +26,7 @@ Implements a checklist [widget](../../../lib/testing/src/lib/core/pages/form/wid
"pageSize": 5, "pageSize": 5,
"settings": { "settings": {
"operator": "OR", "operator": "OR",
"allowUpdateOnChange": true,
"options": [ "options": [
{ "name": "Folder", "value": "TYPE:'cm:folder'" }, { "name": "Folder", "value": "TYPE:'cm:folder'" },
{ "name": "Document", "value": "TYPE:'cm:content'" } { "name": "Document", "value": "TYPE:'cm:content'" }
@@ -44,6 +45,7 @@ Implements a checklist [widget](../../../lib/testing/src/lib/core/pages/form/wid
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| operator | `string` | Logical operator to combine query fragments. Can be 'AND' or 'OR'. | | operator | `string` | Logical operator to combine query fragments. Can be 'AND' or 'OR'. |
| options | `array` | Array of objects with `name` and `value` properties. Each object defines a checkbox, labelled with `name`, that adds the query fragment in `value` to the query when enabled. | | options | `array` | Array of objects with `name` and `value` properties. Each object defines a checkbox, labelled with `name`, that adds the query fragment in `value` to the query when enabled. |
| allowUpdateOnChange | `boolean` | Enable/Disable the update fire event when text has been changed. By default is true.
## Details ## Details

View File

@@ -29,7 +29,8 @@ Implements a text input [widget](../../../lib/testing/src/lib/core/pages/form/wi
"searchSuffix": "", "searchSuffix": "",
"pattern": "cm:name:'(.*?)'", "pattern": "cm:name:'(.*?)'",
"field": "cm:name", "field": "cm:name",
"placeholder": "Enter the name" "placeholder": "Enter the name",
"allowUpdateOnChange": true
} }
} }
} }
@@ -47,6 +48,7 @@ Implements a text input [widget](../../../lib/testing/src/lib/core/pages/form/wi
| placeholder | string | Text displayed in the [widget](../../../lib/testing/src/lib/core/pages/form/widgets/widget.ts) when the input string is empty | | placeholder | string | Text displayed in the [widget](../../../lib/testing/src/lib/core/pages/form/widgets/widget.ts) when the input string is empty |
| searchSuffix | string | Text to append always in the search of a string| | searchSuffix | string | Text to append always in the search of a string|
| searchPrefix | string | Text to prepend always in the search of a string| | searchPrefix | string | Text to prepend always in the search of a string|
| allowUpdateOnChange | `boolean` | Enable/Disable the update fire event when text has been changed. By default is true.
## Details ## Details

View File

@@ -15,7 +15,7 @@
</mat-checkbox> </mat-checkbox>
</div> </div>
<div class="adf-facet-buttons" *ngIf="options.fitsPage"> <div class="adf-facet-buttons" *ngIf="options.fitsPage">
<button mat-button color="primary" (click)="reset()"> <button mat-button color="primary" (click)="reset()">
{{ 'SEARCH.FILTER.ACTIONS.CLEAR-ALL' | translate }} {{ 'SEARCH.FILTER.ACTIONS.CLEAR-ALL' | translate }}

View File

@@ -42,8 +42,10 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
context?: SearchQueryBuilderService; context?: SearchQueryBuilderService;
options: SearchFilterList<SearchListOption>; options: SearchFilterList<SearchListOption>;
operator: string = 'OR'; operator: string = 'OR';
startValue: SearchListOption = null;
pageSize = 5; pageSize = 5;
isActive = false; isActive = false;
enableChangeUpdate = true;
constructor() { constructor() {
this.options = new SearchFilterList<SearchListOption>(); this.options = new SearchFilterList<SearchListOption>();
@@ -57,6 +59,15 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
if (this.settings.options && this.settings.options.length > 0) { if (this.settings.options && this.settings.options.length > 0) {
this.options = new SearchFilterList(this.settings.options, this.pageSize); this.options = new SearchFilterList(this.settings.options, this.pageSize);
} }
if (this.settings.allowUpdateOnChange !== undefined &&
this.settings.allowUpdateOnChange !== null) {
this.enableChangeUpdate = this.settings.allowUpdateOnChange;
}
}
if (this.startValue) {
this.setValue(this.startValue);
} }
} }
@@ -74,7 +85,11 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
changeHandler(event: MatCheckboxChange, option: any) { changeHandler(event: MatCheckboxChange, option: any) {
option.checked = event.checked; option.checked = event.checked;
this.submitValues(); const checkedValues = this.getCheckedValues();
this.isActive = !!checkedValues.length;
if (this.enableChangeUpdate) {
this.submitValues();
}
} }
hasValidValue() { hasValidValue() {
@@ -82,6 +97,16 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
return !!checkedValues.length; return !!checkedValues.length;
} }
getCurrentValue() {
return this.getCheckedValues();
}
setValue(value: any) {
this.options.items.filter((item) => value.includes(item.value))
.map((item) => item.checked = true);
this.submitValues();
}
private getCheckedValues() { private getCheckedValues() {
return this.options.items return this.options.items
.filter((option) => option.checked) .filter((option) => option.checked)
@@ -90,11 +115,7 @@ export class SearchCheckListComponent implements SearchWidget, OnInit {
submitValues() { submitValues() {
const checkedValues = this.getCheckedValues(); const checkedValues = this.getCheckedValues();
this.isActive = !!checkedValues.length;
const query = checkedValues.join(` ${this.operator} `); const query = checkedValues.join(` ${this.operator} `);
if (this.id && this.context) { if (this.id && this.context) {
this.context.queryFragments[this.id] = query; this.context.queryFragments[this.id] = query;
this.context.update(); this.context.update();

View File

@@ -57,6 +57,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
datePickerDateFormat = DEFAULT_FORMAT_DATE; datePickerDateFormat = DEFAULT_FORMAT_DATE;
maxDate: any; maxDate: any;
isActive = false; isActive = false;
startValue: any;
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
@@ -95,14 +96,6 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
Validators.required Validators.required
]); ]);
this.from = new FormControl('', validators);
this.to = new FormControl('', validators);
this.form = new FormGroup({
from: this.from,
to: this.to
});
if (this.settings && this.settings.maxDate) { if (this.settings && this.settings.maxDate) {
if (this.settings.maxDate === 'today') { if (this.settings.maxDate === 'today') {
this.maxDate = this.dateAdapter.today().endOf('day'); this.maxDate = this.dateAdapter.today().endOf('day');
@@ -110,6 +103,22 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
this.maxDate = moment(this.settings.maxDate).endOf('day'); this.maxDate = moment(this.settings.maxDate).endOf('day');
} }
} }
if (this.startValue) {
const splitValue = this.startValue.split('||');
const fromValue = this.dateAdapter.parse(splitValue[0], this.datePickerDateFormat);
const toValue = this.dateAdapter.parse(splitValue[1], this.datePickerDateFormat);
this.from = new FormControl(fromValue, validators);
this.to = new FormControl(toValue, validators);
} else {
this.from = new FormControl('', validators);
this.to = new FormControl('', validators);
}
this.form = new FormGroup({
from: this.from,
to: this.to
});
} }
ngOnDestroy() { ngOnDestroy() {
@@ -137,6 +146,24 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
return this.form.valid; return this.form.valid;
} }
getCurrentValue() {
return { from : this.dateAdapter.format(this.form.value.from, this.datePickerDateFormat),
to: this.dateAdapter.format(this.form.value.from, this.datePickerDateFormat) };
}
setValue(parsedDate: string) {
const splitValue = parsedDate.split('||');
const fromValue = this.dateAdapter.parse(splitValue[0], this.datePickerDateFormat);
const toValue = this.dateAdapter.parse(splitValue[1], this.datePickerDateFormat);
this.from.setValue(fromValue);
this.from.markAsDirty();
this.from.markAsTouched();
this.to.setValue(toValue);
this.to.markAsDirty();
this.to.markAsTouched();
this.submitValues();
}
reset() { reset() {
this.isActive = false; this.isActive = false;
this.form.reset({ this.form.reset({
@@ -150,6 +177,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
} }
onChangedHandler(event: any, formControl: FormControl) { onChangedHandler(event: any, formControl: FormControl) {
const inputValue = event.srcElement.value; const inputValue = event.srcElement.value;
const formatDate = this.dateAdapter.parse(inputValue, this.datePickerDateFormat); const formatDate = this.dateAdapter.parse(inputValue, this.datePickerDateFormat);

View File

@@ -8,7 +8,7 @@
(keyup.enter)="$event.stopPropagation()" (keyup.enter)="$event.stopPropagation()"
class="adf-filter-button" class="adf-filter-button"
[matTooltip]="getTooltipTranslation(col?.title)"> [matTooltip]="getTooltipTranslation(col?.title)">
<adf-icon value="adf:filter" <adf-icon value="adf:filter"
[ngClass]="{ 'adf-icon-active': isActive() || menuTrigger.menuOpen }" [ngClass]="{ 'adf-icon-active': isActive() || menuTrigger.menuOpen }"
matBadge="filter" matBadge="filter"
matBadgeColor="warn" matBadgeColor="warn"
@@ -23,7 +23,8 @@
(keypress)="onKeyPressed($event, menuTrigger)" (keypress)="onKeyPressed($event, menuTrigger)"
[id]="category?.id" [id]="category?.id"
[selector]="category?.component?.selector" [selector]="category?.component?.selector"
[settings]="category?.component?.settings"> [settings]="category?.component?.settings"
[value]="initialValue">
</adf-search-widget-container> </adf-search-widget-container>
</div> </div>
<mat-dialog-actions class="adf-filter-actions"> <mat-dialog-actions class="adf-filter-actions">

View File

@@ -173,7 +173,8 @@ describe('SearchHeaderComponent', () => {
spyOn(queryBuilder, 'isNoFilterActive').and.returnValue(false); spyOn(queryBuilder, 'isNoFilterActive').and.returnValue(false);
spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging)); spyOn(alfrescoApiService.searchApi, 'search').and.returnValue(Promise.resolve(fakeNodePaging));
spyOn(queryBuilder, 'buildQuery').and.returnValue({}); spyOn(queryBuilder, 'buildQuery').and.returnValue({});
spyOn(component.widgetContainer, 'resetInnerWidget').and.stub(); queryBuilder.queryFragments['fake'] = 'test';
spyOn(component.widgetContainer, 'resetInnerWidget').and.callThrough();
const fakeEvent = jasmine.createSpyObj('event', ['stopPropagation']); const fakeEvent = jasmine.createSpyObj('event', ['stopPropagation']);
const menuButton: HTMLButtonElement = fixture.nativeElement.querySelector('#filter-menu-button'); const menuButton: HTMLButtonElement = fixture.nativeElement.querySelector('#filter-menu-button');
component.update.subscribe((newNodePaging) => { component.update.subscribe((newNodePaging) => {

View File

@@ -33,7 +33,7 @@ import { ConfigurableFocusTrapFactory, ConfigurableFocusTrap } from '@angular/cd
import { DataColumn, TranslationService } from '@alfresco/adf-core'; import { DataColumn, TranslationService } from '@alfresco/adf-core';
import { SearchWidgetContainerComponent } from '../search-widget-container/search-widget-container.component'; import { SearchWidgetContainerComponent } from '../search-widget-container/search-widget-container.component';
import { SearchHeaderQueryBuilderService } from '../../search-header-query-builder.service'; import { SearchHeaderQueryBuilderService } from '../../search-header-query-builder.service';
import { NodePaging } from '@alfresco/js-api'; import { NodePaging, MinimalNode } from '@alfresco/js-api';
import { SearchCategory } from '../../search-category.interface'; import { SearchCategory } from '../../search-category.interface';
import { SEARCH_QUERY_SERVICE_TOKEN } from '../../search-query-service.token'; import { SEARCH_QUERY_SERVICE_TOKEN } from '../../search-query-service.token';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
@@ -52,6 +52,9 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
@Input() @Input()
col: DataColumn; col: DataColumn;
@Input()
value: any;
/** The id of the current folder of the document list. */ /** The id of the current folder of the document list. */
@Input() @Input()
currentFolderNodeId: string; currentFolderNodeId: string;
@@ -72,6 +75,10 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
@Output() @Output()
clear: EventEmitter<any> = new EventEmitter(); clear: EventEmitter<any> = new EventEmitter();
/** Emitted when a filter value is selected */
@Output()
selection: EventEmitter<Map<string, string>> = new EventEmitter();
@ViewChild(SearchWidgetContainerComponent) @ViewChild(SearchWidgetContainerComponent)
widgetContainer: SearchWidgetContainerComponent; widgetContainer: SearchWidgetContainerComponent;
@@ -80,6 +87,7 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
category: SearchCategory; category: SearchCategory;
isFilterServiceActive: boolean; isFilterServiceActive: boolean;
initialValue: any;
focusTrap: ConfigurableFocusTrap; focusTrap: ConfigurableFocusTrap;
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
@@ -100,11 +108,18 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
.subscribe((newNodePaging: NodePaging) => { .subscribe((newNodePaging: NodePaging) => {
this.update.emit(newNodePaging); this.update.emit(newNodePaging);
}); });
if (this.searchHeaderQueryBuilder.isCustomSourceNode(this.currentFolderNodeId)) {
this.searchHeaderQueryBuilder.getNodeIdForCustomSource(this.currentFolderNodeId).subscribe((node: MinimalNode) => {
this.initSearchHeader(node.id);
});
} else {
this.initSearchHeader(this.currentFolderNodeId);
}
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (changes['currentFolderNodeId'] && changes['currentFolderNodeId'].currentValue !== changes['currentFolderNodeId'].previousValue) { if (changes['currentFolderNodeId'] && changes['currentFolderNodeId'].currentValue) {
this.searchHeaderQueryBuilder.setCurrentRootFolderId(changes['currentFolderNodeId'].currentValue);
this.clearHeader(); this.clearHeader();
} }
@@ -138,8 +153,8 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
onApply() { onApply() {
if (this.widgetContainer.hasValueSelected()) { if (this.widgetContainer.hasValueSelected()) {
this.widgetContainer.applyInnerWidget(); this.widgetContainer.applyInnerWidget();
this.searchHeaderQueryBuilder.setActiveFilter(this.category.columnKey); this.searchHeaderQueryBuilder.setActiveFilter(this.category.columnKey, this.widgetContainer.getCurrentValue());
this.searchHeaderQueryBuilder.execute(); this.selection.emit(this.searchHeaderQueryBuilder.getActiveFilters());
} else { } else {
this.clearHeader(); this.clearHeader();
} }
@@ -154,10 +169,9 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
if (this.widgetContainer) { if (this.widgetContainer) {
this.widgetContainer.resetInnerWidget(); this.widgetContainer.resetInnerWidget();
this.searchHeaderQueryBuilder.removeActiveFilter(this.category.columnKey); this.searchHeaderQueryBuilder.removeActiveFilter(this.category.columnKey);
this.selection.emit(this.searchHeaderQueryBuilder.getActiveFilters());
if (this.searchHeaderQueryBuilder.isNoFilterActive()) { if (this.searchHeaderQueryBuilder.isNoFilterActive()) {
this.clear.emit(); this.clear.emit();
} else {
this.searchHeaderQueryBuilder.execute();
} }
} }
} }
@@ -173,6 +187,14 @@ export class SearchHeaderComponent implements OnInit, OnChanges, OnDestroy {
return this.widgetContainer && this.widgetContainer.componentRef && this.widgetContainer.componentRef.instance.isActive; return this.widgetContainer && this.widgetContainer.componentRef && this.widgetContainer.componentRef.instance.isActive;
} }
private initSearchHeader(currentFolderId: string) {
this.searchHeaderQueryBuilder.setCurrentRootFolderId(currentFolderId);
if (this.value) {
this.searchHeaderQueryBuilder.setActiveFilter(this.category.columnKey, this.initialValue);
this.initialValue = this.value;
}
}
onMenuOpen() { onMenuOpen() {
if (this.filterContainer && !this.focusTrap) { if (this.filterContainer && !this.focusTrap) {
this.focusTrap = this.focusTrapFactory.create(this.filterContainer.nativeElement); this.focusTrap = this.focusTrapFactory.create(this.filterContainer.nativeElement);

View File

@@ -45,6 +45,7 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
format = '[{FROM} TO {TO}]'; format = '[{FROM} TO {TO}]';
isActive = false; isActive = false;
startValue: any;
validators: Validators; validators: Validators;
@@ -61,8 +62,13 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
Validators.min(0) Validators.min(0)
]); ]);
this.from = new FormControl('', this.validators); if (this.startValue) {
this.to = new FormControl('', this.validators); this.from = new FormControl(this.startValue['from'], this.validators);
this.to = new FormControl(this.startValue['to'], this.validators);
} else {
this.from = new FormControl('', this.validators);
this.to = new FormControl('', this.validators);
}
this.form = new FormGroup({ this.form = new FormGroup({
from: this.from, from: this.from,
@@ -108,6 +114,15 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
return this.form.valid; return this.form.valid;
} }
getCurrentValue() {
return this.form.value;
}
setValue(value: any) {
this.form['from'].setValue(value);
this.form['to'].setValue(value);
}
reset() { reset() {
this.isActive = false; this.isActive = false;

View File

@@ -41,10 +41,10 @@ describe('SearchRadioComponent', () => {
describe('Pagination', () => { describe('Pagination', () => {
it('should show 5 items when pageSize not defined', () => { it('should show 5 items when pageSize not defined', () => {
component.id = 'checklist'; component.id = 'radio';
component.context = <any> { component.context = <any> {
queryFragments: { queryFragments: {
'checklist': 'query' 'radio': 'query'
}, },
update() {} update() {}
}; };
@@ -60,10 +60,10 @@ describe('SearchRadioComponent', () => {
}); });
it('should show all items when pageSize is high', () => { it('should show all items when pageSize is high', () => {
component.id = 'checklist'; component.id = 'radio';
component.context = <any> { component.context = <any> {
queryFragments: { queryFragments: {
'checklist': 'query' 'radio': 'query'
}, },
update() {} update() {}
}; };
@@ -78,21 +78,22 @@ describe('SearchRadioComponent', () => {
}); });
}); });
it('should able to check the radio button', () => { it('should able to check the radio button', async () => {
component.id = 'checklist'; component.id = 'radio';
component.context = <any> { component.context = <any> {
queryFragments: { queryFragments: {
'checklist': 'query' 'radio': 'query'
}, },
update: () => {} update: () => {}
}; };
component.settings = <any> { options: sizeOptions }; component.settings = <any> { options: sizeOptions };
spyOn(component.context, 'update').and.stub(); spyOn(component.context, 'update').and.stub();
component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable();
const optionElements = fixture.debugElement.query(By.css('mat-radio-button')); const optionElements = fixture.debugElement.query(By.css('mat-radio-button'));
optionElements.triggerEventHandler('change', { checked: true }); optionElements.triggerEventHandler('change', { checked: true });
fixture.detectChanges();
expect(component.context.update).toHaveBeenCalled(); expect(component.context.update).toHaveBeenCalled();
expect(component.context.queryFragments[component.id]).toBe(sizeOptions[0].value); expect(component.context.queryFragments[component.id]).toBe(sizeOptions[0].value);

View File

@@ -47,6 +47,7 @@ export class SearchRadioComponent implements SearchWidget, OnInit {
options: SearchFilterList<SearchRadioOption>; options: SearchFilterList<SearchRadioOption>;
pageSize = 5; pageSize = 5;
isActive = false; isActive = false;
startValue: any;
constructor() { constructor() {
this.options = new SearchFilterList<SearchRadioOption>(); this.options = new SearchFilterList<SearchRadioOption>();
@@ -64,8 +65,11 @@ export class SearchRadioComponent implements SearchWidget, OnInit {
} }
const initialValue = this.getSelectedValue(); const initialValue = this.getSelectedValue();
if (initialValue !== null) { if (initialValue !== null) {
this.setValue(initialValue); this.setValue(initialValue);
} else if (this.startValue !== null) {
this.setValue(initialValue);
} }
} }
@@ -93,12 +97,16 @@ export class SearchRadioComponent implements SearchWidget, OnInit {
return !!currentValue; return !!currentValue;
} }
private setValue(newValue: string) { setValue(newValue: string) {
this.value = newValue; this.value = newValue;
this.context.queryFragments[this.id] = newValue; this.context.queryFragments[this.id] = newValue;
this.context.update(); this.context.update();
} }
getCurrentValue() {
return this.getSelectedValue();
}
changeHandler(event: MatRadioChange) { changeHandler(event: MatRadioChange) {
this.setValue(event.value); this.setValue(event.value);
} }

View File

@@ -29,6 +29,8 @@ import { MatSliderChange } from '@angular/material/slider';
host: { class: 'adf-search-slider' } host: { class: 'adf-search-slider' }
}) })
export class SearchSliderComponent implements SearchWidget, OnInit { export class SearchSliderComponent implements SearchWidget, OnInit {
isActive?: boolean;
startValue: any;
id: string; id: string;
settings: SearchWidgetSettings; settings: SearchWidgetSettings;
@@ -58,6 +60,10 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
this.thumbLabel = this.settings['thumbLabel'] ? true : false; this.thumbLabel = this.settings['thumbLabel'] ? true : false;
} }
if (this.startValue) {
this.setValue(this.startValue);
}
} }
reset() { reset() {
@@ -78,6 +84,15 @@ export class SearchSliderComponent implements SearchWidget, OnInit {
return !!this.value; return !!this.value;
} }
getCurrentValue() {
return this.value;
}
setValue(value: any) {
this.value = value;
this.submitValues();
}
private updateQuery(value: number | null) { private updateQuery(value: number | null) {
if (this.id && this.context && this.settings && this.settings.field) { if (this.id && this.context && this.settings && this.settings.field) {
if (value === null) { if (value === null) {

View File

@@ -36,16 +36,26 @@ export class SearchTextComponent implements SearchWidget, OnInit {
id: string; id: string;
settings: SearchWidgetSettings; settings: SearchWidgetSettings;
context: SearchQueryBuilderService; context: SearchQueryBuilderService;
startValue: string;
isActive = false; isActive = false;
enableChangeUpdate = true;
ngOnInit() { ngOnInit() {
if (this.context && this.settings && this.settings.pattern) { if (this.context && this.settings && this.settings.pattern) {
const pattern = new RegExp(this.settings.pattern, 'g'); const pattern = new RegExp(this.settings.pattern, 'g');
const match = pattern.exec(this.context.queryFragments[this.id] || ''); const match = pattern.exec(this.context.queryFragments[this.id] || '');
if (this.settings.allowUpdateOnChange !== undefined &&
this.settings.allowUpdateOnChange !== null) {
this.enableChangeUpdate = this.settings.allowUpdateOnChange;
}
if (match && match.length > 1) { if (match && match.length > 1) {
this.value = match[1]; this.value = match[1];
} }
if (this.startValue) {
this.setValue(this.startValue);
}
} }
} }
@@ -58,12 +68,13 @@ export class SearchTextComponent implements SearchWidget, OnInit {
onChangedHandler(event) { onChangedHandler(event) {
this.value = event.target.value; this.value = event.target.value;
this.updateQuery(this.value); this.isActive = !!this.value;
if (this.enableChangeUpdate) {
this.updateQuery(this.value);
}
} }
private updateQuery(value: string) { private updateQuery(value: string) {
this.isActive = !!value;
if (this.context && this.settings && this.settings.field) { if (this.context && this.settings && this.settings.field) {
this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : ''; this.context.queryFragments[this.id] = value ? `${this.settings.field}:'${this.getSearchPrefix()}${value}${this.getSearchSuffix()}'` : '';
this.context.update(); this.context.update();
@@ -79,6 +90,15 @@ export class SearchTextComponent implements SearchWidget, OnInit {
return !!this.value; return !!this.value;
} }
getCurrentValue() {
return this.value;
}
setValue(value: string) {
this.value = value;
this.submitValues();
}
private getSearchPrefix(): string { private getSearchPrefix(): string {
return this.settings.searchPrefix ? this.settings.searchPrefix : ''; return this.settings.searchPrefix ? this.settings.searchPrefix : '';
} }

View File

@@ -41,6 +41,9 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy {
@Input() @Input()
config: any; config: any;
@Input()
value: any;
componentRef: ComponentRef<any>; componentRef: ComponentRef<any>;
constructor( constructor(
@@ -66,6 +69,10 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy {
ref.instance.id = this.id; ref.instance.id = this.id;
ref.instance.settings = { ...this.settings }; ref.instance.settings = { ...this.settings };
ref.instance.context = this.queryBuilder; ref.instance.context = this.queryBuilder;
if (this.value) {
ref.instance.isActive = true;
ref.instance.startValue = this.value;
}
} }
} }
@@ -80,10 +87,19 @@ export class SearchWidgetContainerComponent implements OnInit, OnDestroy {
this.componentRef.instance.submitValues(); this.componentRef.instance.submitValues();
} }
setValue(currentValue: string | Object) {
this.componentRef.instance.isActive = true;
this.componentRef.instance.setValue(currentValue);
}
hasValueSelected() { hasValueSelected() {
return this.componentRef.instance.hasValidValue(); return this.componentRef.instance.hasValidValue();
} }
getCurrentValue() {
return this.componentRef.instance.getCurrentValue();
}
resetInnerWidget() { resetInnerWidget() {
if (this.componentRef && this.componentRef.instance) { if (this.componentRef && this.componentRef.instance) {
this.componentRef.instance.reset(); this.componentRef.instance.reset();

View File

@@ -136,39 +136,6 @@ describe('SearchHeaderQueryBuilder', () => {
); );
}); });
it('should replace the new query filter for the old parent node with the new one', () => {
const expectedResult = [
{ query: 'PARENT:"workspace://SpacesStore/fake-next-node-id"' }
];
const config: SearchConfiguration = {
categories: [
<any> { id: 'cat1', enabled: true },
<any> { id: 'cat2', enabled: true }
],
filterQueries: [
{ query: 'PARENT:"workspace://SpacesStore/fake-node-id' }
]
};
const searchHeaderService = new SearchHeaderQueryBuilderService(
buildConfig(config),
null,
null
);
searchHeaderService.currentParentFolderId = 'fake-node-id';
searchHeaderService.setCurrentRootFolderId(
'fake-next-node-id'
);
expect(searchHeaderService.filterQueries).toEqual(
expectedResult,
'Filters are not as expected'
);
});
it('should not add duplicate column names in activeFilters', () => { it('should not add duplicate column names in activeFilters', () => {
const activeFilter = 'FakeColumn'; const activeFilter = 'FakeColumn';
@@ -187,11 +154,11 @@ describe('SearchHeaderQueryBuilder', () => {
null null
); );
expect(searchHeaderService.activeFilters.length).toBe(0); expect(searchHeaderService.activeFilters.size).toBe(0);
searchHeaderService.setActiveFilter(activeFilter); searchHeaderService.setActiveFilter(activeFilter, 'fake-value');
searchHeaderService.setActiveFilter(activeFilter); searchHeaderService.setActiveFilter(activeFilter, 'fake-value');
expect(searchHeaderService.activeFilters.length).toBe(1); expect(searchHeaderService.activeFilters.size).toBe(1);
}); });
}); });

View File

@@ -20,7 +20,9 @@ import { AlfrescoApiService, AppConfigService, NodesApiService } from '@alfresco
import { SearchConfiguration } from './search-configuration.interface'; import { SearchConfiguration } from './search-configuration.interface';
import { BaseQueryBuilderService } from './base-query-builder.service'; import { BaseQueryBuilderService } from './base-query-builder.service';
import { SearchCategory } from './search-category.interface'; import { SearchCategory } from './search-category.interface';
import { MinimalNode } from '@alfresco/js-api'; import { MinimalNode, QueryBody } from '@alfresco/js-api';
import { filter } from 'rxjs/operators';
import { Observable } from 'rxjs';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -29,11 +31,15 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
private customSources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-', '-my-']; private customSources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-', '-my-'];
activeFilters: string[] = []; activeFilters: Map<string, string> = new Map();
currentParentFolderId: string;
constructor(appConfig: AppConfigService, alfrescoApiService: AlfrescoApiService, private nodeApiService: NodesApiService) { constructor(appConfig: AppConfigService, alfrescoApiService: AlfrescoApiService, private nodeApiService: NodesApiService) {
super(appConfig, alfrescoApiService); super(appConfig, alfrescoApiService);
this.updated.pipe(
filter((query: QueryBody) => !!query)).subscribe(() => {
this.execute();
});
} }
public isFilterServiceActive(): boolean { public isFilterServiceActive(): boolean {
@@ -53,18 +59,22 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
} }
} }
setActiveFilter(columnActivated: string) { setActiveFilter(columnActivated: string, filterValue: string) {
if (!this.activeFilters.includes(columnActivated)) { this.activeFilters.set(columnActivated, filterValue);
this.activeFilters.push(columnActivated); }
}
getActiveFilters(): Map<string, string> {
return this.activeFilters;
} }
isNoFilterActive(): boolean { isNoFilterActive(): boolean {
return this.activeFilters.length === 0; return this.activeFilters.size === 0;
} }
removeActiveFilter(columnRemoved: string) { removeActiveFilter(columnRemoved: string) {
this.activeFilters = this.activeFilters.filter((column) => column !== columnRemoved); if (this.activeFilters.get(columnRemoved) !== null) {
this.activeFilters.delete(columnRemoved);
}
} }
getCategoryForColumn(columnKey: string): SearchCategory { getCategoryForColumn(columnKey: string): SearchCategory {
@@ -78,19 +88,6 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
} }
setCurrentRootFolderId(currentFolderId: string) { setCurrentRootFolderId(currentFolderId: string) {
if (currentFolderId !== this.currentParentFolderId) {
if (this.customSources.includes(currentFolderId)) {
this.nodeApiService.getNode(currentFolderId).subscribe((nodeEntity: MinimalNode) => {
this.updateCurrentParentFilter(nodeEntity.id);
});
} else {
this.currentParentFolderId = currentFolderId;
this.updateCurrentParentFilter(currentFolderId);
}
}
}
private updateCurrentParentFilter(currentFolderId: string) {
const alreadyAddedFilter = this.filterQueries.find(filterQueries => const alreadyAddedFilter = this.filterQueries.find(filterQueries =>
filterQueries.query.includes(currentFolderId) filterQueries.query.includes(currentFolderId)
); );
@@ -104,4 +101,12 @@ export class SearchHeaderQueryBuilderService extends BaseQueryBuilderService {
}]; }];
} }
isCustomSourceNode(currentNodeId: string): boolean {
return this.customSources.includes(currentNodeId);
}
getNodeIdForCustomSource(customSourceId: string): Observable<MinimalNode> {
return this.nodeApiService.getNode(customSourceId);
}
} }

View File

@@ -23,7 +23,10 @@ export interface SearchWidget {
settings?: SearchWidgetSettings; settings?: SearchWidgetSettings;
context?: SearchQueryBuilderService; context?: SearchQueryBuilderService;
isActive?: boolean; isActive?: boolean;
startValue: any;
reset(); reset();
submitValues(); submitValues();
hasValidValue(); hasValidValue();
getCurrentValue();
setValue(value: any);
} }

View File

@@ -8,7 +8,7 @@ rm -rf tmp && mkdir tmp;
npx @alfresco/adf-cli@alpha update-commit-sha --pointer "HEAD" --pathPackage "$(pwd)" npx @alfresco/adf-cli@alpha update-commit-sha --pointer "HEAD" --pathPackage "$(pwd)"
if [[ $TRAVIS_PULL_REQUEST == "false" ]]; if [[ "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
if [[ $TRAVIS_BRANCH == "develop" ]]; if [[ $TRAVIS_BRANCH == "develop" ]];
then then

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Start Content service e2e"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../ cd $DIR/../../../
@@ -8,18 +10,20 @@ export CONTEXT_ENV="content-services"
export PROVIDER='ECM' export PROVIDER='ECM'
export AUTH_TYPE='BASIC' export AUTH_TYPE='BASIC'
if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
if [[ $TRAVIS_PULL_REQUEST == "true" ]]; then echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1; ./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1;
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")"; AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")";
echo "Affected e2e ${AFFECTED_E2E}"
fi; fi;
./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1 ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1
#-b is needed to run the Folder upload test that are not workin in Headless chrome #-b is needed to run the Folder upload test that are not workin in Headless chrome
RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -b -save -m 4 || exit 1) RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -b -save -m 4 || exit 1)
if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || $TRAVIS_PULL_REQUEST == "false" ]]; then if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || "${TRAVIS_EVENT_TYPE}" == "push" ]]; then
$RUN_CHECK $RUN_CHECK
$RUN_E2E --folder $CONTEXT_ENV $RUN_E2E --folder $CONTEXT_ENV
else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]]; else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]];

View File

@@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Start Core e2e"
echo "Start Core e2e $TRAVIS_PULL_REQUEST"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../ cd $DIR/../../../
@@ -8,17 +11,20 @@ export CONTEXT_ENV="core"
export PROVIDER='ALL' export PROVIDER='ALL'
export AUTH_TYPE='BASIC' export AUTH_TYPE='BASIC'
if [[ $TRAVIS_PULL_REQUEST == "true" ]]; then if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1; ./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1;
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")"; AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")";
echo "Affected e2e ${AFFECTED_E2E}"
fi; fi;
./node_modules/@alfresco/adf-cli/bin/adf-cli check-ps-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1 ./node_modules/@alfresco/adf-cli/bin/adf-cli check-ps-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1
./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1 ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1
RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -m 2 || exit 1) RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -m 2 || exit 1)
if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
$RUN_E2E --folder $CONTEXT_ENV || exit 1 $RUN_E2E --folder $CONTEXT_ENV || exit 1
else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]]; else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]];

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Start insight e2e"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PROVIDER='BPM' export PROVIDER='BPM'
@@ -7,12 +9,15 @@ export AUTH_TYPE='BASIC'
cd $DIR/../../../ cd $DIR/../../../
if [[ $TRAVIS_PULL_REQUEST == "true" ]]; then if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1; ./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1;
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "Affected e2e ${AFFECTED_E2E}"
fi; fi;
if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "insight" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "insight" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
./node_modules/@alfresco/adf-cli/bin/adf-cli check-ps-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1; ./node_modules/@alfresco/adf-cli/bin/adf-cli check-ps-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1;
./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --folder insights --use-dist || exit 1; ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --folder insights --use-dist || exit 1;

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "Start process services cloud e2e"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../ cd $DIR/../../../
@@ -8,10 +10,13 @@ export CONTEXT_ENV="process-services-cloud"
export PROVIDER="ALL" export PROVIDER="ALL"
export AUTH_TYPE="OAUTH" export AUTH_TYPE="OAUTH"
if [[ $TRAVIS_PULL_REQUEST == "true" ]]; then if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1; ./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1;
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")"; AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")";
echo "Affected e2e ${AFFECTED_E2E}"
fi; fi;
RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST_BPM" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" -host_sso "$E2E_HOST_SSO" -identity_admin_email "$E2E_ADMIN_EMAIL_IDENTITY" -identity_admin_password "$E2E_ADMIN_PASSWORD_IDENTITY" -prefix $TRAVIS_BUILD_NUMBER --use-dist -m 2 -save -b ) RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST_BPM" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" -host_sso "$E2E_HOST_SSO" -identity_admin_email "$E2E_ADMIN_EMAIL_IDENTITY" -identity_admin_password "$E2E_ADMIN_PASSWORD_IDENTITY" -prefix $TRAVIS_BUILD_NUMBER --use-dist -m 2 -save -b )
@@ -22,7 +27,7 @@ check_env(){
./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST_BPM" -u "$E2E_ADMIN_EMAIL_IDENTITY" -p "$E2E_ADMIN_PASSWORD_IDENTITY" || exit 1 ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST_BPM" -u "$E2E_ADMIN_EMAIL_IDENTITY" -p "$E2E_ADMIN_PASSWORD_IDENTITY" || exit 1
} }
if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
echo "Case 1 - adf-testing has been changed"; echo "Case 1 - adf-testing has been changed";
check_env; check_env;

View File

@@ -8,16 +8,21 @@ export CONTEXT_ENV="process-services"
export PROVIDER='BPM' export PROVIDER='BPM'
export AUTH_TYPE='BASIC' export AUTH_TYPE='BASIC'
if [[ $TRAVIS_PULL_REQUEST == "true" ]]; then echo "Start process services e2e"
if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1; ./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1;
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")"; AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")";
echo "Affected e2e ${AFFECTED_E2E}"
fi; fi;
./node_modules/@alfresco/adf-cli/bin/adf-cli check-ps-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1 ./node_modules/@alfresco/adf-cli/bin/adf-cli check-ps-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1
RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -m 2 || exit 1) RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -m 2 || exit 1)
if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "$CONTEXT_ENV" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
$RUN_E2E --folder $CONTEXT_ENV $RUN_E2E --folder $CONTEXT_ENV
else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]]; else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]];

View File

@@ -2,22 +2,27 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Start search e2e"
cd $DIR/../../../ cd $DIR/../../../
export CONTEXT_ENV="search" export CONTEXT_ENV="search"
export PROVIDER='ECM' export PROVIDER='ECM'
export AUTH_TYPE='BASIC' export AUTH_TYPE='BASIC'
if [[ $TRAVIS_PULL_REQUEST == "true" ]]; then if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ];then
echo "Calculate affected e2e $BASE_HASH $HEAD_HASH"
./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1; ./scripts/git-util/check-branch-updated.sh -b $TRAVIS_BRANCH || exit 1;
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "Affected libs ${AFFECTED_LIBS}"
AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")"; AFFECTED_E2E="$(./scripts/git-util/affected-folder.sh -b $TRAVIS_BRANCH -f "e2e/$CONTEXT_ENV")";
echo "Affected e2e ${AFFECTED_E2E}"
fi; fi;
./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1 ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" || exit 1
RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -m 2 || exit 1) RUN_E2E=$(echo ./scripts/test-e2e-lib.sh -host http://localhost:4200 -proxy "$E2E_HOST" -u "$E2E_USERNAME" -p "$E2E_PASSWORD" -e "$E2E_EMAIL" --use-dist -m 2 || exit 1)
if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "content-services" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "testing" || $AFFECTED_LIBS =~ "content-services" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
$RUN_E2E --folder $CONTEXT_ENV $RUN_E2E --folder $CONTEXT_ENV
else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]]; else if [[ $AFFECTED_E2E = "e2e/$CONTEXT_ENV" ]];

View File

@@ -4,7 +4,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/../../../ cd $DIR/../../../
if [[ $TRAVIS_PULL_REQUEST == "false" ]]; if [[ "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
TAG_NPM=latest TAG_NPM=latest
if [[ $TRAVIS_BRANCH == "develop" ]]; if [[ $TRAVIS_BRANCH == "develop" ]];

View File

@@ -9,7 +9,7 @@ ng test content-services --watch=false || exit 1;
# echo "================== content-services unit ===================" # echo "================== content-services unit ==================="
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
if [[ $AFFECTED_LIBS =~ "content-services" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "content-services" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
ng test content-services --watch=false || exit 1; ng test content-services --watch=false || exit 1;
fi; fi;

View File

@@ -9,14 +9,14 @@ AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "================== core unit ===================" echo "================== core unit ==================="
if [[ $AFFECTED_LIBS =~ "core" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "core" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
ng test core --watch=false || exit 1; ng test core --watch=false || exit 1;
fi; fi;
echo "================== extensions unit ===================" echo "================== extensions unit ==================="
if [[ $AFFECTED_LIBS =~ "extensions" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "extensions" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
ng test extensions --watch=false || exit 1; ng test extensions --watch=false || exit 1;
fi; fi;

View File

@@ -10,19 +10,19 @@ cd $DIR/../../../
AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)" AFFECTED_LIBS="$(nx affected:libs --base=$BASE_HASH --head=$HEAD_HASH --plain)"
echo "================== process-services unit ===================" echo "================== process-services unit ==================="
if [[ $AFFECTED_LIBS =~ "process-services" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "process-services" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
ng test process-services --watch=false || exit 1; ng test process-services --watch=false || exit 1;
fi; fi;
echo "================== insights unit ===================" echo "================== insights unit ==================="
if [[ $AFFECTED_LIBS =~ "insights" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "insights" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
ng test insights --watch=false || exit 1; ng test insights --watch=false || exit 1;
fi; fi;
echo "================== process-services-cloud unit ===================" echo "================== process-services-cloud unit ==================="
if [[ $AFFECTED_LIBS =~ "process-services-cloud" || $TRAVIS_PULL_REQUEST == "false" ]]; if [[ $AFFECTED_LIBS =~ "process-services-cloud" || "${TRAVIS_EVENT_TYPE}" == "push" ]];
then then
ng test process-services-cloud --watch=false || exit 1; ng test process-services-cloud --watch=false || exit 1;
fi; fi;