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