Skip to content

Commit

Permalink
fix(extensions): address inconsistent signature for changeFieldControl (
Browse files Browse the repository at this point in the history
  • Loading branch information
lehnerm authored and makinwab committed Aug 21, 2019
1 parent f508a99 commit be59e90
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
- [`editField(id[, opts])` : [Field](#field)](#editfieldid-opts--fieldfield)
- [`deleteField(id)` : void](#deletefieldid--void)
- [`changeFieldId (currentId, newId)` : void](#changefieldid-currentid-newid--void)
- [`changeFieldControl (fieldId, widgetId, widgetNamespace[, settings])` : void](#changefieldcontrol-fieldid-widgetid-widgetnamespace-settings--void)
- [`changeFieldControl (fieldId, widgetNamespace, widgetId[, settings])` : void](#changefieldcontrol-fieldid-widgetnamespace-widgetid-settings--void)
- [`resetFieldControl (fieldId)` : void](#resetfieldcontrol-fieldid--void)
- [`copyFieldControl (sourceFieldId, destinationFieldId)` : void](#copyfieldcontrol-sourcefieldid-destinationfieldid--void)
- [`addSidebarWidget (widgetNamespace, widgetId[, settings, insertBeforeWidgetId])` : void](#addsidebarwidget-widgetnamespace-widgetid-settings-insertbeforewidgetid--void)
Expand Down Expand Up @@ -523,18 +523,18 @@ module.exports = function (migration) {
};
```

#### `changeFieldControl (fieldId, widgetId, widgetNamespace[, settings])` : void
#### `changeFieldControl (fieldId, widgetNamespace, widgetId[, settings])` : void

Changes control interface of given field's ID.

**`fieldId : string`** – The ID of the field.

**`widgetId : string`** – The new widget ID for the field. See the [editor interface documentation](https://www.contentful.com/developers/docs/concepts/editor-interfaces/) for a list of available widgets.

**`widgetNamespace : string`** – The namespace of the widget, one of the following values:
- `builtin` (Standard widget)
- `extension` (Custom UI extension)

**`widgetId : string`** – The new widget ID for the field. See the [editor interface documentation](https://www.contentful.com/developers/docs/concepts/editor-interfaces/) for a list of available widgets.

**`settings : Object`** – Widget settings and extension instance parameters. Key-value pairs of type (string, number | boolean | string). For builtin widgets, the the following options are available:

- **`helpText : string`** – This help text will show up below the field.
Expand Down
2 changes: 1 addition & 1 deletion examples/16-change-field-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ module.exports = function (migration) {
type: 'Symbol',
required: true
});
blogPost.changeFieldControl('slug', 'slugEditor', 'builtin', { setting: 'value' });
blogPost.changeFieldControl('slug', 'builtin', 'slugEditor', { setting: 'value' });
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ module.exports = function (migration) {

blogPost
.resetFieldControl('slug')
.changeFieldControl('slug', 'singleLine', 'builtin');
.changeFieldControl('slug', 'builtin', 'singleLine');
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module.exports = function (migration) {

blogPost.changeFieldControl(
'slug',
'slugEditor',
'builtin',
'slugEditor',
{ helpText: 'This is the slug for the entry, it will be used for the URL' }
);
};
2 changes: 1 addition & 1 deletion examples/21-copy-field-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ module.exports = function (migration) {
name: 'Instruction',
type: 'Text'
});
recipe.changeFieldControl('description', 'markdown', 'builtin');
recipe.changeFieldControl('description', 'builtin', 'markdown');
recipe.copyFieldControl('description', 'instruction');
};
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ export interface ContentType {
/**
* Changes the control of given field's ID.
*
* @param widgetNamespace The namespace of the widget. Use 'builtin' for standard widgets or 'extension' for UI extensions.
* @param fieldId The ID of the field.
* @param widgetNamespace The namespace of the widget. Use 'builtin' for standard widgets or 'extension' for UI extensions.
* @param widgetId The new widget ID for the field.
* @param settings Widget settings
*/
Expand Down
4 changes: 2 additions & 2 deletions src/lib/migration-steps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ContentType extends DispatchProxy {
))
}

changeFieldControl (fieldId, widgetId, widgetNamespace, settings) {
changeFieldControl (fieldId, widgetNamespace, widgetId, settings) {
const callsite = getFirstExternalCaller()
this.dispatch(actionCreators.contentType.changeEditorInterface(
this.id,
Expand All @@ -162,7 +162,7 @@ class ContentType extends DispatchProxy {
/** deprecated, use changeFieldControl instead */
changeEditorInterface (fieldId, widgetId, settings, widgetNamespace) {
deprecatedMethod('changeEditorInterface', 'changeFieldControl')
return this.changeFieldControl(fieldId, widgetId, widgetNamespace, settings)
return this.changeFieldControl(fieldId, widgetNamespace, widgetId, settings)
}

copyFieldControl (sourceFieldId, destinationFieldId) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/migration-steps/migration-steps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ describe('migration-steps', function () {
const plan = yield migration(function (migration) {
migration
.editContentType('book')
.changeFieldControl('title', 'markdown', 'builtin')
.changeFieldControl('desc', 'singleLine', 'builtin');
.changeFieldControl('title', 'builtin', 'markdown')
.changeFieldControl('desc', 'builtin', 'singleLine');
});

expect(stripCallsites(plan)).to.eql([
Expand Down

0 comments on commit be59e90

Please sign in to comment.