Skip to content

Commit a4d399c

Browse files
fix(chatbot): inactivated refresh button and inputs when the message is generated by the assistant
1 parent aa8f1c0 commit a4d399c

File tree

16 files changed

+67
-16
lines changed

16 files changed

+67
-16
lines changed
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
<ai-card-footer>
22
<ai-controls>
33
@if (isTranscriptionEnabled) {
4-
<ai-recorder (send$)="sendAudio$.emit($event)" matTooltip="Record audio" />
4+
<ai-recorder
5+
(send$)="sendAudio$.emit($event)"
6+
[isDisabled]="isDisabled"
7+
[matTooltip]="!isDisabled ? 'Record audio' : ''"
8+
/>
59
} @if (isAttachmentEnabled) {
6-
<ai-files matTooltip="Add files" />
10+
<ai-files
11+
[matTooltip]="!isDisabled ? 'Add files' : ''"
12+
[isDisabled]="isDisabled"
13+
/>
714
}
815
</ai-controls>
916

10-
<ai-input [isDisabled]="isDisabled" (send$)="sendMessage$.emit($event)" />
17+
<ai-input
18+
(send$)="!isDisabled && sendMessage$.emit($event)"
19+
[isDisabled]="isDisabled"
20+
/>
1121
</ai-card-footer>

apps/spa/src/app/components/chat/chat-header/chat-header.component.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
</div>
55
<div class="chat-header__controls">
66
@if (isConfigEnabled) {
7-
<button mat-icon-button (click)="config$.emit()" matTooltip="Settings">
7+
<button
8+
mat-icon-button
9+
matTooltip="Settings"
10+
(click)="config$.emit()"
11+
>
812
<mat-icon class="char-header__icon">settings</mat-icon>
913
</button>
1014
} @if (isRefreshEnabled) {
11-
<button mat-icon-button (click)="refresh$.emit()" matTooltip="Refresh">
15+
<button
16+
mat-icon-button
17+
matTooltip="Refresh"
18+
(click)="refresh$.emit()"
19+
[disabled]="isResponding"
20+
>
1221
<mat-icon class="char-header__icon">refresh</mat-icon>
1322
</button>
1423
}

apps/spa/src/app/components/chat/chat-header/chat-header.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class ChatHeaderComponent {
1414
@Output() close$ = new EventEmitter();
1515
@Output() refresh$ = new EventEmitter();
1616
@Output() config$ = new EventEmitter();
17+
@Input() isResponding = false;
1718
@Input() isRefreshEnabled = true;
1819
@Input() isConfigEnabled = true;
1920

apps/spa/src/app/components/controls/control-item/control-item.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@
2222
background-color: var(--color-grey-300);
2323
color: var(--color-grey-900);
2424
}
25+
26+
&.is-disabled {
27+
pointer-events: none;
28+
opacity: 0.5;
29+
}
2530
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { Component } from '@angular/core';
1+
import { Component, HostBinding, Input } from '@angular/core';
22

33
@Component({
44
selector: 'ai-control-item',
55
standalone: true,
66
templateUrl: './control-item.component.html',
77
styleUrl: './control-item.component.scss',
88
})
9-
export class ControlItemComponent {}
9+
export class ControlItemComponent {
10+
@HostBinding('class.is-disabled') @Input() isDisabled = false;
11+
}

apps/spa/src/app/components/controls/files/files.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
aiFiles
33
(click)="input.click()"
44
(drop$)="addFiles($event)"
5-
[files]="files()">
5+
[files]="files()"
6+
[isDisabled]="isDisabled"
7+
>
68
<ai-control-icon>attach_file</ai-control-icon>
79

810
@if (files().length) {

apps/spa/src/app/components/controls/files/files.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild } from '@angular/core';
1+
import { Component, Input, ViewChild } from '@angular/core';
22
import { MatIcon } from '@angular/material/icon';
33
import { AiFilesDirective } from './files.directive';
44
import { toSignal } from '@angular/core/rxjs-interop';
@@ -20,6 +20,7 @@ import { ControlIconComponent } from '../control-icon/control-icon.component';
2020
})
2121
export class FilesComponent {
2222
@ViewChild('input') input!: HTMLInputElement;
23+
@Input() isDisabled = false;
2324
files = toSignal(this.fileService.files$, { initialValue: [] });
2425

2526
constructor(private readonly fileService: FilesService) {}

apps/spa/src/app/components/controls/input/input.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
placeholder="Aa"
55
autocomplete="off"
66
[(ngModel)]="content"
7-
[disabled]="isDisabled"
8-
(keydown.enter)="send(content)" />
7+
(keydown.enter)="!isDisabled && send(content)" />
98
<button
109
class="input__suffix"
1110
mat-icon-button

apps/spa/src/app/components/controls/input/input.component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55

66
.input__suffix {
77
margin-right: 4px;
8+
9+
&.mat-mdc-button-disabled {
10+
opacity: 0.5;
11+
}
812
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<ai-control-item [ngClass]="{ 'is-active': recording }" (click)="onRecord()">
1+
<ai-control-item
2+
(click)="onRecord()"
3+
[ngClass]="{ 'is-active': recording }"
4+
[isDisabled]="isDisabled"
5+
>
26
<ai-control-icon class="recorder__icon">mic</ai-control-icon>
37
<div class="recorder__circle"></div>
48
</ai-control-item>

0 commit comments

Comments
 (0)