-
Notifications
You must be signed in to change notification settings - Fork 667
✨AI Column: Create handling errors mechanism using Toasts instead of ErrorRow #31182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b615352
add toast to dataGrid
dmlvr 1600197
some small fix for view and container + add test
dmlvr f11a1ce
Merge branch '25_2' into dg_25_2_ai_column_toats
dmlvr 021658d
fix lint for test
dmlvr ccb086f
merge updat 25_2
dmlvr 6a20863
fix lint error
dmlvr 01593dd
fix test
dmlvr ddc784b
add showErrorToast in ErrorHandlingController
dmlvr a188fa1
merge 25_2
dmlvr 442a517
fix lint
dmlvr 8e14a6e
upload current screen
dmlvr acd9476
fix after review
dmlvr 1873f29
register toast module in treeList and add 2e2 test for treeList
dmlvr 3d27fda
Merge branch '25_2' into dg_25_2_ai_column_toats
dmlvr 77c913c
some fix test
dmlvr 3f14f60
added screen
dmlvr e59e12a
remane screen
dmlvr 7375829
update screen
dmlvr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+3.15 KB
...treme/tests/dataGrid/common/etalons/ai-column__toast__at-the-right-position.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import DataGrid from 'devextreme-testcafe-models/dataGrid'; | ||
| import { createScreenshotsComparer } from 'devextreme-screenshot-comparer'; | ||
| import url from '../../../helpers/getPageUrl'; | ||
| import { createWidget } from '../../../helpers/createWidget'; | ||
|
|
||
| fixture.disablePageReloads`Toasts in DataGrid`.page( | ||
| url(__dirname, '../../container.html'), | ||
| ); | ||
|
|
||
| test('Toast should be visible after calling and should be not visible after default display time', async (t) => { | ||
| const dataGrid = new DataGrid('#container'); | ||
| const { takeScreenshot, compareResults } = createScreenshotsComparer(t); | ||
| await dataGrid.isReady(); | ||
| await dataGrid.apiShowErrorToast(); | ||
| await t.expect(dataGrid.getToast().exists).ok(); | ||
| await t | ||
| .expect(await takeScreenshot('ai-column__toast__at-the-right-position.png', dataGrid.element)) | ||
| .ok() | ||
| .expect(compareResults.isValid()) | ||
| .ok(compareResults.errorMessages()); | ||
| await t.expect(dataGrid.getToast().exists).notOk(); | ||
| }).before(async () => { | ||
| createWidget('dxDataGrid', {}); | ||
| }); |
Binary file added
BIN
+3.15 KB
...e-devextreme/tests/treeList/etalons/ai-column__toast__at-the-right-position.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { createScreenshotsComparer } from 'devextreme-screenshot-comparer'; | ||
| import TreeList from 'devextreme-testcafe-models/treeList'; | ||
| import url from '../../helpers/getPageUrl'; | ||
| import { createWidget } from '../../helpers/createWidget'; | ||
|
|
||
| fixture`Toasts in TreeList` | ||
| .page(url(__dirname, '../container.html')); | ||
|
|
||
| test('Toast should be visible after calling and should be not visible after default display time', async (t) => { | ||
| const treeList = new TreeList('#container'); | ||
| const { takeScreenshot, compareResults } = createScreenshotsComparer(t); | ||
| await treeList.isReady(); | ||
| await treeList.apiShowErrorToast(); | ||
| await t.expect(treeList.getToast().exists).ok(); | ||
| await t | ||
| .expect(await takeScreenshot('ai-column__toast__at-the-right-position.png', treeList.element)) | ||
| .ok() | ||
| .expect(compareResults.isValid()) | ||
| .ok(compareResults.errorMessages()); | ||
| await t.expect(treeList.getToast().exists).notOk(); | ||
| }).before(async () => { | ||
| createWidget('dxTreeList', {}); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/devextreme/js/__internal/grids/data_grid/module_not_extended/toast.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { ToastViewController } from '@ts/grids/grid_core/toast/m_toast_controller'; | ||
| import { ToastView } from '@ts/grids/grid_core/toast/m_toast_view'; | ||
|
|
||
| import gridCore from '../m_core'; | ||
|
|
||
| gridCore.registerModule('toast', { | ||
| defaultOptions() { | ||
| return {}; | ||
| }, | ||
| controllers: { | ||
| toastViewController: ToastViewController, | ||
| }, | ||
| views: { | ||
| toastView: ToastView, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/devextreme/js/__internal/grids/grid_core/toast/m_toast_controller.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { Properties as ToastProperties } from '@js/ui/toast'; | ||
|
|
||
| import { ViewController } from '../m_modules'; | ||
| import type { ToastView } from './m_toast_view'; | ||
|
|
||
| export class ToastViewController extends ViewController { | ||
| private _toastView: ToastView | null = null; | ||
|
|
||
| public init(): void { | ||
| this._toastView = this.getView('toastView'); | ||
| } | ||
|
|
||
| public showToast(message: string, options: ToastProperties = {}): void { | ||
| this._toastView?.showToast(message, options); | ||
| } | ||
|
|
||
| public async hideToast(): Promise<void> { | ||
| await this._toastView?.hideToast(); | ||
| } | ||
|
|
||
| public dispose(): void { | ||
| this._toastView?.dispose(); | ||
| } | ||
| } |
62 changes: 62 additions & 0 deletions
62
packages/devextreme/js/__internal/grids/grid_core/toast/m_toast_view.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import $ from '@js/core/renderer'; | ||
| import type { Properties as ToastProperties } from '@js/ui/toast'; | ||
| import type dxToast from '@js/ui/toast'; | ||
|
|
||
| import { View } from '../m_modules'; | ||
|
|
||
| const DEFAULT_POSITION = { my: 'center bottom', at: 'center bottom' }; | ||
|
|
||
| export class ToastView extends View { | ||
| private _toastInstance: dxToast | null = null; | ||
|
|
||
| private _$toastContainer: any | null = null; | ||
|
|
||
| private _ensureToastContainer(): void { | ||
| if (!this._$toastContainer) { | ||
| this._$toastContainer = $('<div>').appendTo(this.component.$element()); | ||
| } | ||
| } | ||
|
|
||
| private _createToastInstance(options: ToastProperties): dxToast | null { | ||
| this._ensureToastContainer(); | ||
|
|
||
| if (this._toastInstance) { | ||
| return this._toastInstance; | ||
| } | ||
|
|
||
| this._toastInstance = this._$toastContainer.dxToast({ | ||
| position: { | ||
| ...DEFAULT_POSITION, | ||
| of: this.component.$element(), | ||
| }, | ||
| ...options, | ||
| visible: false, | ||
| }).dxToast('instance'); | ||
|
|
||
| return this._toastInstance; | ||
| } | ||
|
|
||
| public showToast(message: string, options: ToastProperties = {}): void { | ||
| const toast = this._createToastInstance(options); | ||
| toast?.option({ | ||
| ...options, | ||
| message, | ||
| visible: true, | ||
| }); | ||
| } | ||
|
|
||
| public async hideToast(): Promise<void> { | ||
| await this._toastInstance?.hide(); | ||
| } | ||
|
|
||
| public dispose(): void { | ||
| if (this._toastInstance) { | ||
| this._toastInstance.dispose(); | ||
| this._toastInstance = null; | ||
| } | ||
| if (this._$toastContainer) { | ||
| this._$toastContainer.remove(); | ||
| this._$toastContainer = null; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/devextreme/js/__internal/grids/tree_list/module_not_extended/toast.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { ToastViewController } from '@ts/grids/grid_core/toast/m_toast_controller'; | ||
| import { ToastView } from '@ts/grids/grid_core/toast/m_toast_view'; | ||
|
|
||
| import gridCore from '../m_core'; | ||
|
|
||
| gridCore.registerModule('toast', { | ||
| controllers: { | ||
| toastViewController: ToastViewController, | ||
| }, | ||
| views: { | ||
| toastView: ToastView, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.