diff --git a/packages/auth/src/db/Replication.js b/packages/auth/src/db/Replication.js index 9720776413..931bc3d496 100644 --- a/packages/auth/src/db/Replication.js +++ b/packages/auth/src/db/Replication.js @@ -31,7 +31,7 @@ class Replication { * Two way replication operation, intended to be promise based. * @param {Object} opts - PouchDB replication options */ - sync(opts) { + sync(opts = {}) { this.replication = this.promisify(this.source.sync, opts) return this.replication } @@ -40,7 +40,7 @@ class Replication { * One way replication operation, intended to be promise based. * @param {Object} opts - PouchDB replication options */ - replicate(opts) { + replicate(opts = {}) { this.replication = this.promisify(this.source.replicate.to, opts) return this.replication } @@ -61,8 +61,13 @@ class Replication { }) } + /** + * Rollback the target DB back to the state of the source DB + */ async rollback() { await this.target.destroy() + // Recreate the DB again + this.target = getDB(this.target.name) await this.replicate() } diff --git a/packages/auth/src/db/utils.js b/packages/auth/src/db/utils.js index 3f97a01a1c..b5e5242cb5 100644 --- a/packages/auth/src/db/utils.js +++ b/packages/auth/src/db/utils.js @@ -13,6 +13,9 @@ exports.StaticDatabases = { GLOBAL: { name: "global-db", }, + DEPLOYMENTS: { + name: "deployments", + }, } const DocumentTypes = { @@ -22,6 +25,7 @@ const DocumentTypes = { TEMPLATE: "template", APP: "app", APP_DEV: "app_dev", + APP_METADATA: "app_metadata", ROLE: "role", } @@ -162,7 +166,7 @@ exports.getAllApps = async (devApps = false) => { const appDbNames = allDbs.filter(dbName => dbName.startsWith(exports.APP_PREFIX) ) - const appPromises = appDbNames.map(db => new CouchDB(db).get(db)) + const appPromises = appDbNames.map(db => new CouchDB(db).get(DocumentTypes.APP_METADATA)) if (appPromises.length === 0) { return [] } else { @@ -172,9 +176,9 @@ exports.getAllApps = async (devApps = false) => { .map(({ value }) => value) return apps.filter(app => { if (devApps) { - return app._id.startsWith(exports.APP_DEV_PREFIX) + return app.appId.startsWith(exports.APP_DEV_PREFIX) } - return !app._id.startsWith(exports.APP_DEV_PREFIX) + return !app.appId.startsWith(exports.APP_DEV_PREFIX) }) } } diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index be553066b9..0d80065f2f 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -51,14 +51,14 @@ export const getFrontendStore = () => { store.actions = { initialise: async pkg => { const { layouts, screens, application, clientLibPath } = pkg - const components = await fetchComponentLibDefinitions(application._id) + const components = await fetchComponentLibDefinitions(application.appId) store.update(state => ({ ...state, libraries: application.componentLibraries, components, name: application.name, description: application.description, - appId: application._id, + appId: application.appId, url: application.url, layouts, screens, diff --git a/packages/builder/src/components/deploy/DeployModal.svelte b/packages/builder/src/components/deploy/DeployModal.svelte new file mode 100644 index 0000000000..5fffa4cd55 --- /dev/null +++ b/packages/builder/src/components/deploy/DeployModal.svelte @@ -0,0 +1,110 @@ + + + + + + + The changes you have made will be published to the production version of the application. + + diff --git a/packages/builder/src/components/deploy/RevertModal.svelte b/packages/builder/src/components/deploy/RevertModal.svelte new file mode 100644 index 0000000000..7eaac42bbd --- /dev/null +++ b/packages/builder/src/components/deploy/RevertModal.svelte @@ -0,0 +1,35 @@ + + + + + + + The changes you have made will be deleted and the application reverted back to its production state. + + diff --git a/packages/builder/src/components/start/AppCard.svelte b/packages/builder/src/components/start/AppCard.svelte index a4edb756f4..3e7d87bb0f 100644 --- a/packages/builder/src/components/start/AppCard.svelte +++ b/packages/builder/src/components/start/AppCard.svelte @@ -41,7 +41,7 @@ {/if} {#if app.lockedBy && app.lockedBy?.email === $auth.user?.email} - releaseLock(app._id)} icon="LockOpen"> + releaseLock(app.appId)} icon="LockOpen"> Release Lock {/if} diff --git a/packages/builder/src/components/start/AppRow.svelte b/packages/builder/src/components/start/AppRow.svelte index 693c717ab5..1a4ec1a152 100644 --- a/packages/builder/src/components/start/AppRow.svelte +++ b/packages/builder/src/components/start/AppRow.svelte @@ -50,7 +50,7 @@ deleteApp(app)} icon="Delete">Delete {/if} {#if app.lockedBy && app.lockedBy?.email === $auth.user?.email} - releaseLock(app._id)} icon="LockOpen"> + releaseLock(app.appId)} icon="LockOpen"> Release Lock {/if} diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index 44859fbb17..8d2ec56655 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -96,7 +96,7 @@ // Select Correct Application/DB in prep for creating user const applicationPkg = await get( - `/api/applications/${appJson._id}/appPackage` + `/api/applications/${appJson.instance._id}/appPackage` ) const pkg = await applicationPkg.json() if (applicationPkg.ok) { @@ -112,7 +112,7 @@ } const userResp = await api.post(`/api/users/metadata/self`, user) await userResp.json() - $goto(`/builder/app/${appJson._id}`) + $goto(`/builder/app/${appJson.instance._id}`) } catch (error) { console.error(error) notifications.error(error) diff --git a/packages/builder/src/pages/builder/app/[application]/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/_layout.svelte index 98846b3db7..ba4181c6cc 100644 --- a/packages/builder/src/pages/builder/app/[application]/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/_layout.svelte @@ -1,10 +1,12 @@