Skip to content

Commit 901bb8c

Browse files
author
Alyar
committed
Fix remarks
1 parent 013a282 commit 901bb8c

File tree

13 files changed

+311
-431
lines changed

13 files changed

+311
-431
lines changed

packages/devextreme/js/__internal/grids/grid_core/header_panel/m_header_panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { Properties as ToolbarProperties } from '@js/ui/toolbar';
77
import Toolbar from '@js/ui/toolbar';
88
import type { EditingController } from '@ts/grids/grid_core/editing/m_editing';
99
import type { HeaderFilterController } from '@ts/grids/grid_core/header_filter/m_header_filter';
10-
import { normalizeToolbarItems } from '@ts/grids/new/grid_core/utils';
10+
import { normalizeToolbarItems } from '@ts/grids/new/grid_core/toolbar/utils';
1111

1212
import type { ModuleType } from '../m_types';
1313
import { ColumnsView } from '../views/m_columns_view';

packages/devextreme/js/__internal/grids/new/card_view/__snapshots__/widget.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`common initial render should be successfull 1`] = `
44
<div
55
class="dx-widget dx-cardview"
66
>
7+
78
This is cardView
89
</div>
910
`;

packages/devextreme/js/__internal/grids/new/grid_core/inferno_wrappers/toolbar.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ export class Toolbar extends InfernoWrapper<ToolbarProps, dxToolbar> {
2929
});
3030
}
3131
});
32-
const propsToUpdate = { ...props };
33-
delete propsToUpdate.items;
32+
33+
const { items, ...propsToUpdate } = props;
34+
3435
super.updateComponentOptions(prevProps, propsToUpdate);
3536
} else {
3637
super.updateComponentOptions(prevProps, props);

packages/devextreme/js/__internal/grids/new/grid_core/toolbar/__snapshots__/view.test.ts.snap renamed to packages/devextreme/js/__internal/grids/new/grid_core/toolbar/__snapshots__/options.test.ts.snap

Lines changed: 16 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Applying options when changing a visible to 'false' at runtime Toolbar should be hidden 1`] = `
4-
<div>
5-
6-
</div>
7-
`;
8-
9-
exports[`Applying options when changing a visible to 'true' at runtime Toolbar should be visible 1`] = `
10-
<div>
11-
<div
12-
class="dx-toolbar dx-widget dx-visibility-change-handler dx-collection dx-toolbar-mini"
13-
role="toolbar"
14-
>
15-
<div
16-
class="dx-toolbar-items-container"
17-
>
18-
<div
19-
class="dx-toolbar-before"
20-
role="presentation"
21-
/>
22-
<div
23-
class="dx-toolbar-center"
24-
role="presentation"
25-
/>
26-
<div
27-
class="dx-toolbar-after"
28-
role="presentation"
29-
/>
30-
</div>
31-
</div>
32-
</div>
33-
`;
34-
35-
exports[`Applying options when disabled = 'false' Toolbar should not be disabled 1`] = `
3+
exports[`Options disabled when it is 'false' Toolbar should not be disabled 1`] = `
364
<div>
375
<div
386
class="dx-toolbar dx-widget dx-visibility-change-handler dx-collection dx-toolbar-mini"
@@ -58,7 +26,7 @@ exports[`Applying options when disabled = 'false' Toolbar should not be disabled
5826
</div>
5927
`;
6028

61-
exports[`Applying options when disabled = 'true' Toolbar should be disabled 1`] = `
29+
exports[`Options disabled when it is 'true' Toolbar should be disabled 1`] = `
6230
<div>
6331
<div
6432
aria-disabled="true"
@@ -85,39 +53,13 @@ exports[`Applying options when disabled = 'true' Toolbar should be disabled 1`]
8553
</div>
8654
`;
8755

88-
exports[`Applying options when visible = 'false' Toolbar should be hidden 1`] = `
56+
exports[`Options items when these are not set Toolbar should be hidden 1`] = `
8957
<div>
9058
9159
</div>
9260
`;
9361

94-
exports[`Applying options when visible = 'true' Toolbar should be visible 1`] = `
95-
<div>
96-
<div
97-
class="dx-toolbar dx-widget dx-visibility-change-handler dx-collection dx-toolbar-mini"
98-
role="toolbar"
99-
>
100-
<div
101-
class="dx-toolbar-items-container"
102-
>
103-
<div
104-
class="dx-toolbar-before"
105-
role="presentation"
106-
/>
107-
<div
108-
class="dx-toolbar-center"
109-
role="presentation"
110-
/>
111-
<div
112-
class="dx-toolbar-after"
113-
role="presentation"
114-
/>
115-
</div>
116-
</div>
117-
</div>
118-
`;
119-
120-
exports[`Applying options when visible = 'undefined' and there are items Toolbar should be visible 1`] = `
62+
exports[`Options items when these are set Toolbar should be visible 1`] = `
12163
<div>
12264
<div
12365
class="dx-toolbar dx-widget dx-visibility-change-handler dx-collection"
@@ -193,16 +135,16 @@ exports[`Applying options when visible = 'undefined' and there are items Toolbar
193135
</div>
194136
`;
195137

196-
exports[`Applying options when visible = 'undefined' and there are no items Toolbar should be hidden 1`] = `
138+
exports[`Options visilbe when changing it to 'false' at runtime Toolbar should be hidden 1`] = `
197139
<div>
198140
199141
</div>
200142
`;
201143

202-
exports[`render Toolbar with options 1`] = `
144+
exports[`Options visilbe when changing it to 'true' at runtime Toolbar should be visible 1`] = `
203145
<div>
204146
<div
205-
class="dx-toolbar dx-widget dx-visibility-change-handler dx-collection"
147+
class="dx-toolbar dx-widget dx-visibility-change-handler dx-collection dx-toolbar-mini"
206148
role="toolbar"
207149
>
208150
<div
@@ -211,71 +153,27 @@ exports[`render Toolbar with options 1`] = `
211153
<div
212154
class="dx-toolbar-before"
213155
role="presentation"
214-
>
215-
<div
216-
class="dx-item dx-toolbar-item dx-toolbar-button"
217-
>
218-
<div
219-
class="dx-item-content dx-toolbar-item-content"
220-
>
221-
<div
222-
aria-label="button1"
223-
class="dx-widget dx-button dx-button-mode-contained dx-button-normal dx-button-has-text"
224-
role="button"
225-
tabindex="0"
226-
>
227-
<div
228-
class="dx-button-content"
229-
>
230-
<span
231-
class="dx-button-text"
232-
>
233-
button1
234-
</span>
235-
</div>
236-
</div>
237-
</div>
238-
</div>
239-
</div>
156+
/>
240157
<div
241158
class="dx-toolbar-center"
242159
role="presentation"
243160
/>
244161
<div
245162
class="dx-toolbar-after"
246163
role="presentation"
247-
>
248-
<div
249-
class="dx-item dx-toolbar-item dx-toolbar-button"
250-
>
251-
<div
252-
class="dx-item-content dx-toolbar-item-content"
253-
>
254-
<div
255-
aria-label="button2"
256-
class="dx-widget dx-button dx-button-mode-contained dx-button-normal dx-button-has-text"
257-
role="button"
258-
tabindex="0"
259-
>
260-
<div
261-
class="dx-button-content"
262-
>
263-
<span
264-
class="dx-button-text"
265-
>
266-
button2
267-
</span>
268-
</div>
269-
</div>
270-
</div>
271-
</div>
272-
</div>
164+
/>
273165
</div>
274166
</div>
275167
</div>
276168
`;
277169

278-
exports[`render empty toolbar 1`] = `
170+
exports[`Options visilbe when it is 'false' Toolbar should be hidden 1`] = `
171+
<div>
172+
173+
</div>
174+
`;
175+
176+
exports[`Options visilbe when it is 'true' Toolbar should be visible 1`] = `
279177
<div>
280178
<div
281179
class="dx-toolbar dx-widget dx-visibility-change-handler dx-collection dx-toolbar-mini"

packages/devextreme/js/__internal/grids/new/grid_core/toolbar/controller.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
/* eslint-disable @typescript-eslint/no-dynamic-delete */
22
/* eslint-disable @typescript-eslint/no-shadow */
33
/* eslint-disable spellcheck/spell-checker */
4-
import type { MaybeSubscribable, Subscribable, SubsGets } from '@ts/core/reactive/index';
4+
import type {
5+
MaybeSubscribable, Subscribable, Subscription, SubsGets,
6+
} from '@ts/core/reactive/index';
57
import { computed, state, toSubscribable } from '@ts/core/reactive/index';
68

79
import { OptionsController } from '../options_controller/options_controller';
8-
import { normalizeToolbarItems } from '../utils';
910
import { DEFAULT_TOOLBAR_ITEMS } from './defaults';
1011
import type { PredefinedToolbarItem, ToolbarItem, ToolbarItems } from './types';
12+
import { normalizeToolbarItems } from './utils';
1113

1214
export class ToolbarController {
15+
private readonly itemSubscriptions: Record<string, Subscription> = {};
16+
1317
private readonly defaultItems = state<Record<string, PredefinedToolbarItem>>({});
1418

1519
private readonly userItems: Subscribable<ToolbarItems | undefined>;
@@ -35,7 +39,11 @@ export class ToolbarController {
3539
public addDefaultItem(
3640
item: MaybeSubscribable<PredefinedToolbarItem>,
3741
): void {
38-
toSubscribable(item).subscribe((item) => {
42+
const itemObs = toSubscribable(item);
43+
// @ts-expect-error
44+
const { name } = itemObs.unreactive_get();
45+
46+
this.itemSubscriptions[name] = itemObs.subscribe((item) => {
3947
this.defaultItems.updateFunc((oldDefaultItems) => ({
4048
...oldDefaultItems,
4149
[item.name]: item,
@@ -49,5 +57,6 @@ export class ToolbarController {
4957
delete defaultItems[name];
5058
return defaultItems;
5159
});
60+
this.itemSubscriptions[name].unsubscribe();
5261
}
5362
}

packages/devextreme/js/__internal/grids/new/grid_core/toolbar/defaults.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
* used for defining default toolbar items and their default order in header panel
33
*/
44
export const DEFAULT_TOOLBAR_ITEMS = [
5-
'saveButton',
6-
'revertButton',
7-
'editButton',
8-
'columnsChooserButton',
95
'searchPanel',
106
] as const;

0 commit comments

Comments
 (0)