cozy-harvest-lib 22.0.6 → 22.0.7

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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [22.0.7](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@22.0.6...cozy-harvest-lib@22.0.7) (2024-01-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Do not disable submit buton when password is the same ([f431e7f](https://github.com/cozy/cozy-libs/commit/f431e7fda2e1d16618f687c5b16fbfbef83ab0e7))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [22.0.6](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@22.0.5...cozy-harvest-lib@22.0.6) (2024-01-08)
7
18
 
8
19
 
@@ -114,14 +114,12 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
114
114
  _createClass(AccountForm, [{
115
115
  key: "isSubmittable",
116
116
  value: function isSubmittable(_ref) {
117
- var dirty = _ref.dirty,
118
- error = _ref.error,
119
- initialValues = _ref.initialValues,
117
+ var error = _ref.error,
120
118
  valid = _ref.valid;
121
- var modified = !initialValues || dirty; // Here error is not a validation error but an instance of a
119
+ // Here error is not a validation error but an instance of a
122
120
  // KonnectorJobError, so submitting again is possible
123
-
124
- return modified && (error || valid);
121
+ var result = error || valid;
122
+ return result;
125
123
  }
126
124
  /**
127
125
  * Give focus to next input in the form.
@@ -161,10 +159,8 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
161
159
  * Handle key up and check if `ENTER` key has been pressed. If so, submit the
162
160
  * form if all parmater are ok.
163
161
  * @param {React.SyntheticEvent} event Key events
164
- * @param {Boolean} dirty Indicates if form is dirty, i.e. if values
165
162
  * have changed
166
163
  * @param {Object} form The form object injected by ReactFinalForm.
167
- * @param {Object} initialValues Initial data injected into AccountForm
168
164
  * @param {Boolean} valid Indicates if the form data is valid
169
165
  * @param {Object} values Actual form values data
170
166
  */
@@ -172,9 +168,7 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
172
168
  }, {
173
169
  key: "handleKeyUp",
174
170
  value: function handleKeyUp(event, _ref2) {
175
- var dirty = _ref2.dirty,
176
- form = _ref2.form,
177
- initialValues = _ref2.initialValues,
171
+ var form = _ref2.form,
178
172
  valid = _ref2.valid,
179
173
  values = _ref2.values;
180
174
 
@@ -182,8 +176,6 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
182
176
  var changedFocus = isMobile() && !!this.focusNext();
183
177
 
184
178
  if (!changedFocus && this.isSubmittable({
185
- dirty: dirty,
186
- initialValues: initialValues,
187
179
  valid: valid
188
180
  })) {
189
181
  this.handleSubmit(values, form);
@@ -303,7 +295,6 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
303
295
  vendor_link = konnector.vendor_link;
304
296
  var sanitizedFields = manifest.sanitizeFields(fields);
305
297
  fieldHelpers.addForceEncryptedPlaceholder(sanitizedFields, fieldOptions);
306
- var initialValues = account && account.auth;
307
298
  var values = manifest.getFieldsValues(konnector, account);
308
299
  var isReadOnlyIdentifier = Boolean(get(account, 'relationships.vaultCipher')) && this.props.readOnlyIdentifier;
309
300
 
@@ -321,16 +312,13 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
321
312
  onSubmit: onSubmit,
322
313
  validate: this.validate(sanitizedFields, values),
323
314
  render: function render(_ref3) {
324
- var dirty = _ref3.dirty,
325
- form = _ref3.form,
315
+ var form = _ref3.form,
326
316
  values = _ref3.values,
327
317
  valid = _ref3.valid;
328
318
  return /*#__PURE__*/React.createElement("div", {
329
319
  onKeyUp: function onKeyUp(event) {
330
320
  return _this3.handleKeyUp(event, {
331
- dirty: dirty,
332
321
  form: form,
333
- initialValues: initialValues,
334
322
  valid: valid,
335
323
  values: values
336
324
  });
@@ -365,9 +353,7 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
365
353
  buttonProps: _defineProperty({
366
354
  busy: submitting && !flag('harvest.inappconnectors.enabled'),
367
355
  disabled: submitting || !_this3.isSubmittable({
368
- dirty: dirty,
369
356
  error: error,
370
- initialValues: initialValues,
371
357
  valid: valid
372
358
  }),
373
359
  label: t('accountForm.clientSide.submit'),
@@ -379,9 +365,7 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
379
365
  busy: submitting && !flag('harvest.inappconnectors.enabled'),
380
366
  className: "u-mt-2 u-mb-1-half",
381
367
  disabled: submitting || !_this3.isSubmittable({
382
- dirty: dirty,
383
368
  error: error,
384
- initialValues: initialValues,
385
369
  valid: valid
386
370
  }),
387
371
  fullWidth: true,
@@ -260,52 +260,15 @@ describe('AccountForm', function () {
260
260
 
261
261
  assertButtonEnabled(wrapper);
262
262
  });
263
- it('should be disabled with initialValues', function () {
264
- var account = {
265
- auth: {
266
- username: 'foo',
267
- passphrase: 'bar'
268
- }
269
- };
270
-
271
- var _setup12 = setup({
272
- account: account
273
- }),
274
- wrapper = _setup12.wrapper;
275
-
276
- assertButtonDisabled(wrapper);
277
- });
278
- /**
279
- * This case corresponds to an account edition of a trigger already having
280
- * an error. We are not supposed to submit it without modifications.
281
- */
282
-
283
- it('should be disabled with initialValues AND error', function () {
284
- var account = {
285
- auth: {
286
- username: 'foo',
287
- passphrase: 'bar'
288
- }
289
- };
290
- var error = new Error('Existing trigger error');
291
-
292
- var _setup13 = setup({
293
- account: account,
294
- error: error
295
- }),
296
- wrapper = _setup13.wrapper;
297
-
298
- assertButtonDisabled(wrapper);
299
- });
300
263
  it('should be enabled when an error exists', function () {
301
264
  var account = {};
302
265
  var error = new Error('Test error');
303
266
 
304
- var _setup14 = setup({
267
+ var _setup12 = setup({
305
268
  account: account,
306
269
  error: error
307
270
  }),
308
- wrapper = _setup14.wrapper;
271
+ wrapper = _setup12.wrapper;
309
272
 
310
273
  assertButtonEnabled(wrapper);
311
274
  });
@@ -314,8 +277,8 @@ describe('AccountForm', function () {
314
277
  var loginInput = document.createElement('input');
315
278
  var passwordInput = document.createElement('input');
316
279
  it('should focus next input', function () {
317
- var _setup15 = setup(),
318
- wrapper = _setup15.wrapper;
280
+ var _setup13 = setup(),
281
+ wrapper = _setup13.wrapper;
319
282
 
320
283
  wrapper.instance().inputs = {
321
284
  login: loginInput,
@@ -334,8 +297,8 @@ describe('AccountForm', function () {
334
297
  it('should ignore other keys than ENTER', function () {
335
298
  isMobile.mockReturnValue(false);
336
299
 
337
- var _setup16 = setup(),
338
- wrapper = _setup16.wrapper;
300
+ var _setup14 = setup(),
301
+ wrapper = _setup14.wrapper;
339
302
 
340
303
  wrapper.instance().handleSubmit = jest.fn();
341
304
  wrapper.instance().handleKeyUp({
@@ -346,8 +309,8 @@ describe('AccountForm', function () {
346
309
  it('should submit form', function () {
347
310
  isMobile.mockReturnValue(false);
348
311
 
349
- var _setup17 = setup(),
350
- wrapper = _setup17.wrapper;
312
+ var _setup15 = setup(),
313
+ wrapper = _setup15.wrapper;
351
314
 
352
315
  wrapper.instance().handleSubmit = jest.fn();
353
316
  wrapper.instance().isSubmittable = jest.fn().mockReturnValue(true);
@@ -359,8 +322,8 @@ describe('AccountForm', function () {
359
322
  it('should not submit form', function () {
360
323
  isMobile.mockReturnValue(false);
361
324
 
362
- var _setup18 = setup({}),
363
- wrapper = _setup18.wrapper;
325
+ var _setup16 = setup({}),
326
+ wrapper = _setup16.wrapper;
364
327
 
365
328
  wrapper.instance().handleSubmit = jest.fn();
366
329
  wrapper.instance().isSubmittable = jest.fn().mockReturnValue(false);
@@ -372,8 +335,8 @@ describe('AccountForm', function () {
372
335
  it('should focus next input on mobile', function () {
373
336
  isMobile.mockReturnValue(true);
374
337
 
375
- var _setup19 = setup(),
376
- wrapper = _setup19.wrapper;
338
+ var _setup17 = setup(),
339
+ wrapper = _setup17.wrapper;
377
340
 
378
341
  wrapper.instance().focusNext = jest.fn().mockReturnValue(document.createElement('input'));
379
342
  wrapper.instance().handleKeyUp({
@@ -384,8 +347,8 @@ describe('AccountForm', function () {
384
347
  it('should submit form on mobile', function () {
385
348
  isMobile.mockReturnValue(true);
386
349
 
387
- var _setup20 = setup(),
388
- wrapper = _setup20.wrapper;
350
+ var _setup18 = setup(),
351
+ wrapper = _setup18.wrapper;
389
352
 
390
353
  wrapper.instance().focusNext = jest.fn().mockReturnValue(null);
391
354
  wrapper.instance().isSubmittable = jest.fn().mockReturnValue(true);
@@ -399,8 +362,8 @@ describe('AccountForm', function () {
399
362
  it('should not submit form on mobile', function () {
400
363
  isMobile.mockReturnValue(true);
401
364
 
402
- var _setup21 = setup(),
403
- wrapper = _setup21.wrapper;
365
+ var _setup19 = setup(),
366
+ wrapper = _setup19.wrapper;
404
367
 
405
368
  wrapper.instance().focusNext = jest.fn().mockReturnValue(null);
406
369
  wrapper.instance().isSubmittable = jest.fn().mockReturnValue(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "22.0.6",
3
+ "version": "22.0.7",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -106,5 +106,5 @@
106
106
  "react-router-dom": ">=4.3.1"
107
107
  },
108
108
  "sideEffects": false,
109
- "gitHead": "b7d55abbda1a057fcfe88f0a5558c10c84fdeab7"
109
+ "gitHead": "e96e3f59e027dc5c55614bbe1877b0b7a527b076"
110
110
  }
@@ -71,11 +71,11 @@ export class AccountForm extends PureComponent {
71
71
  * @param {Object} formState See https://github.com/final-form/final-form#formstate
72
72
  * @return {Boolean}
73
73
  */
74
- isSubmittable({ dirty, error, initialValues, valid }) {
75
- const modified = !initialValues || dirty
74
+ isSubmittable({ error, valid }) {
76
75
  // Here error is not a validation error but an instance of a
77
76
  // KonnectorJobError, so submitting again is possible
78
- return modified && (error || valid)
77
+ const result = error || valid
78
+ return result
79
79
  }
80
80
 
81
81
  /**
@@ -115,20 +115,15 @@ export class AccountForm extends PureComponent {
115
115
  * Handle key up and check if `ENTER` key has been pressed. If so, submit the
116
116
  * form if all parmater are ok.
117
117
  * @param {React.SyntheticEvent} event Key events
118
- * @param {Boolean} dirty Indicates if form is dirty, i.e. if values
119
118
  * have changed
120
119
  * @param {Object} form The form object injected by ReactFinalForm.
121
- * @param {Object} initialValues Initial data injected into AccountForm
122
120
  * @param {Boolean} valid Indicates if the form data is valid
123
121
  * @param {Object} values Actual form values data
124
122
  */
125
- handleKeyUp(event, { dirty, form, initialValues, valid, values }) {
123
+ handleKeyUp(event, { form, valid, values }) {
126
124
  if (event.key === 'Enter') {
127
125
  const changedFocus = isMobile() && !!this.focusNext()
128
- if (
129
- !changedFocus &&
130
- this.isSubmittable({ dirty, initialValues, valid })
131
- ) {
126
+ if (!changedFocus && this.isSubmittable({ valid })) {
132
127
  this.handleSubmit(values, form)
133
128
  }
134
129
  }
@@ -242,7 +237,6 @@ export class AccountForm extends PureComponent {
242
237
  const sanitizedFields = manifest.sanitizeFields(fields)
243
238
  fieldHelpers.addForceEncryptedPlaceholder(sanitizedFields, fieldOptions)
244
239
 
245
- const initialValues = account && account.auth
246
240
  const values = manifest.getFieldsValues(konnector, account)
247
241
 
248
242
  const isReadOnlyIdentifier =
@@ -263,13 +257,11 @@ export class AccountForm extends PureComponent {
263
257
  initialValues={values}
264
258
  onSubmit={onSubmit}
265
259
  validate={this.validate(sanitizedFields, values)}
266
- render={({ dirty, form, values, valid }) => (
260
+ render={({ form, values, valid }) => (
267
261
  <div
268
262
  onKeyUp={event =>
269
263
  this.handleKeyUp(event, {
270
- dirty,
271
264
  form,
272
- initialValues,
273
265
  valid,
274
266
  values
275
267
  })
@@ -327,9 +319,7 @@ export class AccountForm extends PureComponent {
327
319
  disabled:
328
320
  submitting ||
329
321
  !this.isSubmittable({
330
- dirty,
331
322
  error,
332
- initialValues,
333
323
  valid
334
324
  }),
335
325
  label: t('accountForm.clientSide.submit'),
@@ -346,9 +336,7 @@ export class AccountForm extends PureComponent {
346
336
  disabled={
347
337
  submitting ||
348
338
  !this.isSubmittable({
349
- dirty,
350
339
  error,
351
- initialValues,
352
340
  valid
353
341
  })
354
342
  }
@@ -230,40 +230,6 @@ describe('AccountForm', () => {
230
230
  assertButtonEnabled(wrapper)
231
231
  })
232
232
 
233
- it('should be disabled with initialValues', () => {
234
- const account = {
235
- auth: {
236
- username: 'foo',
237
- passphrase: 'bar'
238
- }
239
- }
240
- const { wrapper } = setup({
241
- account
242
- })
243
-
244
- assertButtonDisabled(wrapper)
245
- })
246
-
247
- /**
248
- * This case corresponds to an account edition of a trigger already having
249
- * an error. We are not supposed to submit it without modifications.
250
- */
251
- it('should be disabled with initialValues AND error', () => {
252
- const account = {
253
- auth: {
254
- username: 'foo',
255
- passphrase: 'bar'
256
- }
257
- }
258
- const error = new Error('Existing trigger error')
259
- const { wrapper } = setup({
260
- account,
261
- error
262
- })
263
-
264
- assertButtonDisabled(wrapper)
265
- })
266
-
267
233
  it('should be enabled when an error exists', () => {
268
234
  const account = {}
269
235
  const error = new Error('Test error')