linting and tidy

This commit is contained in:
Peter Clement 2022-07-07 08:55:32 +01:00
parent 8a66a38470
commit 0e3b1fc46f
22 changed files with 87 additions and 138 deletions

View File

@ -5,7 +5,6 @@
import { fly } from "svelte/transition" import { fly } from "svelte/transition"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import clickOutside from "../../Actions/click_outside" import clickOutside from "../../Actions/click_outside"
import StatusLight from "../../StatusLight/StatusLight.svelte"
export let inputValue export let inputValue
export let dropdownValue export let dropdownValue
@ -19,7 +18,6 @@
export let options = [] export let options = []
export let getOptionLabel = option => extractProperty(option, "label") export let getOptionLabel = option => extractProperty(option, "label")
export let getOptionValue = option => extractProperty(option, "value") export let getOptionValue = option => extractProperty(option, "value")
export let getOptionColour = option => extractProperty(option, "colour")
export let isOptionSelected = () => false export let isOptionSelected = () => false

View File

@ -5,7 +5,6 @@
import { fly } from "svelte/transition" import { fly } from "svelte/transition"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import clickOutside from "../../Actions/click_outside" import clickOutside from "../../Actions/click_outside"
import Search from "./Search.svelte"
import Icon from "../../Icon/Icon.svelte" import Icon from "../../Icon/Icon.svelte"
import StatusLight from "../../StatusLight/StatusLight.svelte" import StatusLight from "../../StatusLight/StatusLight.svelte"
import Detail from "../../Typography/Detail.svelte" import Detail from "../../Typography/Detail.svelte"
@ -61,14 +60,6 @@
dispatch("change", newValue) dispatch("change", newValue)
} }
const onClickPrimary = () => {
dispatch("click")
if (readonly) {
return
}
primaryOpen = true
}
const onClickSecondary = () => { const onClickSecondary = () => {
dispatch("click") dispatch("click")
if (readonly) { if (readonly) {
@ -83,18 +74,10 @@
} }
const onPickSecondary = newValue => { const onPickSecondary = newValue => {
console.log(newValue)
dispatch("picksecondary", newValue) dispatch("picksecondary", newValue)
secondaryOpen = false secondaryOpen = false
} }
const onFocus = () => {
if (readonly) {
return
}
focus = true
}
const onBlur = event => { const onBlur = event => {
if (readonly) { if (readonly) {
return return
@ -354,11 +337,6 @@
border-bottom-left-radius: 0px; border-bottom-left-radius: 0px;
} }
.override-borders-left {
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-right: 0px;
}
.spectrum-Popover { .spectrum-Popover {
max-height: 240px; max-height: 240px;
z-index: 999; z-index: 999;

View File

@ -8,7 +8,6 @@
export let inputType = "text" export let inputType = "text"
export let label = null export let label = null
export let labelPosition = "above" export let labelPosition = "above"
export let primaryPlaceholder = "test"
export let secondaryPlaceholder = null export let secondaryPlaceholder = null
export let autocomplete export let autocomplete
export let placeholder = null export let placeholder = null
@ -72,15 +71,12 @@
} }
const onPickPrimary = e => { const onPickPrimary = e => {
console.log("hello")
primaryLabel = e.detail.label primaryLabel = e.detail.label
primaryValue = e.detail.value primaryValue = e.detail.value
dispatch("pickprimary", e.detail.value) dispatch("pickprimary", e.detail.value)
} }
const onPickSecondary = e => { const onPickSecondary = e => {
console.log("hello222")
secondaryValue = e.detail secondaryValue = e.detail
dispatch("picksecondary", e.detail) dispatch("picksecondary", e.detail)
} }

View File

@ -211,7 +211,6 @@
bindings={getAuthBindings()} bindings={getAuthBindings()}
on:change={e => { on:change={e => {
form.bearer.token = e.detail form.bearer.token = e.detail
console.log(e.detail)
onFieldChange() onFieldChange()
}} }}
on:blur={() => { on:blur={() => {

View File

@ -41,7 +41,6 @@
await store.actions.screens.save(duplicateScreen) await store.actions.screens.save(duplicateScreen)
} catch (error) { } catch (error) {
notifications.error("Error duplicating screen") notifications.error("Error duplicating screen")
console.log(error)
} }
} }

View File

@ -1,6 +1,5 @@
<script> <script>
import { ActionButton, Icon, Search, Divider, Detail } from "@budibase/bbui" import { ActionButton, Icon, Search, Divider, Detail } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
export let searchTerm = "" export let searchTerm = ""
export let selected export let selected
@ -9,11 +8,6 @@
export let select export let select
export let title export let title
export let key export let key
const dispatch = createEventDispatcher()
function onChange(e) {
dispatch("change", e.detail)
}
</script> </script>
<div style="padding: var(--spacing-m)"> <div style="padding: var(--spacing-m)">

View File

@ -126,11 +126,10 @@
$redirect("../") $redirect("../")
} else { } else {
try { try {
await organisation.init()
await roles.fetch() await roles.fetch()
await organisation.init()
} catch (error) { } catch (error) {
console.log(error) console.log(error)
notifications.error("Error getting org config") notifications.error("Error getting org config")
} }
loaded = true loaded = true

View File

@ -219,7 +219,6 @@
try { try {
await organisation.init() await organisation.init()
} catch (error) { } catch (error) {
console.log("hello1")
notifications.error("Error getting org config") notifications.error("Error getting org config")
} }

View File

@ -56,7 +56,6 @@
$users.data?.filter(x => !group?.users.map(y => y._id).includes(x._id)) || $users.data?.filter(x => !group?.users.map(y => y._id).includes(x._id)) ||
[] []
$: console.log(filtered)
async function removeUser(id) { async function removeUser(id) {
let newUsers = group.users.filter(user => user._id !== id) let newUsers = group.users.filter(user => user._id !== id)
group.users = newUsers group.users = newUsers
@ -82,10 +81,6 @@
} }
} }
function onChange(e) {
console.log(e)
}
onMount(async () => { onMount(async () => {
try { try {
await groups.actions.init() await groups.actions.init()
@ -118,7 +113,6 @@
</div> </div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}> <Popover align="right" bind:this={popover} anchor={popoverAnchor}>
<UserGroupPicker <UserGroupPicker
on:change={onChange}
key={"email"} key={"email"}
title={"User"} title={"User"}
bind:searchTerm bind:searchTerm

View File

@ -34,7 +34,6 @@
} }
async function saveGroup(group) { async function saveGroup(group) {
console.log(group)
try { try {
await groups.actions.save(group) await groups.actions.save(group)
} catch (error) { } catch (error) {

View File

@ -25,12 +25,13 @@
import { fetchData } from "helpers" import { fetchData } from "helpers"
import { users, auth, groups, apps } from "stores/portal" import { users, auth, groups, apps } from "stores/portal"
import { roles } from "stores/backend"
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte" import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
import UserGroupPicker from "components/settings/UserGroupPicker.svelte" import UserGroupPicker from "components/settings/UserGroupPicker.svelte"
export let userId export let userId
let deleteUserModal let deleteUserModal
let resetPasswordModal let resetPasswordModal
let popoverAnchor let popoverAnchor
@ -38,7 +39,7 @@
let popover let popover
let selectedGroups = [] let selectedGroups = []
let allAppList = [] let allAppList = []
let toggleDisabled = false
$: allAppList = $apps $: allAppList = $apps
.filter(x => { .filter(x => {
if ($userFetch.data?.roles) { if ($userFetch.data?.roles) {
@ -161,18 +162,6 @@
notifications.error("Error updating user") notifications.error("Error updating user")
} }
} }
async function toggleBuilderAccess({ detail }) {
return toggleFlag("builder", detail)
}
async function toggleAdminAccess({ detail }) {
return toggleFlag("admin", detail)
}
async function openUpdateRolesModal({ detail }) {
selectedApp = detail
editRolesModal.show()
}
function addAll() {} function addAll() {}
onMount(async () => { onMount(async () => {

View File

@ -5,15 +5,9 @@
ModalContent, ModalContent,
Multiselect, Multiselect,
InputDropdown, InputDropdown,
Body,
Input,
notifications,
Select,
Toggle,
Layout, Layout,
} from "@budibase/bbui" } from "@budibase/bbui"
import { createValidationStore, emailValidator } from "helpers/validation" import { groups } from "stores/portal"
import { users, groups } from "stores/portal"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
@ -22,8 +16,6 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
let disabled let disabled
let selected = "Email onboarding"
$: userData = [{ email: "", role: "", groups: [], error: null }] $: userData = [{ email: "", role: "", groups: [], error: null }]
function addNewInput() { function addNewInput() {

View File

@ -1,7 +1,6 @@
<script> <script>
import { Icon, Body } from "@budibase/bbui" import { Icon, Body } from "@budibase/bbui"
export let value export let value
console.log(value)
</script> </script>
<div class="align"> <div class="align">

View File

@ -18,8 +18,9 @@
let csvString = undefined let csvString = undefined
/*
function parseCsv() {} function parseCsv() {}
*/
async function handleFile(evt) { async function handleFile(evt) {
const fileArray = Array.from(evt.target.files) const fileArray = Array.from(evt.target.files)
if (fileArray.some(file => file.size >= FILE_SIZE_LIMIT)) { if (fileArray.some(file => file.size >= FILE_SIZE_LIMIT)) {
@ -72,27 +73,10 @@
</ModalContent> </ModalContent>
<style> <style>
.inner {
display: flex;
}
:global(.spectrum-Picker) { :global(.spectrum-Picker) {
border-top-left-radius: 0px; border-top-left-radius: 0px;
} }
.container {
width: 100%;
height: var(--spectrum-alias-item-height-l);
background: var(--spectrum-global-color-gray-200);
display: flex;
justify-content: center;
align-items: center;
}
.error {
color: var(--red);
}
.dropzone { .dropzone {
text-align: center; text-align: center;
display: flex; display: flex;

View File

@ -2,6 +2,7 @@
import { Avatar } from "@budibase/bbui" import { Avatar } from "@budibase/bbui"
export let value export let value
console.log(value)
</script> </script>
<div class="align"> <div class="align">

View File

@ -63,7 +63,7 @@
}, },
] ]
let email //let email
let enrichedUsers = [] let enrichedUsers = []
let createUserModal, let createUserModal,
inviteConfirmationModal, inviteConfirmationModal,
@ -80,15 +80,11 @@
$: { $: {
enrichedUsers = $users.data?.map(user => { enrichedUsers = $users.data?.map(user => {
let userGroups = [] let userGroups = []
let userApps = []
$groups.forEach(group => { $groups.forEach(group => {
console.log(group)
if (group.users) { if (group.users) {
group.users?.forEach(y => { group.users?.forEach(y => {
if (y._id === user._id) { if (y._id === user._id) {
console.log("hello")
userGroups.push(group) userGroups.push(group)
userApps = group.apps
} }
}) })
} }
@ -121,7 +117,7 @@
notifications.error("Error inviting user") notifications.error("Error inviting user")
} }
} }
/*
async function createUser() { async function createUser() {
try { try {
await users.create({ await users.create({
@ -136,12 +132,12 @@
notifications.error("Error creating user") notifications.error("Error creating user")
} }
} }
*/
async function chooseCreationType(onboardingType) { async function chooseCreationType(onboardingType) {
if (onboardingType === "emailOnboarding") { if (onboardingType === "emailOnboarding") {
createUserFlow() createUserFlow()
} else { } else {
let newUser = await users.create({ await users.create({
email: "auser5@test.com", email: "auser5@test.com",
password: Math.random().toString(36).slice(2, 20), password: Math.random().toString(36).slice(2, 20),
builder: true, builder: true,
@ -157,7 +153,6 @@
try { try {
await groups.actions.init() await groups.actions.init()
} catch (error) { } catch (error) {
console.log(error)
notifications.error("Error fetching User Group data") notifications.error("Error fetching User Group data")
} }
}) })

View File

@ -40,6 +40,7 @@
return y.appId === app.appId return y.appId === app.appId
}) })
}) })
function extractAppId(id) { function extractAppId(id) {
const split = id?.split("_") || [] const split = id?.split("_") || []
return split.length ? split[split.length - 1] : null return split.length ? split[split.length - 1] : null
@ -71,7 +72,11 @@
}) })
await pageInfo.reset() await pageInfo.reset()
} }
/*
async function updateRole(user) {
console.log(user)
}
*/
async function fetchUsers(page, search) { async function fetchUsers(page, search) {
if ($pageInfo.loading) { if ($pageInfo.loading) {
return return
@ -103,6 +108,7 @@
<div class="access-tab"> <div class="access-tab">
<Layout> <Layout>
{#if appGroups.length || appUsers.length}
<div> <div>
<Heading>Access</Heading> <Heading>Access</Heading>
<div class="subtitle"> <div class="subtitle">
@ -140,6 +146,23 @@
</ListItem> </ListItem>
{/each} {/each}
</List> </List>
{:else}
<div class="align">
<Layout gap="S">
<Heading>No users assigned</Heading>
<div class="opacity">
<Body size="S"
>Assign users to your app and set their access here</Body
>
</div>
<div class="padding">
<Button on:click={() => assignmentModal.show()} cta icon="UserArrow"
>Assign Users</Button
>
</div>
</Layout>
</div>
{/if}
</Layout> </Layout>
</div> </div>
@ -153,6 +176,17 @@
margin: 0 auto; margin: 0 auto;
padding: 40px; padding: 40px;
} }
.padding {
margin-top: var(--spacing-m);
}
.opacity {
opacity: 0.8;
}
.align {
text-align: center;
}
.subtitle { .subtitle {
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@ -1,6 +1,6 @@
<script> <script>
import { ModalContent, PickerDropdown, ActionButton } from "@budibase/bbui" import { ModalContent, PickerDropdown, ActionButton } from "@budibase/bbui"
import { users, groups, apps } from "stores/portal" import { groups } from "stores/portal"
import { roles } from "stores/backend" import { roles } from "stores/backend"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"

View File

@ -7,7 +7,6 @@ export function createRolesStore() {
const actions = { const actions = {
fetch: async () => { fetch: async () => {
const roles = await API.getRoles() const roles = await API.getRoles()
console.log(roles)
set(roles) set(roles)
}, },
delete: async role => { delete: async role => {

View File

@ -19,7 +19,6 @@ export function createGroupsStore() {
}, },
save: async group => { save: async group => {
console.log(group)
const response = await API.saveGroup(group) const response = await API.saveGroup(group)
group._id = response._id group._id = response._id
group._rev = response._rev group._rev = response._rev

View File

@ -165,7 +165,7 @@ export const inviteMultiple = async (ctx: any) => {
if (!userInfo) { if (!userInfo) {
userInfo = {} userInfo = {}
} }
userInfo.tenantId = getTenantId() userInfo.tenantId = tenancy.getTenantId()
const opts: any = { const opts: any = {
subject: "{{ company }} platform invitation", subject: "{{ company }} platform invitation",
info: userInfo, info: userInfo,

View File

@ -65,6 +65,8 @@ function buildConfigSaveValidation() {
_rev: Joi.string().optional(), _rev: Joi.string().optional(),
workspace: Joi.string().optional(), workspace: Joi.string().optional(),
type: Joi.string().valid(...Object.values(Configs)).required(), type: Joi.string().valid(...Object.values(Configs)).required(),
createdAt: Joi.string().optional(),
updatedAt: Joi.string().optional(),
config: Joi.alternatives() config: Joi.alternatives()
.conditional("type", { .conditional("type", {
switch: [ switch: [