Date: Tue, 9 Nov 2021 18:30:51 +0100
Subject: [PATCH 05/10] adding check for delete app
---
packages/builder/src/components/common/ConfirmDialog.svelte | 2 ++
packages/builder/src/pages/builder/portal/apps/index.svelte | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/packages/builder/src/components/common/ConfirmDialog.svelte b/packages/builder/src/components/common/ConfirmDialog.svelte
index cf2bf989b9..ece20fe102 100644
--- a/packages/builder/src/components/common/ConfirmDialog.svelte
+++ b/packages/builder/src/components/common/ConfirmDialog.svelte
@@ -8,6 +8,7 @@
export let onOk = undefined
export let onCancel = undefined
export let warning = true
+ export let disabled
let modal
@@ -26,6 +27,7 @@
confirmText={okText}
{cancelText}
{warning}
+ {disabled}
>
{body}
diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte
index 2c8cbb1097..d465f7b978 100644
--- a/packages/builder/src/pages/builder/portal/apps/index.svelte
+++ b/packages/builder/src/pages/builder/portal/apps/index.svelte
@@ -6,6 +6,7 @@
ActionButton,
ActionGroup,
ButtonGroup,
+ Input,
Select,
Modal,
Page,
@@ -36,6 +37,7 @@
let loaded = false
let searchTerm = ""
let cloud = $admin.cloud
+ let appName = ""
$: enrichedApps = enrichApps($apps, $auth.user, sortBy)
$: filteredApps = enrichedApps.filter(app =>
@@ -296,8 +298,12 @@
title="Confirm deletion"
okText="Delete app"
onOk={confirmDeleteApp}
+ disabled={appName !== selectedApp?.name}
>
Are you sure you want to delete the app {selectedApp?.name}?
+
+ Please enter the app name below to confirm.
+
Date: Tue, 9 Nov 2021 18:35:19 +0100
Subject: [PATCH 06/10] updating delete app cypress command
---
packages/builder/cypress/support/commands.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js
index 82e3c45a1f..ff1d13d6cb 100644
--- a/packages/builder/cypress/support/commands.js
+++ b/packages/builder/cypress/support/commands.js
@@ -43,7 +43,7 @@ Cypress.Commands.add("createApp", name => {
})
})
-Cypress.Commands.add("deleteApp", () => {
+Cypress.Commands.add("deleteApp", appName => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(1000)
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
@@ -52,6 +52,7 @@ Cypress.Commands.add("deleteApp", () => {
console.log(val)
if (val.length > 0) {
cy.get(".title > :nth-child(3) > .spectrum-Icon").click()
+ cy.get("input").type(appName)
cy.contains("Delete").click()
cy.get(".spectrum-Button--warning").click()
}
@@ -60,7 +61,7 @@ Cypress.Commands.add("deleteApp", () => {
Cypress.Commands.add("createTestApp", () => {
const appName = "Cypress Tests"
- cy.deleteApp()
+ cy.deleteApp(appName)
cy.createApp(appName, "This app is used for Cypress testing.")
})
From 7cf916a00d73b9a3a5bb32f2e876f2ccb6a5e952 Mon Sep 17 00:00:00 2001
From: Martin McKeaveney
Date: Wed, 10 Nov 2021 12:12:33 +0100
Subject: [PATCH 07/10] code review, simplify iframeTemplate
---
.../design/AppPreview/CurrentItemPreview.svelte | 16 +++++++---------
.../design/AppPreview/iframeTemplate.js | 8 +-------
packages/builder/src/stores/portal/auth.js | 9 ++++-----
3 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte
index a97cf22442..4001db44b6 100644
--- a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte
+++ b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte
@@ -95,12 +95,12 @@
const handlers = {
[MessageTypes.READY]: () => {
// Initialise the app when mounted
- // Display preview immediately if the intelligent loading feature
- // is not supported
if ($store.clientFeatures.messagePassing) {
if (!loading) return
}
+ // Display preview immediately if the intelligent loading feature
+ // is not supported
if (!$store.clientFeatures.intelligentLoading) {
loading = false
}
@@ -119,9 +119,8 @@
}
onMount(() => {
- if ($store.clientFeatures.messagePassing) {
- window.addEventListener("message", receiveMessage)
- } else {
+ window.addEventListener("message", receiveMessage)
+ if (!$store.clientFeatures.messagePassing) {
// Legacy - remove in later versions of BB
iframe.contentWindow.addEventListener("ready", () => {
receiveMessage({ data: { type: MessageTypes.READY }})
@@ -132,15 +131,14 @@
// Add listener for events sent by client library in preview
iframe.contentWindow.addEventListener("bb-event", handleBudibaseEvent)
iframe.contentWindow.addEventListener("keydown", handleKeydownEvent)
- }
+ }
})
// Remove all iframe event listeners on component destroy
onDestroy(() => {
if (iframe.contentWindow) {
- if ($store.clientFeatures.messagePassing) {
- window.removeEventListener("message", receiveMessage)
- } else {
+ window.removeEventListener("message", receiveMessage)
+ if (!$store.clientFeatures.messagePassing) {
// Legacy - remove in later versions of BB
iframe.contentWindow.removeEventListener("bb-event", handleBudibaseEvent)
iframe.contentWindow.removeEventListener("keydown", handleKeydownEvent)
diff --git a/packages/builder/src/components/design/AppPreview/iframeTemplate.js b/packages/builder/src/components/design/AppPreview/iframeTemplate.js
index 8bc14f42b9..372eac24f7 100644
--- a/packages/builder/src/components/design/AppPreview/iframeTemplate.js
+++ b/packages/builder/src/components/design/AppPreview/iframeTemplate.js
@@ -65,7 +65,6 @@ export default `
theme,
customTheme,
previewDevice,
- messagePassing
} = parsed
// Set some flags so the app knows we're in the builder
@@ -90,11 +89,7 @@ export default `
throw "The client library couldn't be loaded"
}
} catch (error) {
- if (messagePassing) {
- window.parent.postMessage({ type: "error", error })
- } else {
- window.dispatchEvent(new CustomEvent("error", { detail: error }))
- }
+ window.parent.postMessage({ type: "error", error })
}
}
@@ -104,7 +99,6 @@ export default `
})
window.parent.postMessage({ type: "ready" })
- window.dispatchEvent(new Event("ready"))
diff --git a/packages/builder/src/stores/portal/auth.js b/packages/builder/src/stores/portal/auth.js
index df4e3f8462..2f558c88b2 100644
--- a/packages/builder/src/stores/portal/auth.js
+++ b/packages/builder/src/stores/portal/auth.js
@@ -81,13 +81,12 @@ export function createAuthStore() {
}
async function setInitInfo(info) {
- const response = await api.post(`/api/global/auth/init`, info)
- const json = await response.json()
+ await api.post(`/api/global/auth/init`, info)
auth.update(store => {
- store.initInfo = json
+ store.initInfo = info
return store
})
- return json
+ return info
}
async function getInitInfo() {
@@ -102,7 +101,7 @@ export function createAuthStore() {
return {
subscribe: store.subscribe,
- setOrganisation: setOrganisation,
+ setOrganisation,
getInitInfo,
setInitInfo,
checkQueryString: async () => {
From f5406cecf2a68b06ef715f15a1b6335b2e79351e Mon Sep 17 00:00:00 2001
From: Martin McKeaveney
Date: Wed, 10 Nov 2021 13:04:59 +0100
Subject: [PATCH 08/10] fix cypress tests
---
packages/builder/cypress/support/commands.js | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js
index ff1d13d6cb..5682dcb2e2 100644
--- a/packages/builder/cypress/support/commands.js
+++ b/packages/builder/cypress/support/commands.js
@@ -43,16 +43,14 @@ Cypress.Commands.add("createApp", name => {
})
})
-Cypress.Commands.add("deleteApp", appName => {
+Cypress.Commands.add("deleteApp", () => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(1000)
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
.its("body")
.then(val => {
- console.log(val)
if (val.length > 0) {
cy.get(".title > :nth-child(3) > .spectrum-Icon").click()
- cy.get("input").type(appName)
cy.contains("Delete").click()
cy.get(".spectrum-Button--warning").click()
}
From 8f7b57837e74a301bc097759c95163457ccd3e94 Mon Sep 17 00:00:00 2001
From: Martin McKeaveney
Date: Wed, 10 Nov 2021 14:08:34 +0100
Subject: [PATCH 09/10] adding cypress tag to input
---
packages/builder/cypress/support/commands.js | 4 ++--
packages/builder/src/pages/builder/portal/apps/index.svelte | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js
index 5682dcb2e2..af60272d49 100644
--- a/packages/builder/cypress/support/commands.js
+++ b/packages/builder/cypress/support/commands.js
@@ -43,7 +43,7 @@ Cypress.Commands.add("createApp", name => {
})
})
-Cypress.Commands.add("deleteApp", () => {
+Cypress.Commands.add("deleteApp", appName => {
cy.visit(`localhost:${Cypress.env("PORT")}/builder`)
cy.wait(1000)
cy.request(`localhost:${Cypress.env("PORT")}/api/applications?status=all`)
@@ -51,7 +51,7 @@ Cypress.Commands.add("deleteApp", () => {
.then(val => {
if (val.length > 0) {
cy.get(".title > :nth-child(3) > .spectrum-Icon").click()
- cy.contains("Delete").click()
+ cy.get(`[data-cy="delete-app-confirmation"]`).type(appName)
cy.get(".spectrum-Button--warning").click()
}
})
diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte
index d465f7b978..53ad661f72 100644
--- a/packages/builder/src/pages/builder/portal/apps/index.svelte
+++ b/packages/builder/src/pages/builder/portal/apps/index.svelte
@@ -303,7 +303,7 @@
Are you sure you want to delete the app {selectedApp?.name}?
Please enter the app name below to confirm.
-
+
Date: Wed, 10 Nov 2021 14:57:46 +0100
Subject: [PATCH 10/10] fix renaming an app
---
.../cypress/integration/renameAnApplication.spec.js | 3 ++-
packages/builder/cypress/support/commands.js | 7 +++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/packages/builder/cypress/integration/renameAnApplication.spec.js b/packages/builder/cypress/integration/renameAnApplication.spec.js
index b9da64989b..95a152c017 100644
--- a/packages/builder/cypress/integration/renameAnApplication.spec.js
+++ b/packages/builder/cypress/integration/renameAnApplication.spec.js
@@ -11,7 +11,8 @@ it("should rename an unpublished application", () => {
renameApp(appRename)
cy.searchForApplication(appRename)
cy.get(".appGrid").find(".wrapper").should("have.length", 1)
- })
+ cy.deleteApp(appRename)
+})
xit("Should rename a published application", () => {
// It is not possible to rename a published application
diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js
index af60272d49..ca758e46d0 100644
--- a/packages/builder/cypress/support/commands.js
+++ b/packages/builder/cypress/support/commands.js
@@ -51,8 +51,11 @@ Cypress.Commands.add("deleteApp", appName => {
.then(val => {
if (val.length > 0) {
cy.get(".title > :nth-child(3) > .spectrum-Icon").click()
- cy.get(`[data-cy="delete-app-confirmation"]`).type(appName)
- cy.get(".spectrum-Button--warning").click()
+ cy.contains("Delete").click()
+ cy.get(".spectrum-Modal").within(() => {
+ cy.get("input").type(appName)
+ cy.get(".spectrum-Button--warning").click()
+ })
}
})
})