Skip to content

Commit 34e93ee

Browse files
Merge branch '26_1' into issue-4222_26_1
2 parents e9fa2a3 + 4e8dd4e commit 34e93ee

8 files changed

Lines changed: 1280 additions & 284 deletions

File tree

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@
117117
"@tootallnate/once@<3.0.1": "^3.0.1",
118118
"dompurify@<=3.3.3": ">=3.4.0",
119119
"brace-expansion@<1.1.13": "^1.1.13",
120-
"brace-expansion@>=2.0.0 <2.0.3": "^5.0.5",
121-
"brace-expansion@>=4.0.0 <5.0.5": "^5.0.5",
120+
"brace-expansion@>=2.0.0 <2.0.3": "^5.0.6",
121+
"brace-expansion@>=4.0.0 <5.0.6": "^5.0.6",
122122
"yaml@>=2.0.0 <2.8.3": "^2.8.3",
123123
"follow-redirects@<=1.15.11": ">=1.16.0",
124-
"@angular/platform-server@>=20.0.0-next.0 <20.3.19": "^20.3.19",
124+
"@angular/platform-server@>=21.0.0-next.0 <21.2.13": "^21.2.13",
125+
"ws@>=8.0.0 <8.20.1": "^8.20.1",
125126
"stylelint-config-recommended-vue@1.6.1>stylelint-config-recommended": "^16.0.0",
126127
"uuid@<14.0.0": "~14.0.0",
127128
"postcss@<8.5.10": "8.5.10",

packages/devextreme/js/__internal/grids/data_grid/__tests__/__mock__/model/data_grid.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import type { Column } from '@js/ui/data_grid';
22
import DataGrid from '@js/ui/data_grid';
3+
import type { DataGridInstance } from '@ts/grids/grid_core/__tests__/__mock__/helpers/utils';
34
import { DataGridBaseModel } from '@ts/grids/grid_core/__tests__/__mock__/model/data_grid_base';
45

56
export class DataGridModel extends DataGridBaseModel<DataGrid> {
67
protected NAME = 'dxDataGrid';
78

8-
public getInstance(): DataGrid {
9-
return DataGrid.getInstance(this.root) as DataGrid;
9+
public getInstance(): DataGridInstance {
10+
return DataGrid.getInstance(this.root) as DataGridInstance;
1011
}
1112

1213
public apiGetVisibleColumns(headerLevel?: number): Column[] {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import type { ArrayStore } from '@js/common/data';
2+
import type { Message } from '@js/ui/chat';
3+
import DataGrid from '@js/ui/data_grid';
4+
import type { DataGridInstance } from '@ts/grids/grid_core/__tests__/__mock__/helpers/utils';
5+
import { AIChatModel } from '@ts/grids/grid_core/__tests__/__mock__/model/ai_chat';
6+
import { DataGridBaseModel } from '@ts/grids/grid_core/__tests__/__mock__/model/data_grid_base';
7+
import type { AIAssistantController } from '@ts/grids/grid_core/ai_assistant/ai_assistant_controller';
8+
import type { AIAssistantViewController } from '@ts/grids/grid_core/ai_assistant/ai_assistant_view_controller';
9+
import type { AIMessage } from '@ts/grids/grid_core/ai_assistant/types';
10+
11+
export class AIAssistantDataGridModel extends DataGridBaseModel<DataGrid> {
12+
protected NAME = 'dxDataGrid';
13+
14+
public getInstance(): DataGridInstance {
15+
return DataGrid.getInstance(this.root) as DataGridInstance;
16+
}
17+
18+
public getAiAssistantController(): AIAssistantController {
19+
return this.getInstance().getController('aiAssistant');
20+
}
21+
22+
public getAiAssistantViewController(): AIAssistantViewController {
23+
return this.getInstance().getController('aiAssistantViewController');
24+
}
25+
26+
public sendAiRequest(text: string): void {
27+
const controller = this.getAiAssistantController();
28+
29+
controller
30+
.sendRequestToAI({
31+
author: { id: 'user', name: 'User' },
32+
text,
33+
timestamp: new Date().toISOString(),
34+
} as Message)
35+
.catch(() => {});
36+
}
37+
38+
public sendAiRequestRaw(message: Message | AIMessage): Promise<void> {
39+
return this.getAiAssistantController().sendRequestToAI(message);
40+
}
41+
42+
public getMessageStore(): ArrayStore<Message, string> {
43+
return this.getAiAssistantController().getMessageStore();
44+
}
45+
46+
public loadMessages(): Promise<Message[]> {
47+
return this.getMessageStore().load() as Promise<Message[]>;
48+
}
49+
50+
public getAiChatModel(): AIChatModel {
51+
return new AIChatModel();
52+
}
53+
54+
public async togglePopup(): Promise<void> {
55+
await this.getAiAssistantViewController().toggle();
56+
}
57+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { dxElementWrapper } from '@js/core/renderer';
2+
import $ from '@js/core/renderer';
3+
import { MessageStatus } from '@ts/grids/grid_core/ai_assistant/const';
4+
import { CLASSES } from '@ts/grids/grid_core/ai_chat/const';
5+
6+
export class AIChatModel {
7+
protected readonly root: dxElementWrapper;
8+
9+
constructor() {
10+
this.root = $(`.${CLASSES.aiChat}`);
11+
}
12+
13+
public getMessages(): dxElementWrapper {
14+
return this.root.find(`.${CLASSES.message}`);
15+
}
16+
17+
public getMessage(messageIndex: number): dxElementWrapper {
18+
return this.getMessages().eq(messageIndex);
19+
}
20+
21+
public getMessageStatus(messageIndex: number): MessageStatus {
22+
const $message = this.getMessage(messageIndex);
23+
if ($message.hasClass(CLASSES.messagePending)) {
24+
return MessageStatus.Pending;
25+
}
26+
if ($message.hasClass(CLASSES.messageSuccess)) {
27+
return MessageStatus.Success;
28+
}
29+
if ($message.hasClass(CLASSES.messageError)) {
30+
return MessageStatus.Failure;
31+
}
32+
return '' as never;
33+
}
34+
35+
public getErrorMessage(messageIndex: number): dxElementWrapper {
36+
return this.getMessage(messageIndex)
37+
.find(`.${CLASSES.messageErrorText}`);
38+
}
39+
40+
public getActionList(messageIndex: number): dxElementWrapper {
41+
return this.getMessage(messageIndex)
42+
.find(`.${CLASSES.actionListItemText}`);
43+
}
44+
45+
public getRegenerateButton(messageIndex: number): HTMLElement {
46+
return this.getMessage(messageIndex)
47+
.find(`.${CLASSES.messageRegenerateButton}`)
48+
.get(0) as HTMLElement;
49+
}
50+
}

0 commit comments

Comments
 (0)