mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACS-8907] Remove query / question from input on the results page (#4189)
* [ACS-8907] Remove query / question from input on the results page * [ACS-8907] Remove query / question from input on the results page
This commit is contained in:
parent
e743a38117
commit
092a57f8b9
@ -2,7 +2,7 @@
|
|||||||
[searchTerm]="(inputState$ | async).searchTerm"
|
[searchTerm]="(inputState$ | async).searchTerm"
|
||||||
[placeholder]="placeholder"
|
[placeholder]="placeholder"
|
||||||
[agentId]="agentId"
|
[agentId]="agentId"
|
||||||
[useStoredNodes]="useStoredNodes">
|
[usedInAiResultsPage]="usedInAiResultsPage">
|
||||||
</aca-search-ai-input>
|
</aca-search-ai-input>
|
||||||
<mat-divider
|
<mat-divider
|
||||||
[vertical]="true"
|
[vertical]="true"
|
||||||
|
@ -126,11 +126,11 @@ describe('SearchAiInputContainerComponent', () => {
|
|||||||
expect(inputComponent.agentId).toBe(component.agentId);
|
expect(inputComponent.agentId).toBe(component.agentId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have assigned correct useStoredNodes flag', () => {
|
it('should have assigned correct usedInAiResultsPage flag', () => {
|
||||||
component.useStoredNodes = true;
|
component.usedInAiResultsPage = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(inputComponent.useStoredNodes).toBeTrue();
|
expect(inputComponent.usedInAiResultsPage).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set inputState$ to toggleSearchAiInput$ from the service on ngOnInit', () => {
|
it('should set inputState$ to toggleSearchAiInput$ from the service on ngOnInit', () => {
|
||||||
|
@ -48,7 +48,7 @@ export class SearchAiInputContainerComponent implements OnInit {
|
|||||||
@Input()
|
@Input()
|
||||||
agentId: string;
|
agentId: string;
|
||||||
@Input()
|
@Input()
|
||||||
useStoredNodes: boolean;
|
usedInAiResultsPage: boolean;
|
||||||
|
|
||||||
inputState$: Observable<SearchAiInputState>;
|
inputState$: Observable<SearchAiInputState>;
|
||||||
isKnowledgeRetrievalPage = false;
|
isKnowledgeRetrievalPage = false;
|
||||||
|
@ -56,8 +56,18 @@ describe('SearchAiInputComponent', () => {
|
|||||||
let agents$: Subject<Agent[]>;
|
let agents$: Subject<Agent[]>;
|
||||||
let dialog: MatDialog;
|
let dialog: MatDialog;
|
||||||
let activatedRoute: ActivatedRoute;
|
let activatedRoute: ActivatedRoute;
|
||||||
|
let userPreferencesService: UserPreferencesService;
|
||||||
let agentList: Agent[];
|
let agentList: Agent[];
|
||||||
|
|
||||||
|
const newSelectionState: SelectionState = {
|
||||||
|
...selectionState,
|
||||||
|
file: {
|
||||||
|
entry: {
|
||||||
|
id: 'some-id'
|
||||||
|
}
|
||||||
|
} as NodeEntry
|
||||||
|
};
|
||||||
|
|
||||||
const prepareBeforeTest = (): void => {
|
const prepareBeforeTest = (): void => {
|
||||||
selectionState = {
|
selectionState = {
|
||||||
nodes: [],
|
nodes: [],
|
||||||
@ -94,6 +104,10 @@ describe('SearchAiInputComponent', () => {
|
|||||||
loader = TestbedHarnessEnvironment.loader(fixture);
|
loader = TestbedHarnessEnvironment.loader(fixture);
|
||||||
agents$ = new Subject<Agent[]>();
|
agents$ = new Subject<Agent[]>();
|
||||||
dialog = TestBed.inject(MatDialog);
|
dialog = TestBed.inject(MatDialog);
|
||||||
|
userPreferencesService = TestBed.inject(UserPreferencesService);
|
||||||
|
spyOn(userPreferencesService, 'get').and.returnValue(JSON.stringify(newSelectionState));
|
||||||
|
spyOn(userPreferencesService, 'set');
|
||||||
|
spyOn(TestBed.inject(AgentService), 'getAgents').and.returnValue(agents$);
|
||||||
agentList = [
|
agentList = [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
@ -108,7 +122,6 @@ describe('SearchAiInputComponent', () => {
|
|||||||
avatarUrl: undefined
|
avatarUrl: undefined
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
spyOn(TestBed.inject(AgentService), 'getAgents').and.returnValue(agents$);
|
|
||||||
prepareBeforeTest();
|
prepareBeforeTest();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -143,12 +156,24 @@ describe('SearchAiInputComponent', () => {
|
|||||||
expect(component.queryControl.value).toBe(query);
|
expect(component.queryControl.value).toBe(query);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set queryControl value to query param if searchTerm is not defined', () => {
|
it('should set queryControl value to "some new query" if usedInAiResultsPage is equal to false', () => {
|
||||||
component.searchTerm = undefined;
|
const query = 'some new query';
|
||||||
|
component.usedInAiResultsPage = false;
|
||||||
|
component.searchTerm = query;
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
expect(component.queryControl.value).toBe('some query');
|
expect(component.queryControl.value).toBe('some new query');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set queryControl value to empty string if usedInAiResultsPage is equal to true', () => {
|
||||||
|
const query = 'some new query';
|
||||||
|
component.usedInAiResultsPage = true;
|
||||||
|
component.searchTerm = query;
|
||||||
|
|
||||||
|
component.ngOnInit();
|
||||||
|
|
||||||
|
expect(component.queryControl.value).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get agents on init', () => {
|
it('should get agents on init', () => {
|
||||||
@ -285,7 +310,6 @@ describe('SearchAiInputComponent', () => {
|
|||||||
|
|
||||||
it('should be disabled by default', () => {
|
it('should be disabled by default', () => {
|
||||||
activatedRoute.snapshot.queryParams = { query: '' };
|
activatedRoute.snapshot.queryParams = { query: '' };
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -320,7 +344,6 @@ describe('SearchAiInputComponent', () => {
|
|||||||
describe('Submitting', () => {
|
describe('Submitting', () => {
|
||||||
let checkSearchAvailabilitySpy: jasmine.Spy<(selectedNodesState: SelectionState, maxSelectedNodes?: number) => string>;
|
let checkSearchAvailabilitySpy: jasmine.Spy<(selectedNodesState: SelectionState, maxSelectedNodes?: number) => string>;
|
||||||
let notificationService: NotificationService;
|
let notificationService: NotificationService;
|
||||||
let userPreferencesService: UserPreferencesService;
|
|
||||||
let submitButton: DebugElement;
|
let submitButton: DebugElement;
|
||||||
let queryInput: MatInputHarness;
|
let queryInput: MatInputHarness;
|
||||||
let submittingTrigger: () => void;
|
let submittingTrigger: () => void;
|
||||||
@ -334,8 +357,6 @@ describe('SearchAiInputComponent', () => {
|
|||||||
modalAiService = TestBed.inject(ModalAiService);
|
modalAiService = TestBed.inject(ModalAiService);
|
||||||
checkSearchAvailabilitySpy = spyOn(TestBed.inject(SearchAiService), 'checkSearchAvailability');
|
checkSearchAvailabilitySpy = spyOn(TestBed.inject(SearchAiService), 'checkSearchAvailability');
|
||||||
notificationService = TestBed.inject(NotificationService);
|
notificationService = TestBed.inject(NotificationService);
|
||||||
userPreferencesService = TestBed.inject(UserPreferencesService);
|
|
||||||
spyOn(userPreferencesService, 'set');
|
|
||||||
spyOn(notificationService, 'showError');
|
spyOn(notificationService, 'showError');
|
||||||
queryInput = await loader.getHarness(MatInputHarness);
|
queryInput = await loader.getHarness(MatInputHarness);
|
||||||
submitButton = fixture.debugElement.query(By.directive(MatButton));
|
submitButton = fixture.debugElement.query(By.directive(MatButton));
|
||||||
@ -376,16 +397,7 @@ describe('SearchAiInputComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call checkSearchAvailability on SearchAiService with parameter based on value returned by UserPreferencesService', () => {
|
it('should call checkSearchAvailability on SearchAiService with parameter based on value returned by UserPreferencesService', () => {
|
||||||
component.useStoredNodes = true;
|
component.usedInAiResultsPage = true;
|
||||||
const newSelectionState: SelectionState = {
|
|
||||||
...selectionState,
|
|
||||||
file: {
|
|
||||||
entry: {
|
|
||||||
id: 'some-id'
|
|
||||||
}
|
|
||||||
} as NodeEntry
|
|
||||||
};
|
|
||||||
spyOn(userPreferencesService, 'get').and.returnValue(JSON.stringify(newSelectionState));
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
submittingTrigger();
|
submittingTrigger();
|
||||||
|
|
||||||
@ -400,16 +412,7 @@ describe('SearchAiInputComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call set on UserPreferencesService with parameter based on value returned by UserPreferencesService', () => {
|
it('should call set on UserPreferencesService with parameter based on value returned by UserPreferencesService', () => {
|
||||||
component.useStoredNodes = true;
|
component.usedInAiResultsPage = true;
|
||||||
const newSelectionState: SelectionState = {
|
|
||||||
...selectionState,
|
|
||||||
file: {
|
|
||||||
entry: {
|
|
||||||
id: 'some-id'
|
|
||||||
}
|
|
||||||
} as NodeEntry
|
|
||||||
};
|
|
||||||
spyOn(userPreferencesService, 'get').and.returnValue(JSON.stringify(newSelectionState));
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
submittingTrigger();
|
submittingTrigger();
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@ import {
|
|||||||
} from '@angular/material/tooltip';
|
} from '@angular/material/tooltip';
|
||||||
import { ModalAiService } from '../../../../services/modal-ai.service';
|
import { ModalAiService } from '../../../../services/modal-ai.service';
|
||||||
import { Agent } from '@alfresco/js-api';
|
import { Agent } from '@alfresco/js-api';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
|
||||||
|
|
||||||
const MatTooltipOptions: MatTooltipDefaultOptions = {
|
const MatTooltipOptions: MatTooltipDefaultOptions = {
|
||||||
...MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY(),
|
...MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY(),
|
||||||
@ -87,7 +86,7 @@ export class SearchAiInputComponent implements OnInit, OnDestroy {
|
|||||||
agentId: string;
|
agentId: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
useStoredNodes: boolean;
|
usedInAiResultsPage: boolean;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
@ -124,20 +123,14 @@ export class SearchAiInputComponent implements OnInit, OnDestroy {
|
|||||||
private agentService: AgentService,
|
private agentService: AgentService,
|
||||||
private userPreferencesService: UserPreferencesService,
|
private userPreferencesService: UserPreferencesService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private modalAiService: ModalAiService,
|
private modalAiService: ModalAiService
|
||||||
private route: ActivatedRoute
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.searchTerm) {
|
const queryValue = this.usedInAiResultsPage ? '' : this.searchTerm || '';
|
||||||
this.queryControl.setValue(this.searchTerm);
|
this.queryControl.setValue(queryValue);
|
||||||
} else if (this.route.snapshot?.queryParams?.query?.length > 0) {
|
|
||||||
this.queryControl.setValue(this.route.snapshot.queryParams.query);
|
|
||||||
} else {
|
|
||||||
this.queryControl.setValue(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.useStoredNodes) {
|
if (!this.usedInAiResultsPage) {
|
||||||
this.store
|
this.store
|
||||||
.select(getAppSelection)
|
.select(getAppSelection)
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
class="aca-page-layout-header"
|
class="aca-page-layout-header"
|
||||||
placeholder="KNOWLEDGE_RETRIEVAL.SEARCH.RESULTS_PAGE.QUERY_INPUT_PLACEHOLDER"
|
placeholder="KNOWLEDGE_RETRIEVAL.SEARCH.RESULTS_PAGE.QUERY_INPUT_PLACEHOLDER"
|
||||||
[agentId]="agentId"
|
[agentId]="agentId"
|
||||||
[useStoredNodes]="true"
|
[usedInAiResultsPage]="true"
|
||||||
*ngIf="!hasError && agentId">
|
*ngIf="!hasError && agentId">
|
||||||
</aca-search-ai-input-container>
|
</aca-search-ai-input-container>
|
||||||
<div
|
<div
|
||||||
|
Loading…
x
Reference in New Issue
Block a user