allow admins to override the c_ prefix

This commit is contained in:
Ruben Fiszel
2022-11-27 01:17:07 +01:00
parent e3edec0951
commit 3301970b75
2 changed files with 26 additions and 8 deletions
+1 -1
View File
@@ -62,7 +62,7 @@
<Alert title="Demo workspace">The demo workspace shared in which all users get invited.</Alert
>
{:else if $workspaceStore == 'starter'}
<Alert title="Demo workspace"
<Alert title="Stater workspace"
>The starter workspace has all its elements (variables, resources, scripts, flows) shared
across all other workspaces. Useful to seed workspace with common elements within your
organization.</Alert
+25 -7
View File
@@ -19,7 +19,7 @@
import ShareModal from '$lib/components/ShareModal.svelte'
import SharedBadge from '$lib/components/SharedBadge.svelte'
import SvelteMarkdown from 'svelte-markdown'
import { userStore, workspaceStore, oauthStore } from '$lib/stores'
import { userStore, workspaceStore, oauthStore, superadmin } from '$lib/stores'
import SchemaEditor from '$lib/components/SchemaEditor.svelte'
import type { Schema } from '$lib/common'
import SchemaViewer from '$lib/components/SchemaViewer.svelte'
@@ -44,6 +44,8 @@
import Drawer from '$lib/components/common/drawer/Drawer.svelte'
import DrawerContent from '$lib/components/common/drawer/DrawerContent.svelte'
import Popover from '$lib/components/Popover.svelte'
import Toggle from '$lib/components/Toggle.svelte'
import Tooltip from '$lib/components/Tooltip.svelte'
type ResourceW = Resource & { canWrite: boolean }
type ResourceTypeW = ResourceType & { canWrite: boolean }
@@ -104,7 +106,7 @@
await ResourceService.createResourceType({
workspace: $workspaceStore!,
requestBody: {
name: 'c_' + newResourceTypeName,
name: (disableCustomPrefix ? '' : 'c_') + newResourceTypeName,
schema: newResourceTypeSchema,
description: newResourceTypeDescription
}
@@ -159,6 +161,8 @@
}
}
})
let disableCustomPrefix = false
</script>
<Drawer bind:this={resourceViewer} size="800px">
@@ -168,14 +172,28 @@
<div class="flex flex-col gap-6">
<label for="inp">
<div class="mb-1 font-semibold text-gray-700">Name<Required required={true} /></div>
<div>
<span
class="border border-gray-700 rounded p-1 -mr-4 text-sm bg-gray-200 inline-block w-8"
>c_</span
>
<div class="flex flex-row items-center gap-x-4">
{#if !disableCustomPrefix}
<span
class="border border-gray-700 rounded p-1 -mr-6 text-sm bg-gray-200 inline-block w-8"
>c_</span
>
{/if}
<div class="inline-block">
<input id="inp" type="text" bind:value={newResourceTypeName} />
</div>
{#if $userStore?.is_admin}
<Toggle
bind:checked={disableCustomPrefix}
options={{ right: 'disable c_ prefix (admin only)' }}
/>
<Tooltip
>Resource types are synchronized with the official types on the hub regularly. The
`c_` prefix is to avoid name clashes with them.</Tooltip
>
{/if}
</div>
</label>
<label>