Removing isAdmin and isBuilder flags from the auth store, using SDK only.
This commit is contained in:
parent
dce38908c9
commit
a8ff2da768
|
@ -107,7 +107,7 @@
|
|||
>
|
||||
Update password
|
||||
</MenuItem>
|
||||
{#if $auth.isBuilder}
|
||||
{#if sdk.users.hasBuilderPermissions($auth.user)}
|
||||
<MenuItem
|
||||
icon="UserDeveloper"
|
||||
on:click={() => $goto("../portal")}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import { goto } from "@roxi/routify"
|
||||
import { auth, admin, licensing } from "stores/portal"
|
||||
import { isEnabled, TENANT_FEATURE_FLAGS } from "helpers/featureFlags"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
</script>
|
||||
|
||||
{#if isEnabled(TENANT_FEATURE_FLAGS.LICENSING) && !$licensing.isEnterprisePlan}
|
||||
|
@ -17,7 +18,7 @@
|
|||
>
|
||||
Upgrade
|
||||
</Button>
|
||||
{:else if !$admin.cloud && $auth.isAdmin}
|
||||
{:else if !$admin.cloud && sdk.users.isAdmin($auth.user)}
|
||||
<Button
|
||||
cta
|
||||
size="S"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
let activeTab = "Apps"
|
||||
|
||||
$: $url(), updateActiveTab($menu)
|
||||
$: fullscreen = $apps.length == null
|
||||
$: isOnboarding = !$apps.length && sdk.users.isGlobalBuilder($auth.user)
|
||||
|
||||
const updateActiveTab = menu => {
|
||||
for (let entry of menu) {
|
||||
|
@ -50,7 +50,7 @@
|
|||
</script>
|
||||
|
||||
{#if $auth.user && loaded}
|
||||
{#if fullscreen}
|
||||
{#if isOnboarding}
|
||||
<slot />
|
||||
{:else}
|
||||
<HelpMenu />
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
import DeleteLicenseKeyModal from "../../../../components/portal/licensing/DeleteLicenseKeyModal.svelte"
|
||||
import { API } from "api"
|
||||
import { onMount } from "svelte"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
$: license = $auth.user.license
|
||||
$: upgradeUrl = `${$admin.accountPortalUrl}/portal/upgrade`
|
||||
|
@ -176,7 +177,7 @@
|
|||
})
|
||||
</script>
|
||||
|
||||
{#if $auth.isAdmin}
|
||||
{#if sdk.users.isAdmin($auth.user)}
|
||||
<DeleteLicenseKeyModal
|
||||
bind:this={deleteLicenseKeyModal}
|
||||
onConfirm={deleteLicenseKey}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
import { Constants } from "@budibase/frontend-core"
|
||||
import { DashCard, Usage } from "components/usage"
|
||||
import { PlanModel } from "constants"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
let staticUsage = []
|
||||
let monthlyUsage = []
|
||||
|
@ -51,7 +52,8 @@
|
|||
$: accountPortalAccess = $auth?.user?.accountPortalAccess
|
||||
$: quotaReset = quotaUsage?.quotaReset
|
||||
$: canManagePlan =
|
||||
($admin.cloud && accountPortalAccess) || (!$admin.cloud && $auth.isAdmin)
|
||||
($admin.cloud && accountPortalAccess) ||
|
||||
(!$admin.cloud && sdk.users.isAdmin($auth.user))
|
||||
|
||||
$: showButton = !usesInvoicing && accountPortalAccess
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
import { API } from "api"
|
||||
import { onMount } from "svelte"
|
||||
import { goto } from "@roxi/routify"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
const imageExtensions = [
|
||||
".png",
|
||||
|
@ -206,7 +207,7 @@
|
|||
})
|
||||
</script>
|
||||
|
||||
{#if $auth.isAdmin && mounted}
|
||||
{#if sdk.users.isAdmin($auth.user) && mounted}
|
||||
<Layout noPadding>
|
||||
<Layout gap="XS" noPadding>
|
||||
<div class="title">
|
||||
|
@ -400,7 +401,7 @@
|
|||
on:click={() => {
|
||||
if (isCloud && $auth?.user?.accountPortalAccess) {
|
||||
window.open($admin.accountPortalUrl + "/portal/upgrade", "_blank")
|
||||
} else if ($auth.isAdmin) {
|
||||
} else if (sdk.users.isAdmin($auth.user)) {
|
||||
$goto("/builder/portal/account/upgrade")
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
import { redirect } from "@roxi/routify"
|
||||
import { API } from "api"
|
||||
import { onMount } from "svelte"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
let diagnosticInfo = ""
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
})
|
||||
</script>
|
||||
|
||||
{#if $auth.isAdmin && diagnosticInfo}
|
||||
{#if sdk.users.isAdmin($auth.user) && diagnosticInfo}
|
||||
<Layout noPadding>
|
||||
<Layout gap="XS">
|
||||
<Heading size="M">Diagnostics</Heading>
|
||||
|
|
|
@ -13,10 +13,11 @@
|
|||
import { auth, organisation, admin } from "stores/portal"
|
||||
import { writable } from "svelte/store"
|
||||
import { redirect } from "@roxi/routify"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
// Only admins allowed here
|
||||
$: {
|
||||
if (!$auth.isAdmin) {
|
||||
if (!sdk.users.isAdmin($auth.user)) {
|
||||
$redirect("../../portal")
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +51,7 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
{#if $auth.isAdmin}
|
||||
{#if sdk.users.isAdmin($auth.user)}
|
||||
<Layout noPadding>
|
||||
<Layout gap="XS" noPadding>
|
||||
<Heading size="M">Organisation</Heading>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
import { API } from "api"
|
||||
import { auth, admin } from "stores/portal"
|
||||
import { redirect } from "@roxi/routify"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
let version
|
||||
let loaded = false
|
||||
|
@ -25,7 +26,7 @@
|
|||
|
||||
// Only admins allowed here
|
||||
$: {
|
||||
if (!$auth.isAdmin || $admin.cloud) {
|
||||
if (!sdk.users.isAdmin($auth.user) || $admin.cloud) {
|
||||
$redirect("../../portal")
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +90,7 @@
|
|||
})
|
||||
</script>
|
||||
|
||||
{#if $auth.isAdmin}
|
||||
{#if sdk.users.isAdmin($auth.user)}
|
||||
<Layout noPadding>
|
||||
<Layout gap="XS" noPadding>
|
||||
<Heading size="M">Version</Heading>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
|
||||
import GroupIcon from "./_components/GroupIcon.svelte"
|
||||
import GroupUsers from "./_components/GroupUsers.svelte"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
export let groupId
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
let editModal, deleteModal
|
||||
|
||||
$: scimEnabled = $features.isScimEnabled
|
||||
$: readonly = !$auth.isAdmin || scimEnabled
|
||||
$: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled
|
||||
$: group = $groups.find(x => x._id === groupId)
|
||||
$: groupApps = $apps
|
||||
.filter(app =>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import UserGroupPicker from "components/settings/UserGroupPicker.svelte"
|
||||
import { createPaginationStore } from "helpers/pagination"
|
||||
import { auth, groups, users } from "stores/portal"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
export let groupId
|
||||
export let onUsersUpdated
|
||||
|
@ -13,7 +14,7 @@
|
|||
let prevSearch = undefined
|
||||
let pageInfo = createPaginationStore()
|
||||
|
||||
$: readonly = !$auth.isAdmin
|
||||
$: readonly = !sdk.users.isAdmin($auth.user)
|
||||
$: page = $pageInfo.page
|
||||
$: searchUsers(page, searchTerm)
|
||||
$: group = $groups.find(x => x._id === groupId)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import { setContext } from "svelte"
|
||||
import ScimBanner from "../../_components/SCIMBanner.svelte"
|
||||
import RemoveUserTableRenderer from "../_components/RemoveUserTableRenderer.svelte"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
export let groupId
|
||||
|
||||
|
@ -49,7 +50,7 @@
|
|||
]
|
||||
|
||||
$: scimEnabled = $features.isScimEnabled
|
||||
$: readonly = !$auth.isAdmin || scimEnabled
|
||||
$: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled
|
||||
|
||||
const removeUser = async id => {
|
||||
await groups.actions.removeUser(groupId, id)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { ActionButton } from "@budibase/bbui"
|
||||
import { getContext } from "svelte"
|
||||
import { auth } from "stores/portal"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
export let value
|
||||
|
||||
|
@ -13,6 +14,10 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<ActionButton disabled={!$auth.isAdmin} size="S" on:click={onClick}>
|
||||
<ActionButton
|
||||
disabled={!sdk.users.isAdmin($auth.user)}
|
||||
size="S"
|
||||
on:click={onClick}
|
||||
>
|
||||
Remove
|
||||
</ActionButton>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
import GroupNameTableRenderer from "./_components/GroupNameTableRenderer.svelte"
|
||||
import { goto } from "@roxi/routify"
|
||||
import ScimBanner from "../_components/SCIMBanner.svelte"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
const DefaultGroup = {
|
||||
name: "",
|
||||
|
@ -40,7 +41,7 @@
|
|||
{ column: "roles", component: GroupAppsTableRenderer },
|
||||
]
|
||||
|
||||
$: readonly = !$auth.isAdmin
|
||||
$: readonly = !sdk.users.isAdmin($auth.user)
|
||||
$: schema = {
|
||||
name: { displayName: "Group", width: "2fr", minWidth: "200px" },
|
||||
users: { sortable: false, width: "1fr" },
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
|
||||
$: scimEnabled = $features.isScimEnabled
|
||||
$: isSSO = !!user?.provider
|
||||
$: readonly = !$auth.isAdmin || scimEnabled
|
||||
$: readonly = !sdk.users.isAdmin($auth.user) || scimEnabled
|
||||
$: privileged = sdk.users.isAdminOrBuilder(user)
|
||||
$: nameLabel = getNameLabel(user)
|
||||
$: filteredGroups = getFilteredGroups($groups, searchTerm)
|
||||
|
@ -286,7 +286,7 @@
|
|||
<div class="field">
|
||||
<Label size="L">Role</Label>
|
||||
<Select
|
||||
disabled={!$auth.isAdmin}
|
||||
disabled={!sdk.users.isAdmin($auth.user)}
|
||||
value={globalRole}
|
||||
options={Constants.BudibaseRoleOptions}
|
||||
on:change={updateUserRole}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { ActionButton } from "@budibase/bbui"
|
||||
import { getContext } from "svelte"
|
||||
import { auth } from "stores/portal"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
export let value
|
||||
|
||||
|
@ -13,6 +14,10 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<ActionButton disabled={!$auth.isAdmin} size="S" on:click={onClick}>
|
||||
<ActionButton
|
||||
disabled={!sdk.users.isAdmin($auth.user)}
|
||||
size="S"
|
||||
on:click={onClick}
|
||||
>
|
||||
Remove
|
||||
</ActionButton>
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
import { API } from "api"
|
||||
import { OnboardingType } from "../../../../../constants"
|
||||
import ScimBanner from "../_components/SCIMBanner.svelte"
|
||||
import { sdk } from "@budibase/shared-core"
|
||||
|
||||
const fetch = fetchData({
|
||||
API,
|
||||
|
@ -66,7 +67,7 @@
|
|||
let userData = []
|
||||
|
||||
$: isOwner = $auth.accountPortalAccess && $admin.cloud
|
||||
$: readonly = !$auth.isAdmin || $features.isScimEnabled
|
||||
$: readonly = !sdk.users.isAdmin($auth.user) || $features.isScimEnabled
|
||||
|
||||
$: debouncedUpdateFetch(searchEmail)
|
||||
$: schema = {
|
||||
|
|
|
@ -14,13 +14,6 @@ export function createAuthStore() {
|
|||
postLogout: false,
|
||||
})
|
||||
const store = derived(auth, $store => {
|
||||
let isAdmin = false
|
||||
let isBuilder = false
|
||||
if ($store.user) {
|
||||
const user = $store.user
|
||||
isAdmin = sdk.users.isAdmin(user)
|
||||
isBuilder = sdk.users.isBuilder(user)
|
||||
}
|
||||
return {
|
||||
user: $store.user,
|
||||
accountPortalAccess: $store.accountPortalAccess,
|
||||
|
@ -28,8 +21,6 @@ export function createAuthStore() {
|
|||
tenantSet: $store.tenantSet,
|
||||
loaded: $store.loaded,
|
||||
postLogout: $store.postLogout,
|
||||
isAdmin,
|
||||
isBuilder,
|
||||
isSSO: !!$store.user?.provider,
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue