Skip to content

Commit

Permalink
remove additional information about deleted fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ruderngespra committed Jan 2, 2020
1 parent bf598b4 commit b3901b6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
20 changes: 20 additions & 0 deletions src/lib/action/content-type-field-purge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { APIAction } from './action'
import OfflineAPI from '../offline-api/index'

class ContentTypeFieldPurgeAction extends APIAction {
private contentTypeId: string
private fieldId: string

constructor (contentTypeId: string, fieldId: string) {
super()
this.contentTypeId = contentTypeId
this.fieldId = fieldId
}

async applyTo (api: OfflineAPI) {
const contentType = await api.getContentType(this.contentTypeId)
contentType.fields.deleteField(this.fieldId)
}
}

export { ContentTypeFieldPurgeAction }
5 changes: 5 additions & 0 deletions src/lib/intent/field-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FieldUpdateAction } from '../action/field-update'
import { ContentTypeSaveAction } from '../action/content-type-save'
import { ContentTypePublishAction } from '../action/content-type-publish'
import { EntryFieldPurgeAction } from '../action/entry-field-purge'
import { ContentTypeFieldPurgeAction } from '../action/content-type-field-purge'
import { PlanMessage } from '../interfaces/plan-message'
import chalk from 'chalk'

Expand Down Expand Up @@ -41,6 +42,10 @@ export default class FieldDeleteIntent extends Intent {
new EntryFieldPurgeAction(
contentTypeId,
fieldId
),
new ContentTypeFieldPurgeAction(
contentTypeId,
fieldId
)
]
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/contentful-migration-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ nock('https://api.contentful.com:443', {"encodedQueryParams":true})


nock('https://api.contentful.com:443', {"encodedQueryParams":true})
.put('/spaces/bohepdihyxin/environments/env-integration/content_types/dog', {"name":"angry dog","displayField":null,"fields":[{"id":"woofs","name":"woof woof","type":"Number","localized":false,"required":true,"validations":[],"disabled":false,"omitted":true,"deleted":true}],"description":"super angry"})
.put('/spaces/bohepdihyxin/environments/env-integration/content_types/dog', {"name":"angry dog","displayField":null,"fields":[],"description":"super angry"})
.reply(200, {
"sys": {
"space": {
Expand Down
15 changes: 0 additions & 15 deletions test/unit/lib/offline-api/request-batches.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ describe('Payload builder', function () {
type: 'Number',
name: 'kills',
required: true
},
{
id: 'favoriteFood',
type: 'Symbol',
name: 'food',
required: true,
omitted: true,
deleted: true
}
]
}
Expand Down Expand Up @@ -178,13 +170,6 @@ describe('Payload builder', function () {
required: true
},
{
id: 'favoriteFood',
type: 'Symbol',
name: 'food',
required: true,
omitted: true,
deleted: true
}, {
id: 'foo',
type: 'Symbol',
name: 'A foo'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('payload validation (display field)', function () {
[
{
type: 'InvalidAction',
message: 'Cannot delete field "dessert" on content type "lunch" because it is set as the display field'
message: 'Cannot set "dessert" as displayField on content type "lunch" because it does not exist'
}
]
])
Expand Down

0 comments on commit b3901b6

Please sign in to comment.