This commit is contained in:
Martin McKeaveney 2021-05-17 21:43:50 +01:00
parent ad64d58af4
commit ee9a097979
11 changed files with 66 additions and 43 deletions

View File

@ -166,7 +166,9 @@ exports.getAllApps = async (devApps = false) => {
const appDbNames = allDbs.filter(dbName => const appDbNames = allDbs.filter(dbName =>
dbName.startsWith(exports.APP_PREFIX) dbName.startsWith(exports.APP_PREFIX)
) )
const appPromises = appDbNames.map(db => new CouchDB(db).get(DocumentTypes.APP_METADATA)) const appPromises = appDbNames.map(db =>
new CouchDB(db).get(DocumentTypes.APP_METADATA)
)
if (appPromises.length === 0) { if (appPromises.length === 0) {
return [] return []
} else { } else {

View File

@ -143,7 +143,6 @@ class RedisWrapper {
} }
async clear() { async clear() {
const db = this._db
let items = await this.scan() let items = await this.scan()
await Promise.all(items.map(obj => this.delete(obj.key))) await Promise.all(items.map(obj => this.delete(obj.key)))
} }

View File

@ -14,7 +14,6 @@
const POLL_INTERVAL = 1000 const POLL_INTERVAL = 1000
let loading = false let loading = false
let feedbackModal let feedbackModal
let deployments = [] let deployments = []
@ -64,7 +63,10 @@
function checkIncomingDeploymentStatus(current, incoming) { function checkIncomingDeploymentStatus(current, incoming) {
console.log(current, incoming) console.log(current, incoming)
for (let incomingDeployment of incoming) { for (let incomingDeployment of incoming) {
if (incomingDeployment.status === DeploymentStatus.FAILURE || incomingDeployment.status === DeploymentStatus.SUCCESS) { if (
incomingDeployment.status === DeploymentStatus.FAILURE ||
incomingDeployment.status === DeploymentStatus.SUCCESS
) {
const currentDeployment = current.find( const currentDeployment = current.find(
deployment => deployment._id === incomingDeployment._id deployment => deployment._id === incomingDeployment._id
) )
@ -77,14 +79,17 @@
if (incomingDeployment.status === DeploymentStatus.FAILURE) { if (incomingDeployment.status === DeploymentStatus.FAILURE) {
notifications.error(incomingDeployment.err) notifications.error(incomingDeployment.err)
} else { } else {
notifications.send("Published to Production.", "success", "CheckmarkCircle") notifications.send(
"Published to Production.",
"success",
"CheckmarkCircle"
)
} }
} }
} }
} }
} }
onMount(() => { onMount(() => {
fetchDeployments() fetchDeployments()
poll = setInterval(fetchDeployments, POLL_INTERVAL) poll = setInterval(fetchDeployments, POLL_INTERVAL)
@ -93,19 +98,16 @@
onDestroy(() => clearInterval(poll)) onDestroy(() => clearInterval(poll))
</script> </script>
<Button secondary on:click={publishModal.show}>Publish</Button>
<Button
secondary
on:click={publishModal.show}
>
Publish
</Button>
<Modal bind:this={publishModal}> <Modal bind:this={publishModal}>
<ModalContent <ModalContent
title="Publish to Production" title="Publish to Production"
confirmText="Publish" confirmText="Publish"
onConfirm={deployApp} onConfirm={deployApp}
> >
<span>The changes you have made will be published to the production version of the application.</span> <span
</ModalContent> >The changes you have made will be published to the production version of
the application.</span
>
</ModalContent>
</Modal> </Modal>

View File

@ -1,6 +1,12 @@
<script> <script>
import { onMount, onDestroy } from "svelte" import { onMount, onDestroy } from "svelte"
import { Button, Icon, Modal, notifications, ModalContent } from "@budibase/bbui" import {
Button,
Icon,
Modal,
notifications,
ModalContent,
} from "@budibase/bbui"
import { store } from "builderStore" import { store } from "builderStore"
import { apps } from "stores/portal" import { apps } from "stores/portal"
import api from "builderStore/api" import api from "builderStore/api"
@ -15,8 +21,10 @@
const json = await response.json() const json = await response.json()
if (response.status !== 200) throw json.message if (response.status !== 200) throw json.message
// Reset frontend state after revert // Reset frontend state after revert
const applicationPkg = await api.get(`/api/applications/${appId}/appPackage`) const applicationPkg = await api.get(
`/api/applications/${appId}/appPackage`
)
const pkg = await applicationPkg.json() const pkg = await applicationPkg.json()
if (applicationPkg.ok) { if (applicationPkg.ok) {
await store.actions.initialise(pkg) await store.actions.initialise(pkg)
@ -31,14 +39,12 @@
} }
</script> </script>
<Icon name="Revert" hoverable on:click={revertModal.show} /> <Icon name="Revert" hoverable on:click={revertModal.show} />
<Modal bind:this={revertModal}> <Modal bind:this={revertModal}>
<ModalContent <ModalContent title="Revert Changes" confirmText="Revert" onConfirm={revert}>
title="Revert Changes" <span
confirmText="Revert" >The changes you have made will be deleted and the application reverted
onConfirm={revert} back to its production state.</span
> >
<span>The changes you have made will be deleted and the application reverted back to its production state.</span> </ModalContent>
</ModalContent>
</Modal> </Modal>

View File

@ -1,7 +1,16 @@
<script> <script>
import { store, automationStore } from "builderStore" import { store, automationStore } from "builderStore"
import { roles } from "stores/backend" import { roles } from "stores/backend"
import { Button, Icon, Modal, ModalContent, ActionGroup, ActionButton, Tabs, Tab } from "@budibase/bbui" import {
Button,
Icon,
Modal,
ModalContent,
ActionGroup,
ActionButton,
Tabs,
Tab,
} from "@budibase/bbui"
import SettingsLink from "components/settings/Link.svelte" import SettingsLink from "components/settings/Link.svelte"
import ThemeEditorDropdown from "components/settings/ThemeEditorDropdown.svelte" import ThemeEditorDropdown from "components/settings/ThemeEditorDropdown.svelte"
import FeedbackNavLink from "components/feedback/FeedbackNavLink.svelte" import FeedbackNavLink from "components/feedback/FeedbackNavLink.svelte"
@ -84,7 +93,9 @@
</div> </div>
<div class="toprightnav"> <div class="toprightnav">
<RevertModal /> <RevertModal />
<Icon name="Play" hoverable <Icon
name="Play"
hoverable
on:click={() => { on:click={() => {
window.open(`/${application}`) window.open(`/${application}`)
}} }}

View File

@ -63,14 +63,16 @@
const openApp = app => { const openApp = app => {
if (app.lockedBy && app.lockedBy?.email !== $auth.user?.email) { if (app.lockedBy && app.lockedBy?.email !== $auth.user?.email) {
notifications.error(`App locked by ${app.lockedBy.email}. Please allow lock to expire or have them unlock this app.`) notifications.error(
`App locked by ${app.lockedBy.email}. Please allow lock to expire or have them unlock this app.`
)
return return
} }
if (appStatus === AppStatus.DEV) { if (appStatus === AppStatus.DEV) {
$goto(`../../app/${app.appId}`) $goto(`../../app/${app.appId}`)
} else { } else {
window.open(`/${app.appId}`, '_blank'); window.open(`/${app.appId}`, "_blank")
} }
} }

View File

@ -1,4 +1,4 @@
export { organisation } from "./organisation" export { organisation } from "./organisation"
export { admin } from "./admin" export { admin } from "./admin"
export { apps } from "./apps" export { apps } from "./apps"
export { email } from "./email" export { email } from "./email"

View File

@ -244,7 +244,7 @@ exports.delete = async function (ctx) {
} }
const createEmptyAppPackage = async (ctx, app) => { const createEmptyAppPackage = async (ctx, app) => {
const db = new CouchDB(app.instance._id) const db = new CouchDB(app.appId)
let screensAndLayouts = [] let screensAndLayouts = []
for (let layout of BASE_LAYOUTS) { for (let layout of BASE_LAYOUTS) {

View File

@ -1,15 +1,12 @@
const CouchDB = require("../../db") const CouchDB = require("../../db")
const { const {
getBuiltinRoles,
Role, Role,
getRole, getRole,
isBuiltin, isBuiltin,
getExternalRoleID,
getAllRoles, getAllRoles,
} = require("@budibase/auth/roles") } = require("@budibase/auth/roles")
const { const {
generateRoleID, generateRoleID,
getRoleParams,
getUserMetadataParams, getUserMetadataParams,
InternalTables, InternalTables,
} = require("../../db/utils") } = require("../../db/utils")

View File

@ -1,5 +1,9 @@
const { getAllRoles } = require("@budibase/auth/roles") const { getAllRoles } = require("@budibase/auth/roles")
const { getAllApps, getDeployedAppID, DocumentTypes } = require("@budibase/auth/db") const {
getAllApps,
getDeployedAppID,
DocumentTypes,
} = require("@budibase/auth/db")
const CouchDB = require("../../../db") const CouchDB = require("../../../db")
exports.fetch = async ctx => { exports.fetch = async ctx => {

View File

@ -29,7 +29,7 @@ exports.getApps = async ctx => {
let url = app.url || encodeURI(`${app.name}`) let url = app.url || encodeURI(`${app.name}`)
url = `/${url.replace(URL_REGEX_SLASH, "")}` url = `/${url.replace(URL_REGEX_SLASH, "")}`
body[url] = { body[url] = {
appId: app.instance._id, appId: app.appId,
name: app.name, name: app.name,
url, url,
} }