@axinom/mosaic-ui 0.32.0-rc.10 → 0.32.0-rc.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-ui",
3
- "version": "0.32.0-rc.10",
3
+ "version": "0.32.0-rc.12",
4
4
  "description": "UI components for building Axinom Mosaic applications",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -32,7 +32,7 @@
32
32
  "build-storybook": "storybook build"
33
33
  },
34
34
  "dependencies": {
35
- "@axinom/mosaic-core": "^0.4.5-rc.10",
35
+ "@axinom/mosaic-core": "^0.4.5-rc.11",
36
36
  "@faker-js/faker": "^7.4.0",
37
37
  "@popperjs/core": "^2.9.2",
38
38
  "clsx": "^1.1.0",
@@ -102,5 +102,5 @@
102
102
  "publishConfig": {
103
103
  "access": "public"
104
104
  },
105
- "gitHead": "896d9e0951c9f8610938ec86dbf271d3aef9c5fc"
105
+ "gitHead": "49d29f6c1ca2811784c79c0da36a5377d1389635"
106
106
  }
@@ -1,10 +1,10 @@
1
1
  import { mount, shallow } from 'enzyme';
2
2
  import React from 'react';
3
3
  import { act } from 'react-dom/test-utils';
4
- import { BrowserRouter as Router, Link } from 'react-router-dom';
4
+ import { Link, BrowserRouter as Router } from 'react-router-dom';
5
5
  import { noop } from '../../../helpers/utils';
6
6
  import { TextButton } from '../../Buttons';
7
- import { ConfirmationConfig, ConfirmDialog } from '../../ConfirmDialog';
7
+ import { ConfirmDialog, ConfirmationConfig } from '../../ConfirmDialog';
8
8
  import { IconName, Icons } from '../../Icons';
9
9
  import {
10
10
  Action,
@@ -2,8 +2,8 @@ import clsx from 'clsx';
2
2
  import React, { useEffect, useState } from 'react';
3
3
  import { Link } from 'react-router-dom';
4
4
  import {
5
- ConfirmationConfig,
6
5
  ConfirmDialog,
6
+ ConfirmationConfig,
7
7
  useConfirmationDelay,
8
8
  } from '../../ConfirmDialog';
9
9
  import { IconName, Icons } from '../../Icons';
@@ -36,6 +36,11 @@ export interface ExplorerBulkAction<T extends Data>
36
36
  * Whether the Explorer should reload the data once the bulk action is completed
37
37
  */
38
38
  reloadData?: boolean;
39
+ /**
40
+ * Whether or not to show toast notification once the bulk action is started
41
+ * (shown by default)
42
+ */
43
+ showStartedNotification?: boolean;
39
44
  }
40
45
 
41
46
  export type PageIdentifier = string | number | undefined;
