Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: editorInterface methods do not reset custom sidebar anymore #175

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/lib/entities/content-type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIContentType, Field, APIEditorInterfaceControl, APIEditorInterfaces, APIEditorInterfaceSettings } from '../interfaces/content-type'
import { APIContentType, Field, APIEditorInterfaceControl, APIEditorInterfaces, APIEditorInterfaceSettings, APIEditorInterfaceSidebar } from '../interfaces/content-type'
import { cloneDeep, find, filter, findIndex, pull, forEach } from 'lodash'

class Fields {
Expand Down Expand Up @@ -81,10 +81,12 @@ class Fields {
class EditorInterfaces {
private _version: number
private _controls: APIEditorInterfaceControl[]
private _sidebar?: APIEditorInterfaceSidebar[]

constructor (apiEditorInterfaces: APIEditorInterfaces) {
this._version = apiEditorInterfaces.sys.version
this._controls = apiEditorInterfaces.controls
this._sidebar = apiEditorInterfaces.sidebar || undefined
}

get version () {
Expand Down Expand Up @@ -146,6 +148,12 @@ class EditorInterfaces {
settings: c.settings
})
})
if (this._sidebar) {
return {
controls: result,
sidebar: this._sidebar
}
}
return {
controls: result
}
Expand Down
14 changes: 12 additions & 2 deletions src/lib/interfaces/content-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,24 @@ interface APIEditorInterfaceSettings {

interface APIEditorInterfaceControl {
fieldId: string,
widgetId: string,
widgetId?: string,
widgetNamespace?: 'builtin' | 'extension',
settings?: APIEditorInterfaceSettings
}

interface APIEditorInterfaceSidebar {
widgetId: string,
widgetNamespace: 'builtin' | 'extension',
disabled?: boolean,
settings?: { [key: string]: any }
}

interface APIEditorInterfaces {
sys: {
version: number
}
controls: APIEditorInterfaceControl[]
sidebar?: APIEditorInterfaceSidebar[]
}

export {
Expand All @@ -57,5 +66,6 @@ export {
Field,
APIEditorInterfaces,
APIEditorInterfaceControl,
APIEditorInterfaceSettings
APIEditorInterfaceSettings,
APIEditorInterfaceSidebar
}
3 changes: 2 additions & 1 deletion test/unit/lib/offline-api/build-payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const buildPayloads = async function (runMigration, contentTypes: APIContentType
sys: {
version: 1
},
controls: []
controls: [],
sidebar: undefined
})
const editorInterfacesByContentType: Map<String, EditorInterfaces> = new Map()

Expand Down