From 9d25f26791432339a10035a343d5d640d865637d Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Sun, 20 Feb 2022 15:28:39 +0100 Subject: [PATCH 01/48] Replace deprecated String.prototype.substr() String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated. Signed-off-by: Tobias Speicher --- packages/bbui/src/Stores/notifications.js | 2 +- packages/bbui/src/Tabs/Tabs.svelte | 2 +- .../portal/manage/users/_components/BasicOnboardingModal.svelte | 2 +- .../manage/users/_components/ForceResetPasswordModal.svelte | 2 +- packages/server/scripts/docs/toSwagger.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/bbui/src/Stores/notifications.js b/packages/bbui/src/Stores/notifications.js index 640f8218c4..74eed8628a 100644 --- a/packages/bbui/src/Stores/notifications.js +++ b/packages/bbui/src/Stores/notifications.js @@ -60,7 +60,7 @@ export const createNotificationStore = () => { } function id() { - return "_" + Math.random().toString(36).substr(2, 9) + return "_" + Math.random().toString(36).slice(2, 9) } export const notifications = createNotificationStore() diff --git a/packages/bbui/src/Tabs/Tabs.svelte b/packages/bbui/src/Tabs/Tabs.svelte index 40e02058c1..6930a6cdb5 100644 --- a/packages/bbui/src/Tabs/Tabs.svelte +++ b/packages/bbui/src/Tabs/Tabs.svelte @@ -68,7 +68,7 @@ }) function id() { - return "_" + Math.random().toString(36).substr(2, 9) + return "_" + Math.random().toString(36).slice(2, 9) } diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte index 29e2d56ed0..8f01349765 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/BasicOnboardingModal.svelte @@ -11,7 +11,7 @@ import { users } from "stores/portal" const [email, error, touched] = createValidationStore("", emailValidator) - const password = Math.random().toString(36).substr(2, 20) + const password = Math.random().toString(36).slice(2, 20) let builder = false, admin = false diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/ForceResetPasswordModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/ForceResetPasswordModal.svelte index a380f0aa65..8a7a3940bf 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/ForceResetPasswordModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/ForceResetPasswordModal.svelte @@ -7,7 +7,7 @@ export let user - const password = Math.random().toString(36).substr(2, 20) + const password = Math.random().toString(36).slice(2, 20) async function resetPassword() { try { diff --git a/packages/server/scripts/docs/toSwagger.js b/packages/server/scripts/docs/toSwagger.js index c9680143fc..1532e25fa6 100644 --- a/packages/server/scripts/docs/toSwagger.js +++ b/packages/server/scripts/docs/toSwagger.js @@ -51,7 +51,7 @@ function extractPaths(apidocJson) { // Surrounds URL parameters with curly brackets -> :email with {email} let pathKeys = [] for (let j = 1; j < matches.length; j++) { - let key = matches[j].substr(1) + let key = matches[j].slice(1) url = url.replace(matches[j], "{" + key + "}") pathKeys.push(key) } From 9fcf702a32037a65b079d0fe406b053f26f2cbb7 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 24 Feb 2022 14:41:24 +0000 Subject: [PATCH 02/48] Add status banner that reacts to cypress healthcheck failures --- packages/backend-core/src/cloud/accounts.js | 15 +++++++ packages/bbui/src/Banner/Banner.svelte | 6 +++ packages/bbui/src/Banner/BannerDisplay.svelte | 42 +++++++++++++++++++ packages/bbui/src/Stores/banner.js | 37 ++++++++++++++++ packages/bbui/src/index.js | 2 + packages/bbui/yarn.lock | 8 ++-- packages/builder/src/App.svelte | 3 +- packages/builder/src/stores/portal/admin.js | 23 ++++++++++ packages/frontend-core/src/api/other.js | 9 ++++ .../src/api/controllers/global/users.js | 15 +++++++ .../src/api/controllers/system/status.js | 9 ++++ packages/worker/src/api/index.js | 5 ++- packages/worker/src/api/routes/index.js | 2 + .../worker/src/api/routes/system/status.js | 8 ++++ 14 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 packages/bbui/src/Banner/BannerDisplay.svelte create mode 100644 packages/bbui/src/Stores/banner.js create mode 100644 packages/worker/src/api/controllers/system/status.js create mode 100644 packages/worker/src/api/routes/system/status.js diff --git a/packages/backend-core/src/cloud/accounts.js b/packages/backend-core/src/cloud/accounts.js index b2e8817ad6..5730bc67a5 100644 --- a/packages/backend-core/src/cloud/accounts.js +++ b/packages/backend-core/src/cloud/accounts.js @@ -22,3 +22,18 @@ exports.getAccount = async email => { return json[0] } + +exports.getStatus = async () => { + const response = await api.get(`/api/status`, { + headers: { + [Headers.API_KEY]: env.ACCOUNT_PORTAL_API_KEY, + }, + }) + const json = await response.json() + + if (response.status !== 200) { + throw new Error(`Error getting status`) + } + + return json +} diff --git a/packages/bbui/src/Banner/Banner.svelte b/packages/bbui/src/Banner/Banner.svelte index f28ee09d9c..63dfdd341f 100644 --- a/packages/bbui/src/Banner/Banner.svelte +++ b/packages/bbui/src/Banner/Banner.svelte @@ -57,3 +57,9 @@ {/if} + + diff --git a/packages/bbui/src/Banner/BannerDisplay.svelte b/packages/bbui/src/Banner/BannerDisplay.svelte new file mode 100644 index 0000000000..f048a3c030 --- /dev/null +++ b/packages/bbui/src/Banner/BannerDisplay.svelte @@ -0,0 +1,42 @@ + + + + + + + diff --git a/packages/bbui/src/Stores/banner.js b/packages/bbui/src/Stores/banner.js new file mode 100644 index 0000000000..81a9ee2204 --- /dev/null +++ b/packages/bbui/src/Stores/banner.js @@ -0,0 +1,37 @@ +import { writable } from "svelte/store" + +export function createBannerStore() { + const DEFAULT_CONFIG = {} + + const banner = writable(DEFAULT_CONFIG) + + const show = async ( + // eslint-disable-next-line + config = { message, type, extraButtonText, extraButtonAction, onChange } + ) => { + banner.update(store => { + return { + ...store, + ...config, + } + }) + } + + const showStatus = async () => { + const config = { + message: "Some systems are experiencing issues", + type: "negative", + extraButtonText: "View Status", + extraButtonAction: () => window.open("https://status.budibase.com/"), + } + + await show(config) + } + + return { + subscribe: banner.subscribe, + showStatus, + } +} + +export const banner = createBannerStore() diff --git a/packages/bbui/src/index.js b/packages/bbui/src/index.js index d3bc11cf9d..2b16f32b84 100644 --- a/packages/bbui/src/index.js +++ b/packages/bbui/src/index.js @@ -60,6 +60,7 @@ export { default as StatusLight } from "./StatusLight/StatusLight.svelte" export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte" export { default as InlineAlert } from "./InlineAlert/InlineAlert.svelte" export { default as Banner } from "./Banner/Banner.svelte" +export { default as BannerDisplay } from "./Banner/BannerDisplay.svelte" export { default as MarkdownEditor } from "./Markdown/MarkdownEditor.svelte" export { default as MarkdownViewer } from "./Markdown/MarkdownViewer.svelte" export { default as RichTextField } from "./Form/RichTextField.svelte" @@ -84,6 +85,7 @@ export { default as clickOutside } from "./Actions/click_outside" // Stores export { notifications, createNotificationStore } from "./Stores/notifications" +export { banner } from "./Stores/banner" // Helpers export * as Helpers from "./helpers" diff --git a/packages/bbui/yarn.lock b/packages/bbui/yarn.lock index 28c009b331..33c3c391be 100644 --- a/packages/bbui/yarn.lock +++ b/packages/bbui/yarn.lock @@ -53,10 +53,10 @@ to-gfm-code-block "^0.1.1" year "^0.2.1" -"@budibase/string-templates@^1.0.66-alpha.0": - version "1.0.72" - resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.0.72.tgz#acc154e402cce98ea30eedde9c6124183ee9b37c" - integrity sha512-w715TjgO6NUHkZNqoOEo8lAKJ/PQ4b00ATWSX5VB523SAu7y/uOiqKqV1E3fgwxq1o8L+Ff7rn9FTkiYtjkV/g== +"@budibase/string-templates@^1.0.72-alpha.0": + version "1.0.75" + resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.0.75.tgz#5b4061f1a626160ec092f32f036541376298100c" + integrity sha512-hPgr6n5cpSCGFEha5DS/P+rtRXOLc72M6y4J/scl59JvUi/ZUJkjRgJdpQPdBLu04CNKp89V59+rAqAuDjOC0g== dependencies: "@budibase/handlebars-helpers" "^0.11.7" dayjs "^1.10.4" diff --git a/packages/builder/src/App.svelte b/packages/builder/src/App.svelte index 60051ea043..97b7d70fad 100644 --- a/packages/builder/src/App.svelte +++ b/packages/builder/src/App.svelte @@ -1,7 +1,7 @@ + + ) } diff --git a/examples/nextjs-api-sales/pages/save.tsx b/examples/nextjs-api-sales/pages/save.tsx new file mode 100644 index 0000000000..5b1ab5abff --- /dev/null +++ b/examples/nextjs-api-sales/pages/save.tsx @@ -0,0 +1,81 @@ +import type { NextPage } from "next" +import { useCallback, useEffect, useState } from "react" +import styles from "../styles/save.module.css" +import Notifications from "../components/notifications" + +const Save: NextPage = () => { + const [salespeople, setSalespeople] = useState([]) + const [loaded, setLoaded] = useState(false) + + const saveSale = useCallback(async (event: any) => { + event.preventDefault() + const sale = { + sale_name: event.target.name.value, + sales_person: [event.target.soldBy.value], + } + const response = await fetch("/api/sales", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(sale), + }) + if (!response.ok) { + const error = await response.text() + Notifications.error(error, "Failed to save sale") + return + } + Notifications.success("Sale saved successfully!", "Sale saved") + }, []) + + const getSalespeople = useCallback(async () => { + const response: any = await fetch("/api/salespeople") + if (!response.ok) { + throw new Error(await response.text()) + } + const json = await response.json() + setSalespeople(json.data) + }, []) + + useEffect(() => { + getSalespeople().then(() => { + setLoaded(true) + }).catch(() => { + setSalespeople([]) + }) + }, []) + + if (!loaded) { + return null + } + return ( +
+
+

New sale

+
+
+ +
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+ ) +} + +export default Save \ No newline at end of file diff --git a/examples/nextjs-api-sales/public/bb-emblem.svg b/examples/nextjs-api-sales/public/bb-emblem.svg new file mode 100644 index 0000000000..9f4f3690d5 --- /dev/null +++ b/examples/nextjs-api-sales/public/bb-emblem.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/nextjs-api-sales/public/vercel.svg b/examples/nextjs-api-sales/public/vercel.svg deleted file mode 100644 index fbf0e25a65..0000000000 --- a/examples/nextjs-api-sales/public/vercel.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/examples/nextjs-api-sales/styles/global.sass b/examples/nextjs-api-sales/styles/global.sass index 794e1ce4d8..85e46f8591 100644 --- a/examples/nextjs-api-sales/styles/global.sass +++ b/examples/nextjs-api-sales/styles/global.sass @@ -1,12 +1,25 @@ @charset "utf-8" -// Import a Google Font @import url('https://fonts.googleapis.com/css?family=Roboto:400,700') - $family-sans-serif: "Roboto", sans-serif -//$grey-dark: color -//$grey-light: color -//$primary: color -//$link: color -@import "../node_modules/bulma/bulma.sass" \ No newline at end of file +#__next + display: flex + flex-direction: column + justify-content: flex-start + align-items: stretch + height: 100vh + +.logo + padding: 0.75rem + +@import "../node_modules/bulma/bulma.sass" +@import "../node_modules/react-notifications-component/dist/theme.css" + +// applied after bulma styles are enabled +html + overflow-y: auto + +.navbar + background-color: #D3D3D3 + color: white \ No newline at end of file diff --git a/examples/nextjs-api-sales/styles/home.module.css b/examples/nextjs-api-sales/styles/home.module.css index 4906fe57f1..eb71c1072e 100644 --- a/examples/nextjs-api-sales/styles/home.module.css +++ b/examples/nextjs-api-sales/styles/home.module.css @@ -1,116 +1,30 @@ .container { - padding: 0 2rem; -} - -.main { - min-height: 100vh; - padding: 4rem 0; - flex: 1; + width: 100vw; display: flex; flex-direction: column; - justify-content: center; + padding: 5rem 2rem 0; align-items: center; + flex: 1 1 auto; } -.footer { +.buttons { display: flex; - flex: 1; - padding: 2rem 0; - border-top: 1px solid #eaeaea; - justify-content: center; - align-items: center; + flex-direction: row; + justify-content: space-between; } -.footer a { - display: flex; - justify-content: center; - align-items: center; - flex-grow: 1; -} - -.title a { - color: #0070f3; - text-decoration: none; -} - -.title a:hover, -.title a:focus, -.title a:active { - text-decoration: underline; -} - -.title { - margin: 0; - line-height: 1.15; - font-size: 4rem; -} - -.title, -.description { - text-align: center; -} - -.description { - margin: 4rem 0; - line-height: 1.5; - font-size: 1.5rem; -} - -.code { - background: #fafafa; - border-radius: 5px; - padding: 0.75rem; - font-size: 1.1rem; - font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, - Bitstream Vera Sans Mono, Courier New, monospace; -} - -.grid { - display: flex; - align-items: center; - justify-content: center; - flex-wrap: wrap; - max-width: 800px; -} - -.card { - margin: 1rem; - padding: 1.5rem; - text-align: left; - color: inherit; - text-decoration: none; - border: 1px solid #eaeaea; +.tableSection { + padding: 2rem; + background: #D3D3D3; + width: 800px; border-radius: 10px; - transition: color 0.15s ease, border-color 0.15s ease; - max-width: 300px; } -.card:hover, -.card:focus, -.card:active { - color: #0070f3; - border-color: #0070f3; -} - -.card h2 { - margin: 0 0 1rem 0; - font-size: 1.5rem; -} - -.card p { - margin: 0; - font-size: 1.25rem; - line-height: 1.5; -} - -.logo { - height: 1em; - margin-left: 0.5rem; -} - -@media (max-width: 600px) { -.grid { +.table table { width: 100%; - flex-direction: column; -} } + +.tableSection h1 { + text-align: center; + color: black; +} \ No newline at end of file diff --git a/examples/nextjs-api-sales/styles/save.module.css b/examples/nextjs-api-sales/styles/save.module.css new file mode 100644 index 0000000000..177d317afd --- /dev/null +++ b/examples/nextjs-api-sales/styles/save.module.css @@ -0,0 +1,20 @@ +.container { + width: 100vw; + display: flex; + flex-direction: column; + padding: 5rem 2rem 0; + align-items: center; + flex: 1 1 auto; +} + +.formSection { + padding: 2rem; + background: #D3D3D3; + width: 400px; + border-radius: 10px; +} + +.formSection h1 { + text-align: center; + color: black; +} \ No newline at end of file diff --git a/examples/nextjs-api-sales/yarn.lock b/examples/nextjs-api-sales/yarn.lock index b1a66a4ac5..3f32417ba8 100644 --- a/examples/nextjs-api-sales/yarn.lock +++ b/examples/nextjs-api-sales/yarn.lock @@ -2384,6 +2384,11 @@ react-is@^16.13.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== +react-notifications-component@^3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/react-notifications-component/-/react-notifications-component-3.4.1.tgz#3670aa17210a4e63ba3b4f553853bd99ab6a0150" + integrity sha512-vS/RLdz+VlXZz0dbK+LCcdhgUdUPi1BvSo7mVp58AQDpixI9emGwI0uISXhiTSjqFn/cPibPlJOJQ8kcvgmUrQ== + react@17.0.2: version "17.0.2" resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037" From 666fc883fb2f5f888e94a6dcbb84205d6c41cae2 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 9 Mar 2022 15:19:18 +0000 Subject: [PATCH 08/48] Adjusting colours, some quick fixes after changing to sales person for relationship name. --- examples/nextjs-api-sales/components/layout.tsx | 7 +++---- examples/nextjs-api-sales/pages/_app.tsx | 4 ++++ examples/nextjs-api-sales/pages/index.tsx | 2 +- examples/nextjs-api-sales/styles/global.sass | 3 ++- examples/nextjs-api-sales/styles/home.module.css | 2 +- examples/nextjs-api-sales/styles/save.module.css | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/nextjs-api-sales/components/layout.tsx b/examples/nextjs-api-sales/components/layout.tsx index 63049af025..48052028d7 100644 --- a/examples/nextjs-api-sales/components/layout.tsx +++ b/examples/nextjs-api-sales/components/layout.tsx @@ -8,21 +8,20 @@ function layout(props: any) {