@@ -270,7 +270,7 @@ describe('Explorer', () => {
270
270
  const header = wrapper.find(PageHeader);
271
271
 
272
272
  await act(async () => {
273
- header.prop('bulkActions')?.[0].onClick();
273
+ header.prop('bulkActions')?.[0].onClick?.();
274
274
 
275
275
  await wrapper.update();
276
276
  });
@@ -280,7 +280,7 @@ describe('Explorer', () => {
280
280
  });
281
281
 
282
282
  it('Calls "showNotification" when bulk action is clicked', async () => {
283
- const [provider, spy] = getDataProvider();
283
+ const [provider] = getDataProvider();
284
284
 
285
285
  const label = 'Something';
286
286
  const wrapper = await actWithReturn(async () => {
@@ -303,7 +303,7 @@ describe('Explorer', () => {
303
303
 
304
304
  const header = wrapper.find(PageHeader);
305
305
  await act(async () => {
306
- header.prop('bulkActions')?.[0].onClick();
306
+ header.prop('bulkActions')?.[0].onClick?.();
307
307
  await wrapper.update();
308
308
  });
309
309
 
@@ -313,6 +313,38 @@ describe('Explorer', () => {
313
313
  });
314
314
  });
315
315
 
316
+ it('Does not call "showNotification" when `showStartedNotification=false` and bulk action is clicked', async () => {
317
+ const [provider] = getDataProvider();
318
+
319
+ const label = 'Something';
320
+ const wrapper = await actWithReturn(async () => {
321
+ const wrapper = mount(
322
+ <Explorer
323
+ columns={mockListColumns}
324
+ dataProvider={provider}
325
+ stationKey="mock-key"
326
+ bulkActions={[
327
+ {
328
+ label,
329
+ onClick: jest.fn(),
330
+ reloadData: true,
331
+ showStartedNotification: false,
332
+ },
333
+ ]}
334
+ />,
335
+ );
336
+ return wrapper;
337
+ });
338
+
339
+ const header = wrapper.find(PageHeader);
340
+ await act(async () => {
341
+ header.prop('bulkActions')?.[0].onClick?.();
342
+ await wrapper.update();
343
+ });
344
+
345
+ expect(showNotificationSpy).toHaveBeenCalledTimes(0);
346
+ });
347
+
316
348
  it.todo(`raises page header bulk action with 'SELECT_ALL'`);
317
349
 
318
350
  it.todo(`raises page header bulk action with 'SINGLE_ITEMS'`);
@@ -1672,7 +1704,7 @@ describe('Explorer', () => {
1672
1704
  const menu = wrapper.find(InlineMenu);
1673
1705
 
1674
1706
  await act(async () => {
1675
- await menu.prop('actions')?.[0].onActionSelected();
1707
+ await menu.prop('actions')?.[0].onActionSelected?.();
1676
1708
  await wrapper.update();
1677
1709
  });
1678
1710
 
@@ -1728,7 +1760,7 @@ describe('Explorer', () => {
1728
1760
  const menu = wrapper.find(InlineMenu);
1729
1761
 
1730
1762
  await act(async () => {
1731
- await menu.prop('actions')?.[0].onActionSelected();
1763
+ await menu.prop('actions')?.[0].onActionSelected?.();
1732
1764
  await wrapper.update();
1733
1765
  });
1734
1766
 
@@ -365,9 +365,11 @@ export const Explorer = React.forwardRef(function Explorer<T extends Data>(
365
365
  return {
366
366
  ...action,
367
367
  onClick: async () => {
368
- showNotification({
369
- title: `Bulk Action '${action.label}' Started`,
370
- });
368
+ if (action.showStartedNotification !== false) {
369
+ showNotification({
370
+ title: `Bulk Action '${action.label}' Started`,
371
+ });
372
+ }
371
373
 
372
374
  try {
373
375
  const result = await action.onClick(getBulkActionSelection());
@@ -2,7 +2,9 @@ import { mount, shallow } from 'enzyme';
2
2
  import React from 'react';
3
3
  import { act } from 'react-dom/test-utils';
4
4
  import { actWithReturn } from '../../../helpers/testing';
5
+ import * as app from '../../../initialize';
5
6
  import { Column } from '../../List';
7
+ import { PageHeader } from '../../PageHeader';
6
8
  import { PageHeaderBulkActions } from '../../PageHeader/PageHeaderBulkActions/PageHeaderBulkActions';
7
9
  import { Explorer } from '../Explorer';
8
10
  import { ExplorerDataProvider } from '../Explorer.model';
@@ -103,6 +105,34 @@ describe('SelectionExplorer', () => {
103
105
  expect(bulkActions.exists()).toBe(false);
104
106
  });
105
107
 
108
+ it('Does not call "showNotification" when "Apply Selection" is clicked', async () => {
109
+ const [provider] = getDataProvider();
110
+ const showNotificationSpy: jest.SpyInstance = jest.spyOn(
111
+ app,
112
+ 'showNotification',
113
+ );
114
+
115
+ const wrapper = await actWithReturn(async () => {
116
+ const wrapper = mount(
117
+ <SelectionExplorer
118
+ columns={mockListColumns}
119
+ dataProvider={provider}
120
+ stationKey="mock-key"
121
+ allowBulkSelect={true}
122
+ />,
123
+ );
124
+ return wrapper;
125
+ });
126
+
127
+ const header = wrapper.find(PageHeader);
128
+ await act(async () => {
129
+ header.prop('bulkActions')?.[0].onClick?.();
130
+ await wrapper.update();
131
+ });
132
+
133
+ expect(showNotificationSpy).toHaveBeenCalledTimes(0);
134
+ });
135
+
106
136
  it('sends onSelection callback when the selection of a single item is triggered', async () => {
107
137
  const [provider] = getDataProvider();
108
138
  const spy = jest.fn();
@@ -68,6 +68,7 @@ export const SelectionExplorer = React.forwardRef(function SelectionExplorer<
68
68
  onClick: ((arg: ItemSelection<T>) => {
69
69
  onSelection(arg);
70
70
  }) as ExplorerBulkAction<T>['onClick'],
71
+ showStartedNotification: false,
71
72
  },
72
73
  ]
73
74
  : []),
@@ -3,9 +3,9 @@ import React, { useEffect, useState } from 'react';
3
3
  import { noop } from '../../../helpers/utils';
4
4
  import { CommonJsButtonOptions } from '../../Buttons/Button.model';
5
5
  import {
6
+ ConfirmDialog,
6
7
  ConfirmationConfig,
7
8
  ConfirmationMode,
8
- ConfirmDialog,
9
9
  } from '../../ConfirmDialog';
10
10
  import { BaseFormControl } from '../Form.models';
11
11
  import { FormElementContainer } from '../FormElementContainer';
@@ -4,7 +4,7 @@ import { act } from 'react-dom/test-utils';
4
4
  import { Link, BrowserRouter as Router } from 'react-router-dom';
5
5
  import { noop } from '../../../helpers/utils';
6
6
  import { TextButton } from '../../Buttons';
7
- import { ConfirmationConfig, ConfirmDialog } from '../../ConfirmDialog';
7
+ import { ConfirmDialog, ConfirmationConfig } from '../../ConfirmDialog';
8
8
  import { IconName } from '../../Icons';
9
9
  import {
10
10
  PageHeaderAction,
@@ -3,9 +3,9 @@ import React, { useEffect, useState } from 'react';
3
3
  import { Link } from 'react-router-dom';
4
4
  import { noop } from '../../../helpers/utils';
5
5
  import {
6
+ ConfirmDialog,
6
7
  ConfirmationConfig,
7
8
  ConfirmationMode,
8
- ConfirmDialog,
9
9
  useConfirmationDelay,
10
10
  } from '../../ConfirmDialog';
11
11
  import { IconName, Icons } from '../../Icons';
@@ -6,8 +6,8 @@ import { ConfirmationMode } from '../../ConfirmDialog';
6
6
  import { IconName } from '../../Icons';
7
7
  import { PageHeaderProps } from '../PageHeader.model';
8
8
  import {
9
- isPageHeaderJsAction,
10
9
  PageHeaderAction,
10
+ isPageHeaderJsAction,
11
11
  } from '../PageHeaderAction/PageHeaderAction';
12
12
  import {
13
13
  PageHeaderActionProps,