cozy-sharing 32.3.1 → 32.3.2

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/FederatedFolder/FederatedFolderModal.js +56 -19
  3. package/dist/components/FederatedFolder/FederatedFolderModal.spec.js +101 -254
  4. package/dist/components/Recipient/RecipientList.js +0 -15
  5. package/dist/components/ShareModal/ShareModal.js +8 -8
  6. package/dist/state.js +6 -1
  7. package/package.json +2 -2
  8. package/src/components/FederatedFolder/FederatedFolderModal.jsx +65 -19
  9. package/src/components/FederatedFolder/FederatedFolderModal.spec.jsx +28 -150
  10. package/src/components/Recipient/RecipientList.jsx +0 -18
  11. package/src/components/ShareModal/ShareModal.jsx +5 -5
  12. package/src/state.js +5 -1
  13. package/.claude/settings.local.json +0 -27
  14. package/AGENTS.md +0 -7
  15. package/dist/RefreshableSharings.spec.js +0 -40
  16. package/dist/assets/illustrations/illustration-shared-drives.svg +0 -1
  17. package/dist/components/EditLinkPermissionDialog.js +0 -72
  18. package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
  19. package/dist/components/FederatedFolder/DumbFederatedFolderModal.js +0 -65
  20. package/dist/components/FederatedFolder/DumbFederatedFolderModal.spec.js +0 -107
  21. package/dist/components/FederatedFolder/FederatedFolderModal.jsx.tmp.179197.1773939270471 +0 -172
  22. package/dist/components/Recipient/actions/revokeGroup.js +0 -42
  23. package/dist/components/Recipient/actions/revokeMember.js +0 -42
  24. package/dist/components/Recipient/actions/revokeSharedDriveMember.js +0 -41
  25. package/dist/components/ShareModal/ShareModal copy.js +0 -43
  26. package/dist/components/ShareModal/ShareModal.spec.js +0 -197
  27. package/dist/components/ShareModal/ShareModalBatchContainer.js +0 -276
  28. package/dist/components/ShareModal/ShareModalBatchContainer.spec.js +0 -131
  29. package/dist/components/ShareModal/SharedDriveEditModal.js +0 -59
  30. package/dist/components/SharedDrive/DumbSharedDriveModal.js +0 -78
  31. package/dist/components/SharedDrive/DumbSharedDriveModal.spec.js +0 -126
  32. package/dist/components/SharedDrive/SharedDriveEditModal.js +0 -110
  33. package/dist/components/SharedDrive/SharedDriveModal copy.js +0 -356
  34. package/dist/components/SharedDrive/SharedDriveRecipient.js +0 -61
  35. package/dist/components/SharedDrive/SharedDriveRecipientPermissions.js +0 -109
  36. package/dist/components/SharedDrive/SharedDriveRecipientStatus.js +0 -22
  37. package/dist/components/SharedDrive/helpers.js +0 -102
  38. package/dist/components/SharedDrive/helpers.spec.js +0 -208
  39. package/dist/components/SharedDriveEditModal.js +0 -43
  40. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.js +0 -145
  41. package/dist/components/SharedFolder/DumbBatchSharedFolderModal.spec.js +0 -321
  42. package/dist/components/SharedStatus.js +0 -61
  43. package/dist/components/SharedStatus.spec.js +0 -44
  44. package/dist/components/Sharesubmit.js +0 -28
  45. package/dist/components/__snapshots__/SharedStatus.spec.js.snap +0 -94
  46. package/dist/helpers/owner.js +0 -14
  47. package/dist/helpers/owner.spec.js +0 -34
  48. package/dist/hooks/useConfirmDiscardChanges.js +0 -33
  49. package/dist/hooks/useContactsAndGroups.js +0 -65
  50. package/dist/hooks/useSharedDrive.js +0 -130
  51. package/dist/hooks/useSharedDriveContactsAndGroups.js +0 -65
  52. package/dist/propTypes.js +0 -26
  53. package/dist/styles/shareddrive.styl +0 -8
  54. package/src/components/SharedDrive/SharedDriveRecipient.jsx +0 -62
  55. package/src/components/SharedDrive/SharedDriveRecipientPermissions.jsx +0 -78
  56. package/src/components/SharedDrive/SharedDriveRecipientStatus.jsx +0 -23
  57. package/src/components/SharedFolder/DumbBatchSharedFolderModal.jsx +0 -161
