From 255512e3095497f5b6974653acecdc16f71bb8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 14 Apr 2021 10:22:45 +0200 Subject: [PATCH 01/12] adds focus action to first input field of modals --- packages/bbui/src/Modal/Modal.svelte | 24 ++++++++- packages/server/src/middleware/authorized.js | 53 -------------------- 2 files changed, 23 insertions(+), 54 deletions(-) diff --git a/packages/bbui/src/Modal/Modal.svelte b/packages/bbui/src/Modal/Modal.svelte index fe843fc1c3..7c23126fa7 100644 --- a/packages/bbui/src/Modal/Modal.svelte +++ b/packages/bbui/src/Modal/Modal.svelte @@ -31,6 +31,28 @@ } } + function focusFirstInput(node) { + const inputs = node.querySelectorAll('input') + + console.log(inputs) + + let timer; + + if (inputs) { + timer = setTimeout(() => { + inputs[0].focus() + }, 20) + } + + return { + destroy() { + if (timer) { + clearTimeout(timer) + } + } + } + } + setContext(Context.Modal, { show, hide }) @@ -38,7 +60,7 @@ {#if visible} -
+
diff --git a/packages/server/src/middleware/authorized.js b/packages/server/src/middleware/authorized.js index 554f281d8c..dcdd39ae0c 100644 --- a/packages/server/src/middleware/authorized.js +++ b/packages/server/src/middleware/authorized.js @@ -18,58 +18,5 @@ function hasResource(ctx) { } module.exports = (permType, permLevel = null) => async (ctx, next) => { - if (env.isProd() && ctx.headers["x-api-key"] && ctx.headers["x-instanceid"]) { - // api key header passed by external webhook - if (await isAPIKeyValid(ctx.headers["x-api-key"])) { - ctx.auth = { - authenticated: AuthTypes.EXTERNAL, - apiKey: ctx.headers["x-api-key"], - } - ctx.user = { - appId: ctx.headers["x-instanceid"], - } - return next() - } - - return ctx.throw(403, "API key invalid") - } - - if (!ctx.user) { - return ctx.throw(403, "No user info found") - } - - const role = ctx.user.role - const isAdmin = ADMIN_ROLES.includes(role._id) - const isAuthed = ctx.auth.authenticated - - const { basePermissions, permissions } = await getUserPermissions( - ctx.appId, - role._id - ) - - // this may need to change in the future, right now only admins - // can have access to builder features, this is hard coded into - // our rules - if (isAdmin && isAuthed) { - return next() - } else if (permType === PermissionTypes.BUILDER) { - return ctx.throw(403, "Not Authorized") - } - - if ( - hasResource(ctx) && - doesHaveResourcePermission(permissions, permLevel, ctx) - ) { - return next() - } - - if (!isAuthed) { - ctx.throw(403, "Session not authenticated") - } - - if (!doesHaveBasePermission(permType, permLevel, basePermissions)) { - ctx.throw(403, "User does not have permission") - } - return next() } From 59c88b0064d671de9b00f8e20c91b5d8a1fbdfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 14 Apr 2021 10:25:10 +0200 Subject: [PATCH 02/12] rework to use tick instead of manual timeout --- packages/bbui/src/Modal/Modal.svelte | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/bbui/src/Modal/Modal.svelte b/packages/bbui/src/Modal/Modal.svelte index 7c23126fa7..10e3db35c6 100644 --- a/packages/bbui/src/Modal/Modal.svelte +++ b/packages/bbui/src/Modal/Modal.svelte @@ -2,7 +2,7 @@ import "@spectrum-css/dialog/dist/index-vars.css" import "@spectrum-css/modal/dist/index-vars.css" import "@spectrum-css/underlay/dist/index-vars.css" - import { createEventDispatcher, setContext } from "svelte" + import { createEventDispatcher, setContext, tick } from "svelte" import { fade, fly } from "svelte/transition" import Portal from "svelte-portal" import Context from "../context" @@ -31,25 +31,11 @@ } } - function focusFirstInput(node) { + async function focusFirstInput(node) { const inputs = node.querySelectorAll('input') - - console.log(inputs) - - let timer; - if (inputs) { - timer = setTimeout(() => { - inputs[0].focus() - }, 20) - } - - return { - destroy() { - if (timer) { - clearTimeout(timer) - } - } + await tick() + inputs[0].focus() } } From df5c2e04a7a5db75b407ee698dc4bfb9ed6da81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 14 Apr 2021 10:40:44 +0200 Subject: [PATCH 03/12] adds Heading component --- packages/bbui/src/Modal/Modal.svelte | 1 - packages/bbui/src/Typography/Body.svelte | 0 packages/bbui/src/Typography/Code.svelte | 0 packages/bbui/src/Typography/Detail.svelte | 0 packages/bbui/src/Typography/Heading.svelte | 78 +++++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 packages/bbui/src/Typography/Body.svelte create mode 100644 packages/bbui/src/Typography/Code.svelte create mode 100644 packages/bbui/src/Typography/Detail.svelte create mode 100644 packages/bbui/src/Typography/Heading.svelte diff --git a/packages/bbui/src/Modal/Modal.svelte b/packages/bbui/src/Modal/Modal.svelte index 10e3db35c6..048530f337 100644 --- a/packages/bbui/src/Modal/Modal.svelte +++ b/packages/bbui/src/Modal/Modal.svelte @@ -1,5 +1,4 @@ + +{#if h1} +

+ +

+{:else if h2} +

+ +

+{:else if h3} +

+ +

+{:else if h4} +

+ +

+{:else} + SPECIFY HEADING SIZE! +{/if} From 697c3d33dfcfa8d8f148905b9e3c548cf3921860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 14 Apr 2021 10:53:23 +0200 Subject: [PATCH 04/12] adds Typogaphy components --- packages/bbui/package.json | 1 + packages/bbui/src/Typography/Body.svelte | 29 +++++++++++++++++++++ packages/bbui/src/Typography/Code.svelte | 20 ++++++++++++++ packages/bbui/src/Typography/Detail.svelte | 21 +++++++++++++++ packages/bbui/src/Typography/Heading.svelte | 2 +- packages/bbui/src/index.js | 9 +++++-- packages/bbui/yarn.lock | 5 ++++ 7 files changed, 84 insertions(+), 3 deletions(-) diff --git a/packages/bbui/package.json b/packages/bbui/package.json index da42b72fcd..d5676edf5e 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -58,6 +58,7 @@ "@spectrum-css/popover": "^3.0.1", "@spectrum-css/table": "^3.0.1", "@spectrum-css/toast": "^3.0.1", + "@spectrum-css/typography": "^3.0.1", "@spectrum-css/underlay": "^2.0.9", "@spectrum-css/vars": "^3.0.1", "dayjs": "^1.10.4", diff --git a/packages/bbui/src/Typography/Body.svelte b/packages/bbui/src/Typography/Body.svelte index e69de29bb2..12a7b8b99c 100644 --- a/packages/bbui/src/Typography/Body.svelte +++ b/packages/bbui/src/Typography/Body.svelte @@ -0,0 +1,29 @@ + + +

+ +

\ No newline at end of file diff --git a/packages/bbui/src/Typography/Code.svelte b/packages/bbui/src/Typography/Code.svelte index e69de29bb2..1aada8b687 100644 --- a/packages/bbui/src/Typography/Code.svelte +++ b/packages/bbui/src/Typography/Code.svelte @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/packages/bbui/src/Typography/Detail.svelte b/packages/bbui/src/Typography/Detail.svelte index e69de29bb2..b1eec70e47 100644 --- a/packages/bbui/src/Typography/Detail.svelte +++ b/packages/bbui/src/Typography/Detail.svelte @@ -0,0 +1,21 @@ + + +

+ +

\ No newline at end of file diff --git a/packages/bbui/src/Typography/Heading.svelte b/packages/bbui/src/Typography/Heading.svelte index cb6a1551c2..5f5dd28867 100644 --- a/packages/bbui/src/Typography/Heading.svelte +++ b/packages/bbui/src/Typography/Heading.svelte @@ -1,5 +1,5 @@ + +
\ No newline at end of file diff --git a/packages/bbui/src/Modal/ModalContent.svelte b/packages/bbui/src/Modal/ModalContent.svelte index c07bc57b43..02c3b482b7 100644 --- a/packages/bbui/src/Modal/ModalContent.svelte +++ b/packages/bbui/src/Modal/ModalContent.svelte @@ -1,8 +1,8 @@ +
+
+ Tab 1 +
+
+ Tab 2 +
+
+ Tab 3 +
+
+ Tab 4 +
+
+
\ No newline at end of file diff --git a/packages/bbui/src/index.js b/packages/bbui/src/index.js index 8ebbf019df..56c2c955a0 100644 --- a/packages/bbui/src/index.js +++ b/packages/bbui/src/index.js @@ -37,6 +37,7 @@ export { default as Multiselect } from "./Form/Multiselect.svelte" export { default as Slider } from "./Form/Slider.svelte" export { default as Context } from "./context" export { default as Table } from "./Table/Table.svelte" +export { default as Divider } from "./Divider/Divider.svelte" // Typography export { default as Body } from "./Typography/Body.svelte" diff --git a/packages/bbui/yarn.lock b/packages/bbui/yarn.lock index 39e15ff5ae..011221f823 100644 --- a/packages/bbui/yarn.lock +++ b/packages/bbui/yarn.lock @@ -480,6 +480,11 @@ resolved "https://registry.yarnpkg.com/@spectrum-css/table/-/table-3.0.1.tgz#753e0e2498082c0c36b9600828516aff3ac338cd" integrity sha512-XQ+srMTv9hK1H0nctWUtqyzitmvyb5TNR+7mjAmKRdkBRSTQQSipDhenxZp72ekzMtMoSYZVZ77kgo0Iw3Fpug== +"@spectrum-css/tabs@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/tabs/-/tabs-3.0.1.tgz#81cebae7a0db0056834c2b8fdf0df3e71aaaa812" + integrity sha512-uyWGiSuv+rKY57RVnNkYe0+8fQxgXtQl09JAmqyqUnvlX5b9sHG/R5TP7ExZ8C7BgE8hzVjPVAMH3RMEQERGUQ== + "@spectrum-css/toast@^3.0.1": version "3.0.1" resolved "https://registry.yarnpkg.com/@spectrum-css/toast/-/toast-3.0.1.tgz#36f62ea05302761e59b9d53e05f6c04423861796" diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBindingPanel.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBindingPanel.svelte index bda233f9f2..da50ae905a 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBindingPanel.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBindingPanel.svelte @@ -46,12 +46,12 @@
- Available bindings + Available bindings {#each categories as [categoryName, bindings]} - {categoryName} + {categoryName} {#each bindableProperties.filter(binding => binding.label.match(searchRgx) @@ -64,7 +64,7 @@
{/each} {/each} - Helpers + Helpers {#each helpers.filter(helper => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper}
addToText(helper)}> diff --git a/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte b/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte index 6656d23eac..99f17c13d6 100644 --- a/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/BindingPanel.svelte @@ -63,7 +63,7 @@ {#if context} - Columns + Columns
    {#each context.filter(context => @@ -77,7 +77,7 @@ {/if} {#if instance} - Components + Components
      {#each instance.filter(instance => @@ -90,7 +90,7 @@
    {/if} - Helpers + Helpers
      {#each helpers.filter(helper => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper} diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte index 85ccf000b9..f1446ae3dd 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/DataSourceSelect.svelte @@ -137,7 +137,7 @@