From 55a68890af40972aae221b09a5933787b89019ea Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 15 Mar 2022 11:18:34 +0000 Subject: [PATCH 001/179] Add nord theme --- packages/frontend-core/src/themes/nord.css | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 packages/frontend-core/src/themes/nord.css diff --git a/packages/frontend-core/src/themes/nord.css b/packages/frontend-core/src/themes/nord.css new file mode 100644 index 0000000000..113adfb853 --- /dev/null +++ b/packages/frontend-core/src/themes/nord.css @@ -0,0 +1,46 @@ +.spectrum--nord { + --spectrum-global-color-red-400: #bf616a; + --spectrum-global-color-red-500: #c26971; + --spectrum-global-color-red-600: #c57179; + --spectrum-global-color-red-700: #c97980; + --spectrum-global-color-static-red-400: #bf616a; + --spectrum-global-color-static-red-500: #c26971; + --spectrum-global-color-static-red-600: #c57179; + --spectrum-global-color-static-red-700: #c97980; + + --spectrum-global-color-green-400: #719453; + --spectrum-global-color-green-500: #789d58; + --spectrum-global-color-green-600: #7fa55e; + --spectrum-global-color-green-700: #86aa67; + --spectrum-global-color-static-green-400: #719453; + --spectrum-global-color-static-green-500: #789d58; + --spectrum-global-color-static-green-600: #7fa55e; + --spectrum-global-color-static-green-700: #86aa67; + + --spectrum-global-color-blue-400: #5680b4; + --spectrum-global-color-blue-500: #5e86b8; + --spectrum-global-color-blue-600: #668dbb; + --spectrum-global-color-blue-700: #6f93bf; + --spectrum-global-color-static-blue-200: #7799c4; + --spectrum-global-color-static-blue-300: #6f93bf; + --spectrum-global-color-static-blue-400: #668dbb; + --spectrum-global-color-static-blue-500: #5e86b8; + --spectrum-global-color-static-blue-600: #5680b4; + --spectrum-global-color-static-blue-700: #4e79af; + --spectrum-global-color-static-blue-800: #4a73a6; + + --spectrum-global-color-gray-50: #2e3440; + --spectrum-global-color-gray-75: #353b4a; + --spectrum-global-color-gray-100: #3b4252; + --spectrum-global-color-gray-200: #4a5367; + --spectrum-global-color-gray-300: #4c566a; + --spectrum-global-color-gray-400: #5a657d; + --spectrum-global-color-gray-500: #677590; + --spectrum-global-color-gray-600: #79869f; + --spectrum-global-color-gray-700: #a9b1c1; + --spectrum-global-color-gray-800: #bac1cd; + --spectrum-global-color-gray-900: #eceff4; + + --spectrum-alias-highlight-hover: rgba(169, 177, 193, 0.06); + --spectrum-alias-highlight-active: rgba(169, 177, 193, 0.1); +} From 3acea6b14832ac5b83ed4cd246e30e1e70c6579e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 15 Mar 2022 11:20:06 +0000 Subject: [PATCH 002/179] Add nord theme --- packages/builder/src/builderStore/store/theme.js | 4 ++++ .../components/design/AppPreview/AppThemeSelect.svelte | 4 ++++ packages/builder/src/main.js | 1 + packages/client/src/components/ClientApp.svelte | 2 +- packages/client/src/components/app/index.js | 8 +++++--- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/builderStore/store/theme.js b/packages/builder/src/builderStore/store/theme.js index d4d7460ed2..77b84ca78c 100644 --- a/packages/builder/src/builderStore/store/theme.js +++ b/packages/builder/src/builderStore/store/theme.js @@ -21,6 +21,10 @@ export const getThemeStore = () => { `spectrum--${option}`, option === state.theme ) + + // Ensure darkest is always added as this is the base class for custom + // themes + themeElement.classList.add("spectrum--darkest") }) }) diff --git a/packages/builder/src/components/design/AppPreview/AppThemeSelect.svelte b/packages/builder/src/components/design/AppPreview/AppThemeSelect.svelte index cdab47db66..59a8671bfd 100644 --- a/packages/builder/src/components/design/AppPreview/AppThemeSelect.svelte +++ b/packages/builder/src/components/design/AppPreview/AppThemeSelect.svelte @@ -20,6 +20,10 @@ label: "Darkest", value: "spectrum--darkest", }, + { + label: "Nord", + value: "spectrum--nord", + }, ] const onChangeTheme = async theme => { diff --git a/packages/builder/src/main.js b/packages/builder/src/main.js index bc5ec4f009..8ab2c16ba2 100644 --- a/packages/builder/src/main.js +++ b/packages/builder/src/main.js @@ -5,6 +5,7 @@ import "@spectrum-css/vars/dist/spectrum-darkest.css" import "@spectrum-css/vars/dist/spectrum-dark.css" import "@spectrum-css/vars/dist/spectrum-light.css" import "@spectrum-css/vars/dist/spectrum-lightest.css" +import "@budibase/frontend-core/src/themes/nord.css" import "@spectrum-css/page/dist/index-vars.css" import "./global.css" import { suppressWarnings } from "./helpers/warnings" diff --git a/packages/client/src/components/ClientApp.svelte b/packages/client/src/components/ClientApp.svelte index e8ed7e9538..8af065f972 100644 --- a/packages/client/src/components/ClientApp.svelte +++ b/packages/client/src/components/ClientApp.svelte @@ -77,7 +77,7 @@ id="spectrum-root" lang="en" dir="ltr" - class="spectrum spectrum--medium {$themeStore.theme}" + class="spectrum spectrum--medium spectrum--darkest {$themeStore.theme}" > {#if permissionError}
diff --git a/packages/client/src/components/app/index.js b/packages/client/src/components/app/index.js index 5af62201e5..71acee5eff 100644 --- a/packages/client/src/components/app/index.js +++ b/packages/client/src/components/app/index.js @@ -1,10 +1,11 @@ import "@spectrum-css/vars/dist/spectrum-global.css" import "@spectrum-css/vars/dist/spectrum-medium.css" import "@spectrum-css/vars/dist/spectrum-large.css" -import "@spectrum-css/vars/dist/spectrum-lightest.css" -import "@spectrum-css/vars/dist/spectrum-light.css" -import "@spectrum-css/vars/dist/spectrum-dark.css" import "@spectrum-css/vars/dist/spectrum-darkest.css" +import "@spectrum-css/vars/dist/spectrum-dark.css" +import "@spectrum-css/vars/dist/spectrum-light.css" +import "@spectrum-css/vars/dist/spectrum-lightest.css" +import "@budibase/frontend-core/src/themes/nord.css" import "@spectrum-css/page/dist/index-vars.css" // Non user-facing components @@ -34,6 +35,7 @@ export { default as markdownviewer } from "./MarkdownViewer.svelte" export * from "./charts" export * from "./forms" export * from "./table" + export * from "./blocks" export * from "./dynamic-filter" From b3227fe51e28f60a0ebc3a7b2820b447e866b2eb Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 14 Jun 2022 14:56:09 +0100 Subject: [PATCH 003/179] add IconPicker component --- .../bbui/src/IconPicker/IconPicker.svelte | 176 ++++++++++++++++++ packages/bbui/src/index.js | 1 + 2 files changed, 177 insertions(+) create mode 100644 packages/bbui/src/IconPicker/IconPicker.svelte diff --git a/packages/bbui/src/IconPicker/IconPicker.svelte b/packages/bbui/src/IconPicker/IconPicker.svelte new file mode 100644 index 0000000000..995394adca --- /dev/null +++ b/packages/bbui/src/IconPicker/IconPicker.svelte @@ -0,0 +1,176 @@ + + +
+
(open = true)}> +
+ +
+
+ {#if open} +
(open = false)} + transition:fly={{ y: -20, duration: 200 }} + class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open" + class:spectrum-Popover--align-right={alignRight} + > + {#each iconList as icon} +
+
{icon.label}
+
+ {#each icon.icons as icon} +
{ + value = icon + }} + > + +
+ {/each} +
+
+ {/each} +
+ {/if} +
+ + diff --git a/packages/bbui/src/index.js b/packages/bbui/src/index.js index 2b16f32b84..97dc88030e 100644 --- a/packages/bbui/src/index.js +++ b/packages/bbui/src/index.js @@ -58,6 +58,7 @@ export { default as Pagination } from "./Pagination/Pagination.svelte" export { default as Badge } from "./Badge/Badge.svelte" export { default as StatusLight } from "./StatusLight/StatusLight.svelte" export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte" +export { default as IconPicker } from "./IconPicker/IconPicker.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" From d529d7456fdebaee18e7006f22fcc1bdf78c0b1d Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 14 Jun 2022 14:57:34 +0100 Subject: [PATCH 004/179] add user groups UI --- .../bbui/src/IconPicker/IconPicker.svelte | 7 +- .../src/pages/builder/portal/_layout.svelte | 5 + .../builder/portal/manage/_layout.svelte | 6 +- .../portal/manage/groups/[groupId].svelte | 211 ++++++++++++++++++ .../groups/_components/UserGroupsRow.svelte | 92 ++++++++ .../manage/groups/_components/UserRow.svelte | 55 +++++ .../portal/manage/groups/_layout.svelte | 3 + .../builder/portal/manage/groups/index.svelte | 155 +++++++++++++ 8 files changed, 530 insertions(+), 4 deletions(-) create mode 100644 packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte create mode 100644 packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte create mode 100644 packages/builder/src/pages/builder/portal/manage/groups/_components/UserRow.svelte create mode 100644 packages/builder/src/pages/builder/portal/manage/groups/_layout.svelte create mode 100644 packages/builder/src/pages/builder/portal/manage/groups/index.svelte diff --git a/packages/bbui/src/IconPicker/IconPicker.svelte b/packages/bbui/src/IconPicker/IconPicker.svelte index 995394adca..954145b42d 100644 --- a/packages/bbui/src/IconPicker/IconPicker.svelte +++ b/packages/bbui/src/IconPicker/IconPicker.svelte @@ -1,5 +1,5 @@
diff --git a/packages/builder/src/pages/builder/portal/_layout.svelte b/packages/builder/src/pages/builder/portal/_layout.svelte index ae0362af72..5da8b34700 100644 --- a/packages/builder/src/pages/builder/portal/_layout.svelte +++ b/packages/builder/src/pages/builder/portal/_layout.svelte @@ -52,6 +52,11 @@ href: "/builder/portal/manage/users", heading: "Manage", }, + { + title: "User Groups", + href: "/builder/portal/manage/groups", + }, + { title: "Auth", href: "/builder/portal/manage/auth" }, { title: "Email", href: "/builder/portal/manage/email" }, { diff --git a/packages/builder/src/pages/builder/portal/manage/_layout.svelte b/packages/builder/src/pages/builder/portal/manage/_layout.svelte index b4ffa4910c..47d9aaf59e 100644 --- a/packages/builder/src/pages/builder/portal/manage/_layout.svelte +++ b/packages/builder/src/pages/builder/portal/manage/_layout.svelte @@ -9,10 +9,14 @@ $redirect("../") } } + + $: wide = + $page.path.includes("email/:template") || + ($page.path.includes("groups") && !$page.path.includes(":groupId")) {#if $auth.isAdmin} - + {/if} diff --git a/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte b/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte new file mode 100644 index 0000000000..d33f144680 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte @@ -0,0 +1,211 @@ + + + +
+ $goto("../groups")} size="S" icon="ArrowLeft"> + Back + +
+
+
+
+
+ +
+
+
+ {group.name} +
+
+
+ +
+ +
+ +
+
+ {filteredUsers.length} User{filteredUsers.length === 1 + ? "" + : "s"} +
+
+ Add all +
+
+ +
+ {#each filteredUsers as user} +
+
+ {user.email} +
+ + {#if selectedUsers.includes(user._id)} +
+ +
+ {/if} +
+ {/each} +
+
+
+
+ +
+ {#if groupUsers.length} + {#each groupUsers as user} +
+ +
+ {/each} + {:else} +
+
+ +
+ You have no users in this team +
+
+
+ {/if} +
+
+ + diff --git a/packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte b/packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte new file mode 100644 index 0000000000..c4f38f080b --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte @@ -0,0 +1,92 @@ + + +
+
+
+
+ +
+
+
{name}
+
+
+
+ +
+ {parseInt(userCount)} app{parseInt(userCount) === 1 ? "" : "s"} +
+
+
+ + +
+ {parseInt(appCount)} app{parseInt(appCount) === 1 ? "" : "s"} +
+
+
+
+
+ +
+
+
+ + diff --git a/packages/builder/src/pages/builder/portal/manage/groups/_components/UserRow.svelte b/packages/builder/src/pages/builder/portal/manage/groups/_components/UserRow.svelte new file mode 100644 index 0000000000..873b45e151 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/groups/_components/UserRow.svelte @@ -0,0 +1,55 @@ + + +
+
+
+ +
+
+
+
+
+ {user.email} +
+ {user.access} +
+
+
+
+
+ + diff --git a/packages/builder/src/pages/builder/portal/manage/groups/_layout.svelte b/packages/builder/src/pages/builder/portal/manage/groups/_layout.svelte new file mode 100644 index 0000000000..a13211a9bb --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/groups/_layout.svelte @@ -0,0 +1,3 @@ +
+ +
diff --git a/packages/builder/src/pages/builder/portal/manage/groups/index.svelte b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte new file mode 100644 index 0000000000..63fcd105f3 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte @@ -0,0 +1,155 @@ + + + + +
+ User groups + {#if !proPlan} + +
+
+ Pro plan +
+
+
+ {/if} +
+ Easily assign and manage your users access with User Groups +
+
+ + {#if !proPlan} + + {/if} +
+ +
+ {#each userGroupData as group} +
+ +
+ {/each} +
+
+ + + + + + + + + From b7cc71a62385ad8609fe8af8b49f3b34f93a8bdd Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 15 Jun 2022 16:51:30 +0100 Subject: [PATCH 005/179] saving and fetching groups from couch --- .vscode/settings.json | 5 +- packages/backend-core/src/db/constants.js | 1 + packages/backend-core/src/db/utils.js | 23 ++++++++ .../groups/_components/UserGroupsRow.svelte | 2 +- .../builder/portal/manage/groups/index.svelte | 54 ++++++++++------- packages/builder/src/stores/portal/groups.js | 24 ++++++++ packages/builder/src/stores/portal/index.js | 1 + packages/frontend-core/src/api/groups.js | 18 ++++++ packages/frontend-core/src/api/index.js | 2 + .../src/api/controllers/global/groups.js | 58 +++++++++++++++++++ .../worker/src/api/routes/global/groups.js | 27 +++++++++ packages/worker/src/api/routes/index.js | 3 +- 12 files changed, 194 insertions(+), 24 deletions(-) create mode 100644 packages/builder/src/stores/portal/groups.js create mode 100644 packages/frontend-core/src/api/groups.js create mode 100644 packages/worker/src/api/controllers/global/groups.js create mode 100644 packages/worker/src/api/routes/global/groups.js diff --git a/.vscode/settings.json b/.vscode/settings.json index d471924fe0..f93d3f0886 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,8 @@ "editor.codeActionsOnSave": { "source.fixAll": true }, - "editor.defaultFormatter": "svelte.svelte-vscode" + "editor.defaultFormatter": "svelte.svelte-vscode", + "[javascript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + } } diff --git a/packages/backend-core/src/db/constants.js b/packages/backend-core/src/db/constants.js index 271d4f412d..0f3daa918c 100644 --- a/packages/backend-core/src/db/constants.js +++ b/packages/backend-core/src/db/constants.js @@ -15,6 +15,7 @@ exports.DocumentTypes = { ROLE: "role", MIGRATIONS: "migrations", DEV_INFO: "devinfo", + GROUP: "gr" } exports.StaticDatabases = { diff --git a/packages/backend-core/src/db/utils.js b/packages/backend-core/src/db/utils.js index d6eb0aa89e..212ada6e9a 100644 --- a/packages/backend-core/src/db/utils.js +++ b/packages/backend-core/src/db/utils.js @@ -148,6 +148,29 @@ exports.getTemplateParams = (ownerId, templateId, otherProps = {}) => { } } +/** + * Generates a new user group ID + * @returns {string} The new user group ID which info can be stored under. + */ +exports.generateUserGroupID = () => { + return `${DocumentTypes.GROUP}${SEPARATOR}${newid()}` +} + +/** + * Gets parameters for retrieving groups. + */ +exports.getUserGroupsParams = (groupId, otherProps = {}) => { + if (!groupId) { + groupId = "" + } + return { + ...otherProps, + startkey: `${DocumentTypes.GROUP}${SEPARATOR}${groupId}`, + endkey: `${DocumentTypes.GROUP}${SEPARATOR}${groupId}${UNICODE_MAX}`, + } +} + + /** * Generates a new role ID. * @returns {string} The new role ID which the role doc can be stored under. diff --git a/packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte b/packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte index c4f38f080b..a8fef775bf 100644 --- a/packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte +++ b/packages/builder/src/pages/builder/portal/manage/groups/_components/UserGroupsRow.svelte @@ -20,7 +20,7 @@
- {parseInt(userCount)} app{parseInt(userCount) === 1 ? "" : "s"} + {parseInt(userCount)} user{parseInt(userCount) === 1 ? "" : "s"}
diff --git a/packages/builder/src/pages/builder/portal/manage/groups/index.svelte b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte index 63fcd105f3..560cf273e5 100644 --- a/packages/builder/src/pages/builder/portal/manage/groups/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/groups/index.svelte @@ -12,30 +12,37 @@ Tags, IconPicker, } from "@budibase/bbui" + import { API } from "api" + import { groups } from "stores/portal" + import { onMount } from "svelte" + import UserGroupsRow from "./_components/UserGroupsRow.svelte" + let modal let selectedColor let selectedIcon + let groupName let proPlan = true - let userGroupData = [ - { - _id: "gr_123456", - color: "green", - icon: "Anchor", - name: "Core Team", - userCount: 5, - appCount: 2, - }, - { - _id: "gr_45678", - color: "red", - icon: "Beaker", - name: "QA Team", - userCount: 3, - appCount: 7, - }, - ] + async function saveConfig() { + try { + API.saveGroup({ + color: selectedColor, + icon: selectedIcon, + name: groupName, + }) + } catch (error) { + notifications.error(`Failed to save group`) + } + } + + onMount(async () => { + try { + await groups.init() + } catch (error) { + notifications.error("Error getting User groups") + } + }) @@ -72,7 +79,7 @@
- {#each userGroupData as group} + {#each $groups as group}
@@ -81,8 +88,13 @@ - - + +