2016-12-01 01:50:59 +00:00
|
|
|
import * as db from '../common/database';
|
2017-03-28 22:45:23 +00:00
|
|
|
import {DEFAULT_SIDEBAR_WIDTH, DEFAULT_PANE_WIDTH, DEFAULT_PANE_HEIGHT} from '../common/constants';
|
2016-12-01 01:50:59 +00:00
|
|
|
|
|
|
|
export const name = 'Workspace Meta';
|
|
|
|
export const type = 'WorkspaceMeta';
|
|
|
|
export const prefix = 'wrkm';
|
2017-03-23 22:10:42 +00:00
|
|
|
export const canDuplicate = true;
|
2016-12-01 01:50:59 +00:00
|
|
|
|
|
|
|
export function init () {
|
|
|
|
return {
|
|
|
|
parentId: null,
|
|
|
|
activeRequestId: null,
|
|
|
|
activeEnvironmentId: null,
|
|
|
|
sidebarFilter: '',
|
|
|
|
sidebarHidden: false,
|
|
|
|
sidebarWidth: DEFAULT_SIDEBAR_WIDTH,
|
2017-03-28 22:45:23 +00:00
|
|
|
paneWidth: DEFAULT_PANE_WIDTH,
|
|
|
|
paneHeight: DEFAULT_PANE_HEIGHT
|
2017-03-03 20:09:08 +00:00
|
|
|
};
|
2016-12-01 01:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function migrate (doc) {
|
|
|
|
return doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function create (patch = {}) {
|
|
|
|
if (!patch.parentId) {
|
|
|
|
throw new Error('New WorkspaceMeta missing `parentId`', patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
return db.docCreate(type, patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function update (workspaceMeta, patch) {
|
|
|
|
return db.docUpdate(workspaceMeta, patch);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getByParentId (parentId) {
|
2017-03-03 20:09:08 +00:00
|
|
|
return db.getWhere(type, {parentId});
|
2016-12-01 01:50:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function all () {
|
|
|
|
return db.all(type);
|
|
|
|
}
|