@contentful/field-editor-slug 2.1.5-canary.6 → 2.2.1-canary.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.
|
@@ -274,36 +274,6 @@ describe('SlugEditor', ()=>{
|
|
|
274
274
|
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
275
275
|
});
|
|
276
276
|
});
|
|
277
|
-
it('shows warning instead of error when unique validation is disabled on content model', async ()=>{
|
|
278
|
-
const { field, sdk } = createMocks({
|
|
279
|
-
titleField: 'Slug value',
|
|
280
|
-
field: 'slug-value'
|
|
281
|
-
});
|
|
282
|
-
field.validations = [];
|
|
283
|
-
sdk.entry.getSys.mockReturnValue({
|
|
284
|
-
id: 'entry-id',
|
|
285
|
-
publishedVersion: undefined,
|
|
286
|
-
contentType: {
|
|
287
|
-
sys: {
|
|
288
|
-
id: 'content-type-id'
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
sdk.cma.entry.getMany.mockResolvedValue({
|
|
293
|
-
total: 2
|
|
294
|
-
});
|
|
295
|
-
const { queryByText, getByTestId } = (0, _react1.render)(/*#__PURE__*/ _react.createElement(_SlugEditor.SlugEditor, {
|
|
296
|
-
field: field,
|
|
297
|
-
baseSdk: sdk,
|
|
298
|
-
isInitiallyDisabled: false
|
|
299
|
-
}));
|
|
300
|
-
await (0, _react1.waitFor)(()=>{
|
|
301
|
-
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(1);
|
|
302
|
-
expect(queryByText('Warning: This slug has already been published in another entry. Enable "Unique" validation in the content model to enforce this as an error.')).toBeInTheDocument();
|
|
303
|
-
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
304
|
-
expect(getByTestId('cf-ui-text-input')).not.toHaveAttribute('aria-invalid');
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
277
|
});
|
|
308
278
|
describe('should react to title changes', ()=>{
|
|
309
279
|
it('when field is disabled', async ()=>{
|
|
@@ -19,7 +19,6 @@ _export(exports, {
|
|
|
19
19
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
20
|
const _f36components = require("@contentful/f36-components");
|
|
21
21
|
const _f36icons = require("@contentful/f36-icons");
|
|
22
|
-
const _f36note = require("@contentful/f36-note");
|
|
23
22
|
const _core = require("@lingui/core");
|
|
24
23
|
const _usedebounce = require("use-debounce");
|
|
25
24
|
const _makeSlug = require("./services/makeSlug");
|
|
@@ -146,13 +145,6 @@ function SlugEditorFieldStatic(props) {
|
|
|
146
145
|
}, _core.i18n._({
|
|
147
146
|
id: "FieldEditors.Slug.SlugEditorField.DuplicateSlugError",
|
|
148
147
|
message: "This slug has already been published in another entry"
|
|
149
|
-
})), hasDuplicate && !isUniqueValidationEnabled && /*#__PURE__*/ _react.createElement(_f36note.Note, {
|
|
150
|
-
variant: "warning",
|
|
151
|
-
testId: "slug-editor-duplicate-warning",
|
|
152
|
-
className: _styles.uniqueValidationError
|
|
153
|
-
}, _core.i18n._({
|
|
154
|
-
id: "FieldEditors.Slug.SlugEditorField.DuplicateSlugWarning",
|
|
155
|
-
message: 'Warning: This slug has already been published in another entry. Enable "Unique" validation in the content model to enforce this as an error.'
|
|
156
148
|
})));
|
|
157
149
|
}
|
|
158
150
|
function SlugEditorField(props) {
|
|
@@ -229,36 +229,6 @@ describe('SlugEditor', ()=>{
|
|
|
229
229
|
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
230
230
|
});
|
|
231
231
|
});
|
|
232
|
-
it('shows warning instead of error when unique validation is disabled on content model', async ()=>{
|
|
233
|
-
const { field, sdk } = createMocks({
|
|
234
|
-
titleField: 'Slug value',
|
|
235
|
-
field: 'slug-value'
|
|
236
|
-
});
|
|
237
|
-
field.validations = [];
|
|
238
|
-
sdk.entry.getSys.mockReturnValue({
|
|
239
|
-
id: 'entry-id',
|
|
240
|
-
publishedVersion: undefined,
|
|
241
|
-
contentType: {
|
|
242
|
-
sys: {
|
|
243
|
-
id: 'content-type-id'
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
sdk.cma.entry.getMany.mockResolvedValue({
|
|
248
|
-
total: 2
|
|
249
|
-
});
|
|
250
|
-
const { queryByText, getByTestId } = render(/*#__PURE__*/ React.createElement(SlugEditor, {
|
|
251
|
-
field: field,
|
|
252
|
-
baseSdk: sdk,
|
|
253
|
-
isInitiallyDisabled: false
|
|
254
|
-
}));
|
|
255
|
-
await waitFor(()=>{
|
|
256
|
-
expect(sdk.cma.entry.getMany).toHaveBeenCalledTimes(1);
|
|
257
|
-
expect(queryByText('Warning: This slug has already been published in another entry. Enable "Unique" validation in the content model to enforce this as an error.')).toBeInTheDocument();
|
|
258
|
-
expect(queryByText('This slug has already been published in another entry')).not.toBeInTheDocument();
|
|
259
|
-
expect(getByTestId('cf-ui-text-input')).not.toHaveAttribute('aria-invalid');
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
232
|
});
|
|
263
233
|
describe('should react to title changes', ()=>{
|
|
264
234
|
it('when field is disabled', async ()=>{
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Spinner, TextInput, ValidationMessage } from '@contentful/f36-components';
|
|
3
3
|
import { LinkSimpleIcon } from '@contentful/f36-icons';
|
|
4
|
-
import { Note } from '@contentful/f36-note';
|
|
5
4
|
import { i18n as $_i18n } from "@lingui/core";
|
|
6
5
|
import { useDebounce } from 'use-debounce';
|
|
7
6
|
import { makeSlug } from './services/makeSlug';
|
|
@@ -87,13 +86,6 @@ export function SlugEditorFieldStatic(props) {
|
|
|
87
86
|
}, $_i18n._({
|
|
88
87
|
id: "FieldEditors.Slug.SlugEditorField.DuplicateSlugError",
|
|
89
88
|
message: "This slug has already been published in another entry"
|
|
90
|
-
})), hasDuplicate && !isUniqueValidationEnabled && /*#__PURE__*/ React.createElement(Note, {
|
|
91
|
-
variant: "warning",
|
|
92
|
-
testId: "slug-editor-duplicate-warning",
|
|
93
|
-
className: styles.uniqueValidationError
|
|
94
|
-
}, $_i18n._({
|
|
95
|
-
id: "FieldEditors.Slug.SlugEditorField.DuplicateSlugWarning",
|
|
96
|
-
message: 'Warning: This slug has already been published in another entry. Enable "Unique" validation in the content model to enforce this as an error.'
|
|
97
89
|
})));
|
|
98
90
|
}
|
|
99
91
|
export function SlugEditorField(props) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-slug",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1-canary.2+dbb30e39",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"registry": "https://npm.pkg.github.com/"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "dbb30e3967c7d082110d7781339b79a0bb03d247"
|
|
63
63
|
}
|