linting and tidy

This commit is contained in:
Peter Clement 2022-07-07 08:55:32 +01:00
parent f2139df344
commit 2399dbceb9
22 changed files with 87 additions and 138 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,12 +25,13 @@
import { fetchData } from "helpers"
import { users, auth, groups, apps } from "stores/portal"
import { roles } from "stores/backend"
import { Constants } from "@budibase/frontend-core"
import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte"
import { RoleUtils } from "@budibase/frontend-core"
import UserGroupPicker from "components/settings/UserGroupPicker.svelte"
export let userId
let deleteUserModal
let resetPasswordModal
let popoverAnchor
@ -38,7 +39,7 @@
let popover
let selectedGroups = []
let allAppList = []
let toggleDisabled = false
$: allAppList = $apps
.filter(x => {
if ($userFetch.data?.roles) {
@ -161,18 +162,6 @@
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() {}
onMount(async () => {

View File

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

View File

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

View File

@ -18,8 +18,9 @@
let csvString = undefined
/*
function parseCsv() {}
*/
async function handleFile(evt) {
const fileArray = Array.from(evt.target.files)
if (fileArray.some(file => file.size >= FILE_SIZE_LIMIT)) {
@ -72,27 +73,10 @@
</ModalContent>
<style>
.inner {
display: flex;
}
:global(.spectrum-Picker) {
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 {
text-align: center;
display: flex;

View File

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

View File

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

View File

@ -40,6 +40,7 @@
return y.appId === app.appId
})
})
function extractAppId(id) {
const split = id?.split("_") || []
return split.length ? split[split.length - 1] : null
@ -71,7 +72,11 @@
})
await pageInfo.reset()
}
/*
async function updateRole(user) {
console.log(user)
}
*/
async function fetchUsers(page, search) {
if ($pageInfo.loading) {
return
@ -103,43 +108,61 @@
<div class="access-tab">
<Layout>
<div>
<Heading>Access</Heading>
<div class="subtitle">
<Body size="S">
Assign users to your app and define their access here</Body
>
<Button on:click={assignmentModal.show} icon="User" cta
>Assign users</Button
>
{#if appGroups.length || appUsers.length}
<div>
<Heading>Access</Heading>
<div class="subtitle">
<Body size="S">
Assign users to your app and define their access here</Body
>
<Button on:click={assignmentModal.show} icon="User" cta
>Assign users</Button
>
</div>
</div>
</div>
<List title="User Groups">
{#each appGroups as group}
<ListItem
title={group.name}
icon={group.icon}
iconBackground={group.color}
>
<RoleSelect autoWidth quiet value={group.role} />
</ListItem>
{/each}
</List>
<List title="Users">
{#each appUsers as user}
<ListItem title={user.email} avatar>
<RoleSelect
autoWidth
quiet
value={user.roles[
Object.keys(user.roles).find(
x => extractAppId(x) === extractAppId(app.appId)
)
]}
/>
</ListItem>
{/each}
</List>
<List title="User Groups">
{#each appGroups as group}
<ListItem
title={group.name}
icon={group.icon}
iconBackground={group.color}
>
<RoleSelect autoWidth quiet value={group.role} />
</ListItem>
{/each}
</List>
<List title="Users">
{#each appUsers as user}
<ListItem title={user.email} avatar>
<RoleSelect
autoWidth
quiet
value={user.roles[
Object.keys(user.roles).find(
x => extractAppId(x) === extractAppId(app.appId)
)
]}
/>
</ListItem>
{/each}
</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>
</div>
@ -153,6 +176,17 @@
margin: 0 auto;
padding: 40px;
}
.padding {
margin-top: var(--spacing-m);
}
.opacity {
opacity: 0.8;
}
.align {
text-align: center;
}
.subtitle {
display: flex;
flex-direction: row;

View File

@ -1,6 +1,6 @@
<script>
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 { RoleUtils } from "@budibase/frontend-core"

View File

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

View File

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

View File

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

View File

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