Update types
This commit is contained in:
parent
452eba8635
commit
c0f26819dc
|
@ -252,7 +252,6 @@ const performAppCreate = async (ctx: any) => {
|
||||||
const appId = instance._id
|
const appId = instance._id
|
||||||
const db = context.getAppDB()
|
const db = context.getAppDB()
|
||||||
|
|
||||||
// Create new app doc
|
|
||||||
let newApplication: App = {
|
let newApplication: App = {
|
||||||
_id: DocumentType.APP_METADATA,
|
_id: DocumentType.APP_METADATA,
|
||||||
_rev: undefined,
|
_rev: undefined,
|
||||||
|
@ -263,7 +262,7 @@ const performAppCreate = async (ctx: any) => {
|
||||||
name: name,
|
name: name,
|
||||||
url: url,
|
url: url,
|
||||||
template: templateKey,
|
template: templateKey,
|
||||||
instance: instance,
|
instance,
|
||||||
tenantId: getTenantId(),
|
tenantId: getTenantId(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
|
@ -290,15 +289,14 @@ const performAppCreate = async (ctx: any) => {
|
||||||
// Fetch and migrate some metadata from the existing app.
|
// Fetch and migrate some metadata from the existing app.
|
||||||
try {
|
try {
|
||||||
const existing: App = await db.get(DocumentType.APP_METADATA)
|
const existing: App = await db.get(DocumentType.APP_METADATA)
|
||||||
const keys: string[] = [
|
const keys: (keyof App)[] = [
|
||||||
"_rev",
|
"_rev",
|
||||||
"navigation",
|
"navigation",
|
||||||
"theme",
|
"theme",
|
||||||
"customTheme",
|
"customTheme",
|
||||||
"icon",
|
"icon",
|
||||||
]
|
]
|
||||||
keys.forEach((key: string) => {
|
keys.forEach(key => {
|
||||||
// @ts-ignore
|
|
||||||
if (existing[key]) {
|
if (existing[key]) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
newApplication[key] = existing[key]
|
newApplication[key] = existing[key]
|
||||||
|
@ -602,17 +600,15 @@ const updateAppPackage = async (appPackage: any, appId: any) => {
|
||||||
const migrateAppNavigation = async () => {
|
const migrateAppNavigation = async () => {
|
||||||
const db = context.getAppDB()
|
const db = context.getAppDB()
|
||||||
const existing: App = await db.get(DocumentType.APP_METADATA)
|
const existing: App = await db.get(DocumentType.APP_METADATA)
|
||||||
const layouts = await getLayouts()
|
const layouts: Layout[] = await getLayouts()
|
||||||
const screens = await getScreens()
|
const screens: Screen[] = await getScreens()
|
||||||
|
|
||||||
// Migrate all screens, removing custom layouts
|
// Migrate all screens, removing custom layouts
|
||||||
for (let screen of screens) {
|
for (let screen of screens) {
|
||||||
if (!screen.layoutId) {
|
if (!screen.layoutId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const layout = layouts.find(
|
const layout = layouts.find(layout => layout._id === screen.layoutId)
|
||||||
(layout: Layout) => layout._id === screen.layoutId
|
|
||||||
)
|
|
||||||
screen.layoutId = undefined
|
screen.layoutId = undefined
|
||||||
screen.showNavigation = layout?.props.navigation !== "None"
|
screen.showNavigation = layout?.props.navigation !== "None"
|
||||||
screen.width = layout?.props.width || "Large"
|
screen.width = layout?.props.width || "Large"
|
||||||
|
|
|
@ -18,6 +18,7 @@ export interface App extends Document {
|
||||||
revertableVersion?: string
|
revertableVersion?: string
|
||||||
navigation?: AppNavigation
|
navigation?: AppNavigation
|
||||||
automationErrors?: AppMetadataErrors
|
automationErrors?: AppMetadataErrors
|
||||||
|
icon?: AppIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppInstance {
|
export interface AppInstance {
|
||||||
|
@ -53,3 +54,8 @@ export interface AppCustomTheme {
|
||||||
navTextColor?: string
|
navTextColor?: string
|
||||||
navBackground?: string
|
navBackground?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AppIcon {
|
||||||
|
name: string
|
||||||
|
color: string
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import { Document } from "../document"
|
import { Document } from "../document"
|
||||||
|
|
||||||
export interface Layout extends Document {}
|
export interface Layout extends Document {
|
||||||
|
props: any
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue