new ui functionality working from S3 bucket
This commit is contained in:
parent
dabbab4c83
commit
d15dfb83fc
|
@ -7,6 +7,7 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
|
- new-design-ui
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
@ -58,3 +59,18 @@ jobs:
|
||||||
with:
|
with:
|
||||||
install: false
|
install: false
|
||||||
command: yarn test:e2e:ci
|
command: yarn test:e2e:ci
|
||||||
|
|
||||||
|
- name: Configure AWS Credentials
|
||||||
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
|
with:
|
||||||
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
aws-region: eu-west-1
|
||||||
|
|
||||||
|
- name: Upload to S3
|
||||||
|
if: github.ref == 'refs/heads/new-design-ui'
|
||||||
|
run: |
|
||||||
|
tar -czvf new_ui.tar.gz packages/server/assets packages/server/index.html
|
||||||
|
aws s3 cp new_ui.tar.gz s3://prod-budi-app-assets/beta:design_ui/
|
||||||
|
aws s3 cp packages/client/dist/budibase-client.js s3://prod-budi-app-assets/beta:design_ui/budibase-client.js
|
||||||
|
|
||||||
|
|
|
@ -288,6 +288,16 @@ exports.uploadDirectory = async (bucketName, localPath, bucketPath) => {
|
||||||
await Promise.all(uploads)
|
await Promise.all(uploads)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.downloadTarballDirect = async (url, path) => {
|
||||||
|
path = sanitizeKey(path)
|
||||||
|
const response = await fetch(url)
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`unexpected response ${response.statusText}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
await streamPipeline(response.body, zlib.Unzip(), tar.extract(path))
|
||||||
|
}
|
||||||
|
|
||||||
exports.downloadTarball = async (url, bucketName, path) => {
|
exports.downloadTarball = async (url, bucketName, path) => {
|
||||||
bucketName = sanitizeBucket(bucketName)
|
bucketName = sanitizeBucket(bucketName)
|
||||||
path = sanitizeKey(path)
|
path = sanitizeKey(path)
|
||||||
|
|
|
@ -91,7 +91,11 @@
|
||||||
notifications.success(`Datasource ${name} tables updated successfully.`)
|
notifications.success(`Datasource ${name} tables updated successfully.`)
|
||||||
await tables.fetch()
|
await tables.fetch()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error updating datasource schema")
|
notifications.error(
|
||||||
|
`Error updating datasource schema ${
|
||||||
|
error?.message ? `: ${error.message}` : ""
|
||||||
|
}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import { store, automationStore } from "builderStore"
|
import { store, automationStore } from "builderStore"
|
||||||
import { roles, flags } from "stores/backend"
|
import { roles, flags } from "stores/backend"
|
||||||
import {
|
import {
|
||||||
Button,
|
|
||||||
Icon,
|
Icon,
|
||||||
ActionGroup,
|
ActionGroup,
|
||||||
Tabs,
|
Tabs,
|
||||||
|
@ -92,9 +91,8 @@
|
||||||
<div class="loading" />
|
<div class="loading" />
|
||||||
{:then _}
|
{:then _}
|
||||||
<div class="root">
|
<div class="root">
|
||||||
<Banner>
|
<Banner extraButtonText="Try New UI (Beta)" extraButtonAction={newDesignUi}>
|
||||||
Wanna try the new UI?
|
Try the <b>all new</b> budibase design interface.
|
||||||
<Button on:click={newDesignUi}>Try the all new Budibase Design UI</Button>
|
|
||||||
</Banner>
|
</Banner>
|
||||||
<div class="top-nav">
|
<div class="top-nav">
|
||||||
<div class="topleftnav">
|
<div class="topleftnav">
|
||||||
|
|
|
@ -22,9 +22,13 @@ export const buildFlagEndpoints = API => ({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Allows us to experimentally toggle a beta UI feature through a cookie.
|
||||||
|
* @param value the feature to toggle
|
||||||
|
*/
|
||||||
toggleUiFeature: async ({ value }) => {
|
toggleUiFeature: async ({ value }) => {
|
||||||
return await API.post({
|
return await API.post({
|
||||||
url: `/api/ui/feature/${value}`,
|
url: `/api/beta/${value}`,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,6 +20,11 @@ const { setCookie, clearCookie } = require("@budibase/backend-core/utils")
|
||||||
const AWS = require("aws-sdk")
|
const AWS = require("aws-sdk")
|
||||||
const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1"
|
const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1"
|
||||||
|
|
||||||
|
const fs = require("fs")
|
||||||
|
const {
|
||||||
|
downloadTarballDirect,
|
||||||
|
} = require("../../../utilities/fileSystem/utilities")
|
||||||
|
|
||||||
async function prepareUpload({ s3Key, bucket, metadata, file }) {
|
async function prepareUpload({ s3Key, bucket, metadata, file }) {
|
||||||
const response = await upload({
|
const response = await upload({
|
||||||
bucket,
|
bucket,
|
||||||
|
@ -50,6 +55,16 @@ exports.toggleBetaUiFeature = async function (ctx) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let builderPath = resolve(TOP_LEVEL_PATH, "new_design_ui")
|
||||||
|
|
||||||
|
// // download it from S3
|
||||||
|
if (!fs.existsSync(builderPath)) {
|
||||||
|
fs.mkdirSync(builderPath)
|
||||||
|
}
|
||||||
|
await downloadTarballDirect(
|
||||||
|
"https://cdn.budi.live/beta:design_ui/new_ui.tar.gz",
|
||||||
|
builderPath
|
||||||
|
)
|
||||||
setCookie(ctx, {}, cookieName)
|
setCookie(ctx, {}, cookieName)
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
|
@ -58,17 +73,11 @@ exports.toggleBetaUiFeature = async function (ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.serveBuilder = async function (ctx) {
|
exports.serveBuilder = async function (ctx) {
|
||||||
const newUiCookie = ctx.cookies.get("beta:design_ui")
|
// Temporary: New Design UI
|
||||||
// When user uses the builder, they should be able to switch to the new UI through a button in a banner
|
const designUiCookie = ctx.cookies.get("beta:design_ui")
|
||||||
// When in the new UI, they should be able to switch back with a button in a banner
|
// TODO: get this from the tmp Dir that we downloaded from MinIO
|
||||||
// Maybe use the flags abstraction
|
const uiPath = designUiCookie ? "new_design_ui" : "builder"
|
||||||
// COS
|
|
||||||
// - Users who click the button get the latest version of the new UI
|
|
||||||
//
|
|
||||||
let uiPath = "builder"
|
|
||||||
if (newUiCookie) {
|
|
||||||
uiPath = "newbuilder"
|
|
||||||
}
|
|
||||||
let builderPath = resolve(TOP_LEVEL_PATH, uiPath)
|
let builderPath = resolve(TOP_LEVEL_PATH, uiPath)
|
||||||
await send(ctx, ctx.file, { root: builderPath })
|
await send(ctx, ctx.file, { root: builderPath })
|
||||||
}
|
}
|
||||||
|
@ -104,7 +113,7 @@ exports.serveApp = async function (ctx) {
|
||||||
title: appInfo.name,
|
title: appInfo.name,
|
||||||
production: env.isProd(),
|
production: env.isProd(),
|
||||||
appId,
|
appId,
|
||||||
clientLibPath: clientLibraryPath(appId, appInfo.version),
|
clientLibPath: clientLibraryPath(appId, appInfo.version, ctx),
|
||||||
})
|
})
|
||||||
|
|
||||||
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
|
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
|
||||||
|
@ -117,13 +126,6 @@ exports.serveApp = async function (ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.serveClientLibrary = async function (ctx) {
|
exports.serveClientLibrary = async function (ctx) {
|
||||||
const newUiCookie = ctx.cookies.get("beta:design_ui")
|
|
||||||
if (newUiCookie) {
|
|
||||||
return send(ctx, "budibase-client.js", {
|
|
||||||
root: join(TOP_LEVEL_PATH, "newbuilder"),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return send(ctx, "budibase-client.js", {
|
return send(ctx, "budibase-client.js", {
|
||||||
root: join(NODE_MODULES_PATH, "@budibase", "client", "dist"),
|
root: join(NODE_MODULES_PATH, "@budibase", "client", "dist"),
|
||||||
})
|
})
|
||||||
|
|
|
@ -38,7 +38,7 @@ router
|
||||||
// TODO: for now this builder endpoint is not authorized/secured, will need to be
|
// TODO: for now this builder endpoint is not authorized/secured, will need to be
|
||||||
.get("/builder/:file*", controller.serveBuilder)
|
.get("/builder/:file*", controller.serveBuilder)
|
||||||
.post("/api/attachments/process", authorized(BUILDER), controller.uploadFile)
|
.post("/api/attachments/process", authorized(BUILDER), controller.uploadFile)
|
||||||
.post("/api/ui/feature/:feature", controller.toggleBetaUiFeature)
|
.post("/api/beta/:feature", controller.toggleBetaUiFeature)
|
||||||
.post(
|
.post(
|
||||||
"/api/attachments/:tableId/upload",
|
"/api/attachments/:tableId/upload",
|
||||||
paramResource("tableId"),
|
paramResource("tableId"),
|
||||||
|
|
|
@ -9,6 +9,7 @@ const {
|
||||||
deleteFolder,
|
deleteFolder,
|
||||||
uploadDirectory,
|
uploadDirectory,
|
||||||
downloadTarball,
|
downloadTarball,
|
||||||
|
downloadTarballDirect,
|
||||||
} = require("@budibase/backend-core/objectStore")
|
} = require("@budibase/backend-core/objectStore")
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
|
@ -29,4 +30,5 @@ exports.retrieveToTmp = retrieveToTmp
|
||||||
exports.deleteFolder = deleteFolder
|
exports.deleteFolder = deleteFolder
|
||||||
exports.uploadDirectory = uploadDirectory
|
exports.uploadDirectory = uploadDirectory
|
||||||
exports.downloadTarball = downloadTarball
|
exports.downloadTarball = downloadTarball
|
||||||
|
exports.downloadTarballDirect = downloadTarballDirect
|
||||||
exports.deleteFiles = deleteFiles
|
exports.deleteFiles = deleteFiles
|
||||||
|
|
|
@ -54,11 +54,17 @@ exports.objectStoreUrl = () => {
|
||||||
* @return {string} The URL to be inserted into appPackage response or server rendered
|
* @return {string} The URL to be inserted into appPackage response or server rendered
|
||||||
* app index file.
|
* app index file.
|
||||||
*/
|
*/
|
||||||
exports.clientLibraryPath = (appId, version) => {
|
exports.clientLibraryPath = (appId, version, ctx) => {
|
||||||
if (env.isProd()) {
|
if (env.isProd()) {
|
||||||
|
// TODO: remove - for beta testing UI
|
||||||
|
if (ctx && ctx.cookies.get("beta:design_ui")) {
|
||||||
|
return "https://cdn.budi.live/beta:design_ui/budibase-client.js"
|
||||||
|
}
|
||||||
|
|
||||||
let url = `${exports.objectStoreUrl()}/${sanitizeKey(
|
let url = `${exports.objectStoreUrl()}/${sanitizeKey(
|
||||||
appId
|
appId
|
||||||
)}/budibase-client.js`
|
)}/budibase-client.js`
|
||||||
|
|
||||||
// append app version to bust the cache
|
// append app version to bust the cache
|
||||||
if (version) {
|
if (version) {
|
||||||
url += `?v=${version}`
|
url += `?v=${version}`
|
||||||
|
|
Loading…
Reference in New Issue