mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 16:02:14 +00:00
Fix operator mode (#1960)
* feat(frontend): Only display edit button if user can write * feat(frontend): Only display edit button if user can write * feat(frontend): Only display edit button if user can write * feat(frontend): Only display edit button if user can write
This commit is contained in:
@@ -32,30 +32,32 @@
|
||||
<slot />
|
||||
</div>
|
||||
<div class="flex gap-1 md:gap-2 items-center">
|
||||
<Menu>
|
||||
<svelte:fragment slot="items">
|
||||
{#each menuItems as { label, Icon, onclick, color } (label)}
|
||||
<MenuItem
|
||||
on:click={() => {
|
||||
const div = document.querySelector('[id^="headlessui-menu-items"]')
|
||||
div?.parentElement?.remove()
|
||||
{#if menuItems.length > 0}
|
||||
<Menu>
|
||||
<svelte:fragment slot="items">
|
||||
{#each menuItems as { label, Icon, onclick, color } (label)}
|
||||
<MenuItem
|
||||
on:click={() => {
|
||||
const div = document.querySelector('[id^="headlessui-menu-items"]')
|
||||
div?.parentElement?.remove()
|
||||
|
||||
onclick()
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class={classNames(
|
||||
'text-xs flex items-center gap-2 flex-row-2 ',
|
||||
color === 'red' ? 'text-red-500' : ''
|
||||
)}
|
||||
onclick()
|
||||
}}
|
||||
>
|
||||
<Icon class="h-4" />
|
||||
{label}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</Menu>
|
||||
<div
|
||||
class={classNames(
|
||||
'text-xs flex items-center gap-2 flex-row-2 ',
|
||||
color === 'red' ? 'text-red-500' : ''
|
||||
)}
|
||||
>
|
||||
<Icon class="h-4" />
|
||||
{label}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</Menu>
|
||||
{/if}
|
||||
{#each mainButtons as btn}
|
||||
<Button
|
||||
{...btn.buttonProps}
|
||||
|
||||
@@ -103,10 +103,9 @@
|
||||
let runForm: RunForm
|
||||
|
||||
function getMainButtons(flow: Flow | undefined, args: object | undefined) {
|
||||
if (!flow || $userStore?.operator) return []
|
||||
|
||||
const buttons: any = []
|
||||
if (!$userStore?.operator) {
|
||||
|
||||
if (flow) {
|
||||
buttons.push({
|
||||
label: 'Fork',
|
||||
buttonProps: {
|
||||
@@ -114,11 +113,16 @@
|
||||
variant: 'border',
|
||||
color: 'light',
|
||||
size: 'xs',
|
||||
disabled: !can_write,
|
||||
startIcon: faCodeFork
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (!flow || $userStore?.operator || !can_write) {
|
||||
return buttons
|
||||
}
|
||||
|
||||
if (!$userStore?.operator) {
|
||||
buttons.push({
|
||||
label: 'Build App',
|
||||
buttonProps: {
|
||||
|
||||
@@ -197,10 +197,24 @@
|
||||
let deploymentDrawer: DeployWorkspaceDrawer
|
||||
|
||||
function getMainButtons(script: Script | undefined, args: object | undefined) {
|
||||
if (!script || $userStore?.operator) return []
|
||||
|
||||
const buttons: any = []
|
||||
|
||||
if (!topHash && script) {
|
||||
buttons.push({
|
||||
label: 'Fork',
|
||||
buttonProps: {
|
||||
href: `/scripts/add?template=${script.path}`,
|
||||
size: 'xs',
|
||||
color: 'light',
|
||||
startIcon: faCodeFork
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (!script || $userStore?.operator || !can_write) {
|
||||
return buttons
|
||||
}
|
||||
|
||||
if (Array.isArray(script.parent_hashes) && script.parent_hashes.length > 0) {
|
||||
buttons.push({
|
||||
label: `History`,
|
||||
@@ -217,19 +231,6 @@
|
||||
}
|
||||
|
||||
if (!$userStore?.operator) {
|
||||
if (!topHash) {
|
||||
buttons.push({
|
||||
label: 'Fork',
|
||||
buttonProps: {
|
||||
href: `/scripts/add?template=${script.path}`,
|
||||
|
||||
size: 'xs',
|
||||
color: 'light',
|
||||
startIcon: faCodeFork
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
buttons.push({
|
||||
label: 'Build App',
|
||||
buttonProps: {
|
||||
@@ -251,11 +252,11 @@
|
||||
href: `/scripts/edit/${script.path}?args=${encodeState(args)}${
|
||||
topHash ? `&hash=${script.hash}&topHash=` + topHash : ''
|
||||
}`,
|
||||
disabled: !can_write,
|
||||
size: 'xs',
|
||||
startIcon: faEdit,
|
||||
color: 'dark',
|
||||
variant: 'contained'
|
||||
variant: 'contained',
|
||||
disabled: !can_write
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user