@@ -1,321 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import { render, screen } from '@testing-library/react';
3
- import React from 'react';
4
- import { DumbBatchSharedFolderModal } from './DumbBatchSharedFolderModal';
5
- var mockOnClose = jest.fn();
6
- var mockOnCreate = jest.fn();
7
- var mockOnSend = jest.fn();
8
- var mockOnRename = jest.fn();
9
- var mockOnShare = jest.fn();
10
- var mockOnRevoke = jest.fn();
11
- var mockOnSetType = jest.fn();
12
- var mockHandleFolderNameChange = jest.fn();
13
- var mockCreateContact = jest.fn();
14
- jest.mock('../../hoc/withLocales', function () {
15
- return {
16
- __esModule: true,
17
- default: function _default(Component) {
18
- return Component;
19
- }
20
- };
21
- });
22
- jest.mock('twake-i18n', function () {
23
- return {
24
- useI18n: jest.fn().mockReturnValue({
25
- t: jest.fn(function (key) {
26
- return key;
27
- })
28
- })
29
- };
30
- });
31
- jest.mock('cozy-ui/transpiled/react/Buttons', function () {
32
- return {
33
- __esModule: true,
34
- default: function _default(_ref) {
35
- var label = _ref.label,
36
- onClick = _ref.onClick,
37
- variant = _ref.variant,
38
- disabled = _ref.disabled;
39
- return /*#__PURE__*/React.createElement("button", {
40
- "data-testid": "button-".concat(label),
41
- "data-variant": variant,
42
- disabled: disabled,
43
- onClick: onClick
44
- }, label);
45
- }
46
- };
47
- });
48
- jest.mock('cozy-ui/transpiled/react/CozyDialogs', function () {
49
- return {
50
- // eslint-disable-next-line no-unused-vars
51
- FixedDialog: function FixedDialog(_ref2) {
52
- var content = _ref2.content,
53
- title = _ref2.title,
54
- actions = _ref2.actions,
55
- onClose = _ref2.onClose;
56
- return /*#__PURE__*/React.createElement("div", {
57
- "data-testid": "fixed-dialog"
58
- }, /*#__PURE__*/React.createElement("div", {
59
- "data-testid": "dialog-title"
60
- }, title), /*#__PURE__*/React.createElement("div", {
61
- "data-testid": "dialog-content"
62
- }, content), /*#__PURE__*/React.createElement("div", {
63
- "data-testid": "dialog-actions"
64
- }, actions));
65
- }
66
- };
67
- });
68
- jest.mock('cozy-ui/transpiled/react/TextField', function () {
69
- return {
70
- __esModule: true,
71
- default: function _default(_ref3) {
72
- var label = _ref3.label,
73
- value = _ref3.value,
74
- onChange = _ref3.onChange;
75
- return /*#__PURE__*/React.createElement("input", {
76
- "data-testid": "text-field",
77
- "data-label": label,
78
- value: value,
79
- onChange: onChange
80
- });
81
- }
82
- };
83
- });
84
- jest.mock('cozy-ui/transpiled/react/Typography', function () {
85
- return {
86
- __esModule: true,
87
- default: function _default(_ref4) {
88
- var children = _ref4.children;
89
- return /*#__PURE__*/React.createElement("div", {
90
- "data-testid": "typography"
91
- }, children);
92
- }
93
- };
94
- });
95
- jest.mock('../AntivirusAlert', function () {
96
- return {
97
- __esModule: true,
98
- default: function _default() {
99
- return /*#__PURE__*/React.createElement("div", {
100
- "data-testid": "antivirus-alert"
101
- }, "AntivirusAlert");
102
- }
103
- };
104
- });
105
- jest.mock('../ShareByEmail', function () {
106
- return {
107
- __esModule: true,
108
- default: function _default(_ref5) {
109
- var onShare = _ref5.onShare;
110
- return /*#__PURE__*/React.createElement("div", {
111
- "data-testid": "share-by-email"
112
- }, /*#__PURE__*/React.createElement("button", {
113
- "data-testid": "trigger-share",
114
- onClick: function onClick() {
115
- return onShare({
116
- recipients: [{
117
- id: 1
118
- }],
119
- readOnlyRecipients: []
120
- });
121
- }
122
- }, "Trigger Share"));
123
- }
124
- };
125
- });
126
- jest.mock('../ShareByLink', function () {
127
- return {
128
- __esModule: true,
129
- default: function _default(_ref6) {
130
- var link = _ref6.link;
131
- return /*#__PURE__*/React.createElement("div", {
132
- "data-testid": "share-by-link"
133
- }, link);
134
- }
135
- };
136
- });
137
- jest.mock('../WhoHasAccess', function () {
138
- return {
139
- __esModule: true,
140
- default: function _default(_ref7) {
141
- var recipients = _ref7.recipients;
142
- return /*#__PURE__*/React.createElement("div", {
143
- "data-testid": "who-has-access"
144
- }, (recipients === null || recipients === void 0 ? void 0 : recipients.length) || 0, " recipients");
145
- }
146
- };
147
- });
148
- describe('DumbBatchSharedFolderModal', function () {
149
- var defaultProps = {
150
- title: 'Test Title',
151
- document: {
152
- _id: 'doc-123'
153
- },
154
- folderName: 'Test Folder',
155
- handleFolderNameChange: mockHandleFolderNameChange,
156
- createContact: mockCreateContact,
157
- recipients: [],
158
- currentRecipients: [],
159
- onRevoke: mockOnRevoke,
160
- onSetType: mockOnSetType,
161
- onClose: mockOnClose,
162
- onShare: mockOnShare,
163
- sharingLink: 'https://share.link/123',
164
- hasRecipientsInitially: false,
165
- nameLabel: 'Name Label',
166
- addPeopleLabel: 'Add People',
167
- addButtonLabel: 'Add',
168
- cancelLabel: 'Cancel',
169
- createLabel: 'Create',
170
- shareLabel: 'Share',
171
- saveLabel: 'Save'
172
- };
173
-
174
- var setup = function setup() {
175
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
176
- return render( /*#__PURE__*/React.createElement(DumbBatchSharedFolderModal, _extends({}, defaultProps, props)));
177
- };
178
-
179
- beforeEach(function () {
180
- jest.clearAllMocks();
181
- });
182
- it('should render FixedDialog with correct title', function () {
183
- setup();
184
- expect(screen.getByTestId('dialog-title')).toHaveTextContent('Test Title');
185
- });
186
- it('should show name field when showNameField is true and handleFolderNameChange is provided', function () {
187
- setup({
188
- showNameField: true
189
- });
190
- expect(screen.getByTestId('text-field')).toBeInTheDocument();
191
- expect(screen.getByTestId('text-field')).toHaveAttribute('data-label', 'Name Label');
192
- });
193
- it('should not show name field when showNameField is false', function () {
194
- setup({
195
- showNameField: false
196
- });
197
- expect(screen.queryByTestId('text-field')).not.toBeInTheDocument();
198
- });
199
- it('should not show name field when handleFolderNameChange is not provided', function () {
200
- setup({
201
- showNameField: true,
202
- handleFolderNameChange: null
203
- });
204
- expect(screen.queryByTestId('text-field')).not.toBeInTheDocument();
205
- });
206
- describe('action buttons', function () {
207
- it('should show Cancel and Create buttons in creation mode (showNameField=true with onCreate)', function () {
208
- setup({
209
- showNameField: true,
210
- onCreate: mockOnCreate
211
- });
212
- expect(screen.getByTestId('button-Cancel')).toBeInTheDocument();
213
- expect(screen.getByTestId('button-Create')).toBeInTheDocument();
214
- expect(screen.queryByTestId('button-Share')).not.toBeInTheDocument();
215
- });
216
- it('should show ShareByLink and Share button in share mode (showNameField=false)', function () {
217
- setup({
218
- showNameField: false,
219
- onSend: mockOnSend
220
- });
221
- expect(screen.getByTestId('share-by-link')).toBeInTheDocument();
222
- expect(screen.getByTestId('button-Share')).toBeInTheDocument();
223
- });
224
- it('should show only Save button in rename mode (onRename provided)', function () {
225
- setup({
226
- showNameField: true,
227
- onRename: mockOnRename
228
- });
229
- expect(screen.getByTestId('button-Save')).toBeInTheDocument();
230
- expect(screen.queryByTestId('button-Cancel')).not.toBeInTheDocument();
231
- expect(screen.queryByTestId('button-Create')).not.toBeInTheDocument();
232
- });
233
- it('should disable Share button when hasRecipients is false', function () {
234
- setup({
235
- showNameField: false,
236
- onSend: mockOnSend,
237
- hasRecipientsInitially: false
238
- });
239
- var shareButton = screen.getByTestId('button-Share');
240
- expect(shareButton).toBeDisabled();
241
- });
242
- it('should enable Share button when hasRecipientsInitially is true', function () {
243
- setup({
244
- showNameField: false,
245
- onSend: mockOnSend,
246
- hasRecipientsInitially: true
247
- });
248
- var shareButton = screen.getByTestId('button-Share');
249
- expect(shareButton).not.toBeDisabled();
250
- });
251
- });
252
- it('should render AntivirusAlert component', function () {
253
- setup();
254
- expect(screen.getByTestId('antivirus-alert')).toBeInTheDocument();
255
- });
256
- it('should render ShareByEmail component with sharedDrive prop', function () {
257
- setup();
258
- expect(screen.getByTestId('share-by-email')).toBeInTheDocument();
259
- });
260
- it('should render WhoHasAccess component with recipients', function () {
261
- setup({
262
- recipients: [{
263
- id: 1
264
- }, {
265
- id: 2
266
- }]
267
- });
268
- expect(screen.getByTestId('who-has-access')).toHaveTextContent('2 recipients');
269
- });
270
- it('should display addPeopleLabel in Typography', function () {
271
- setup();
272
- expect(screen.getByTestId('typography')).toHaveTextContent('Add People');
273
- });
274
- it('should call onClose when Cancel button is clicked', function () {
275
- setup({
276
- showNameField: true,
277
- onCreate: mockOnCreate
278
- });
279
- screen.getByTestId('button-Cancel').click();
280
- expect(mockOnClose).toHaveBeenCalled();
281
- });
282
- it('should call onCreate when Create button is clicked', function () {
283
- setup({
284
- showNameField: true,
285
- onCreate: mockOnCreate
286
- });
287
- screen.getByTestId('button-Create').click();
288
- expect(mockOnCreate).toHaveBeenCalled();
289
- });
290
- it('should call onSend when Share button is clicked and recipients exist', function () {
291
- setup({
292
- showNameField: false,
293
- onSend: mockOnSend,
294
- hasRecipientsInitially: true
295
- });
296
- screen.getByTestId('button-Share').click();
297
- expect(mockOnSend).toHaveBeenCalled();
298
- });
299
- it('should call onRename when Save button is clicked', function () {
300
- setup({
301
- showNameField: true,
302
- onRename: mockOnRename,
303
- folderName: 'New Name'
304
- });
305
- screen.getByTestId('button-Save').click();
306
- expect(mockOnRename).toHaveBeenCalledWith('New Name');
307
- });
308
- it('should update hasRecipients state when onShare is called with recipients', function () {
309
- setup({
310
- showNameField: false,
311
- onSend: mockOnSend,
312
- hasRecipientsInitially: false
313
- }); // Initially disabled
314
-
315
- expect(screen.getByTestId('button-Share')).toBeDisabled(); // Trigger share with recipients
316
-
317
- screen.getByTestId('trigger-share').click(); // Should have called onShare
318
-
319
- expect(mockOnShare).toHaveBeenCalled();
320
- });
321
- });
@@ -1,61 +0,0 @@
1
- import cx from 'classnames';
2
- import React from 'react';
3
- import { useI18n } from 'twake-i18n';
4
- import { SharingTooltip, TooltipRecipientList } from './Tooltip';
5
-
6
- var LinkIcon = function LinkIcon(props) {
7
- return /*#__PURE__*/React.createElement("svg", props, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
8
- d: "M8.88 3.88a1 1 0 1 1-1.415-1.415L9.053.877A2.998 2.998 0 0 1 13.29.876l1.18 1.18a2.998 2.998 0 0 1-.007 4.24L10.999 9.76c-1.535 1.535-4.07 1.583-5.534.12A1 1 0 1 1 6.88 8.465c.67.67 1.94.646 2.705-.119l3.465-3.464a.998.998 0 0 0 .006-1.413l-1.18-1.18a.998.998 0 0 0-1.408.003L8.88 3.88zm-2.415 7.585A1 1 0 1 1 7.88 12.88l-1.587 1.587a2.998 2.998 0 0 1-4.237.002l-1.18-1.18a2.998 2.998 0 0 1 .007-4.24l3.464-3.464c1.534-1.535 4.07-1.583 5.533-.12A1 1 0 1 1 8.465 6.88c-.67-.67-1.94-.646-2.705.119l-3.464 3.464a.998.998 0 0 0-.006 1.413l1.18 1.18a.998.998 0 0 0 1.407-.003l1.588-1.588z",
9
- id: "link-1-path-1"
10
- })), /*#__PURE__*/React.createElement("use", {
11
- fillRule: "nonzero",
12
- xlinkHref: "#link-1-path-1"
13
- }));
14
- };
15
-
16
- LinkIcon.defaultProps = {
17
- width: "16",
18
- height: "16",
19
- viewBox: "0 0 16 16",
20
- xmlns: "http://www.w3.org/2000/svg",
21
- xmlnsXlink: "http://www.w3.org/1999/xlink"
22
- };
23
- import { getDisplayName } from '../models';
24
- var styles = {
25
- "shared-status": "status__shared-status___2HpyL",
26
- "shared-status-label": "status__shared-status-label___1-jvS"
27
- };
28
- export var SharedStatus = function SharedStatus(_ref) {
29
- var className = _ref.className,
30
- docId = _ref.docId,
31
- recipients = _ref.recipients,
32
- link = _ref.link;
33
-
34
- var _useI18n = useI18n(),
35
- t = _useI18n.t;
36
-
37
- return /*#__PURE__*/React.createElement("span", {
38
- className: cx(className, styles['shared-status'])
39
- }, recipients.length > 1 && /*#__PURE__*/React.createElement("a", {
40
- "data-tip": true,
41
- "data-for": "members".concat(docId),
42
- className: styles['shared-status-label']
43
- }, t('Share.members.count', {
44
- smart_count: recipients.length
45
- })), recipients.length > 1 && /*#__PURE__*/React.createElement(SharingTooltip, {
46
- id: "members".concat(docId)
47
- }, /*#__PURE__*/React.createElement(TooltipRecipientList, {
48
- recipientNames: recipients.map(function (recipient) {
49
- return getDisplayName(recipient);
50
- })
51
- })), link && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LinkIcon, {
52
- style: {
53
- fill: 'var(--iconTextColor)'
54
- },
55
- "data-tip": true,
56
- "data-for": "linkfor".concat(docId)
57
- }), /*#__PURE__*/React.createElement(SharingTooltip, {
58
- id: "linkfor".concat(docId)
59
- }, /*#__PURE__*/React.createElement("span", null, t('Files.share.sharedByLink')))));
60
- };
61
- export default SharedStatus;
@@ -1,44 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import React from 'react';
3
- import { SharedStatus } from './SharedStatus';
4
- import AppLike from '../../test/AppLike';
5
- describe('SharedStatus component', function () {
6
- it('should just render a span if no sharing', function () {
7
- var _render = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(SharedStatus, {
8
- docId: "1",
9
- recipients: []
10
- }))),
11
- container = _render.container;
12
-
13
- expect(container).toMatchSnapshot();
14
- });
15
- it('should have the right display if there is several recipients', function () {
16
- var _render2 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(SharedStatus, {
17
- docId: "1",
18
- recipients: [{
19
- _id: 1,
20
- name: '1'
21
- }, {
22
- _id: 2,
23
- name: '2'
24
- }]
25
- }))),
26
- container = _render2.container,
27
- getByText = _render2.getByText;
28
-
29
- expect(container).toMatchSnapshot();
30
- expect(getByText('2 members')).toBeTruthy();
31
- });
32
- it('should display the link if there is a link', function () {
33
- var _render3 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(SharedStatus, {
34
- docId: "1",
35
- recipients: [],
36
- link: true
37
- }))),
38
- container = _render3.container,
39
- getByText = _render3.getByText;
40
-
41
- expect(container).toMatchSnapshot();
42
- expect(getByText('Shared by link')).toBeTruthy();
43
- });
44
- });
@@ -1,28 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import Button from 'cozy-ui/transpiled/react/Buttons';
4
-
5
- var ShareSubmit = function ShareSubmit(props) {
6
- return /*#__PURE__*/React.createElement(Button, {
7
- onClick: function onClick() {
8
- props.onSubmit();
9
- },
10
- size: "large",
11
- busy: props.loading,
12
- label: props.label,
13
- disabled: props.disabled,
14
- variant: "ghost"
15
- });
16
- };
17
-
18
- ShareSubmit.propTypes = {
19
- onSubmit: PropTypes.func.isRequired,
20
- label: PropTypes.string,
21
- loading: PropTypes.bool,
22
- disabled: PropTypes.bool
23
- };
24
- ShareSubmit.defaultProps = {
25
- label: 'Submit',
26
- loading: false
27
- };
28
- export default ShareSubmit;
@@ -1,94 +0,0 @@
1
- // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
-
3
- exports[`SharedStatus component should display the link if there is a link 1`] = `
4
- <div>
5
- <div
6
- class="TwakeTheme--light u-dc"
7
- >
8
- <span
9
- class="shared-status"
10
- >
11
- <svg
12
- currentItem="false"
13
- data-for="linkfor1"
14
- data-tip="true"
15
- height="16"
16
- style="fill: var(--iconTextColor);"
17
- viewBox="0 0 16 16"
18
- width="16"
19
- xmlns="http://www.w3.org/2000/svg"
20
- xmlns:xlink="http://www.w3.org/1999/xlink"
21
- >
22
- <defs>
23
- <path
24
- d="M8.88 3.88a1 1 0 1 1-1.415-1.415L9.053.877A2.998 2.998 0 0 1 13.29.876l1.18 1.18a2.998 2.998 0 0 1-.007 4.24L10.999 9.76c-1.535 1.535-4.07 1.583-5.534.12A1 1 0 1 1 6.88 8.465c.67.67 1.94.646 2.705-.119l3.465-3.464a.998.998 0 0 0 .006-1.413l-1.18-1.18a.998.998 0 0 0-1.408.003L8.88 3.88zm-2.415 7.585A1 1 0 1 1 7.88 12.88l-1.587 1.587a2.998 2.998 0 0 1-4.237.002l-1.18-1.18a2.998 2.998 0 0 1 .007-4.24l3.464-3.464c1.534-1.535 4.07-1.583 5.533-.12A1 1 0 1 1 8.465 6.88c-.67-.67-1.94-.646-2.705.119l-3.464 3.464a.998.998 0 0 0-.006 1.413l1.18 1.18a.998.998 0 0 0 1.407-.003l1.588-1.588z"
25
- id="link-1-path-1"
26
- />
27
- </defs>
28
- <use
29
- fill-rule="nonzero"
30
- xlink:href="#link-1-path-1"
31
- />
32
- </svg>
33
- <div
34
- class="__react_component_tooltip place-bottom type-dark "
35
- data-id="tooltip"
36
- id="linkfor1"
37
- >
38
- <span>
39
- Shared by link
40
- </span>
41
- </div>
42
- </span>
43
- </div>
44
- </div>
45
- `;
46
-
47
- exports[`SharedStatus component should have the right display if there is several recipients 1`] = `
48
- <div>
49
- <div
50
- class="TwakeTheme--light u-dc"
51
- >
52
- <span
53
- class="shared-status"
54
- >
55
- <a
56
- class="shared-status-label"
57
- currentitem="false"
58
- data-for="members1"
59
- data-tip="true"
60
- >
61
- 2 members
62
- </a>
63
- <div
64
- class="__react_component_tooltip place-bottom type-dark "
65
- data-id="tooltip"
66
- id="members1"
67
- >
68
- <ul
69
- class="shared-tooltip-list"
70
- >
71
- <li>
72
- 1
73
- </li>
74
- <li>
75
- 2
76
- </li>
77
- </ul>
78
- </div>
79
- </span>
80
- </div>
81
- </div>
82
- `;
83
-
84
- exports[`SharedStatus component should just render a span if no sharing 1`] = `
85
- <div>
86
- <div
87
- class="TwakeTheme--light u-dc"
88
- >
89
- <span
90
- class="shared-status"
91
- />
92
- </div>
93
- </div>
94
- `;
@@ -1,14 +0,0 @@
1
- export var findOwnerRecipient = function findOwnerRecipient(recipients) {
2
- return recipients.find(function (recipient) {
3
- return recipient.status === 'owner';
4
- }) || null;
5
- };
6
- export var makeDefaultOwnerRecipient = function makeDefaultOwnerRecipient(_ref) {
7
- var instance = _ref.instance,
8
- publicName = _ref.publicName;
9
- return {
10
- status: 'owner',
11
- instance: instance,
12
- public_name: publicName
13
- };
14
- };
@@ -1,34 +0,0 @@
1
- import { findOwnerRecipient, makeDefaultOwnerRecipient } from './owner';
2
- describe('owner helper', function () {
3
- describe('findOwnerRecipient', function () {
4
- it('should return owner recipient when it exists', function () {
5
- var recipients = [{
6
- status: 'ready',
7
- instance: 'https://a.cozy.tools'
8
- }, {
9
- status: 'owner',
10
- instance: 'https://owner.cozy.tools'
11
- }];
12
- expect(findOwnerRecipient(recipients)).toEqual(recipients[1]);
13
- });
14
- it('should return null when owner recipient does not exist', function () {
15
- var recipients = [{
16
- status: 'ready',
17
- instance: 'https://a.cozy.tools'
18
- }];
19
- expect(findOwnerRecipient(recipients)).toBe(null);
20
- });
21
- });
22
- describe('makeDefaultOwnerRecipient', function () {
23
- it('should return a default owner recipient', function () {
24
- expect(makeDefaultOwnerRecipient({
25
- instance: 'https://me.cozy.tools',
26
- publicName: 'My Cozy'
27
- })).toEqual({
28
- status: 'owner',
29
- instance: 'https://me.cozy.tools',
30
- public_name: 'My Cozy'
31
- });
32
- });
33
- });
34
- });
@@ -1,33 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useCallback, useState } from 'react';
3
- export var useConfirmDiscardChanges = function useConfirmDiscardChanges(_ref) {
4
- var hasChanges = _ref.hasChanges,
5
- onClose = _ref.onClose;
6
-
7
- var _useState = useState(false),
8
- _useState2 = _slicedToArray(_useState, 2),
9
- showDiscardChanges = _useState2[0],
10
- setShowDiscardChanges = _useState2[1];
11
-
12
- var handleCloseRequest = useCallback(function () {
13
- if (hasChanges) {
14
- setShowDiscardChanges(true);
15
- return;
16
- }
17
-
18
- onClose();
19
- }, [hasChanges, onClose]);
20
- var handleCancelDiscardChanges = useCallback(function () {
21
- setShowDiscardChanges(false);
22
- }, []);
23
- var handleConfirmDiscardChanges = useCallback(function () {
24
- setShowDiscardChanges(false);
25
- onClose();
26
- }, [onClose]);
27
- return {
28
- showDiscardChanges: showDiscardChanges,
29
- handleCloseRequest: handleCloseRequest,
30
- handleCancelDiscardChanges: handleCancelDiscardChanges,
31
- handleConfirmDiscardChanges: handleConfirmDiscardChanges
32
- };
33
- };