* update: add migration for gcp_trigger table, add cli method gcp and add gcp_trigger args for github ci * update: add gcp module and routing it in lib.rs * update: added gcp type to TRIGGER KIND type in db, add new feature condition to try_get_fn and added gcp_trigger feature in cargo file * update: add ui for gcp trigger, added missing triggers type for job kin, add gcp trigger in deploy to functionallity * adding google cloud crate * update: handle pull and push delivery * update: handle pull and push delivery * update: handle push event, changed front ui * update: ui * fix: capture for gcp * update: automatically manage pub sub subscription and refactoring * capture done * update cli types * fix: wrong func argument and type openapi * fix: missing import * update .sqlx * update: svg color and remove pulse button for capture push gcp * update: handle deployto * update script helper and link to hub gcp script/flow * update gcp representation * update: add confirmation modal * add unique index to mitigate same subscriber id, fix `zombie worker`, update test connection logic * Update frontend/src/lib/components/triggers/gcp/GcpTriggerEditorInner.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Update cli/gen/services.gen.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * nits * update repo ref * fix feature function * update dependencies * update .sqlx * fix missing import * update: handle existing subscription and creating new one or update it * fix ee build * handle existing config properly * update .sqlx * update .sqlx * remove unused * update documentation link fix ci * use on instance of empty_string_as_none fn * update refo ref * updat script_helper * update ui * update migration * add missing arguments * fix and nits * update repo ref * remove unused * nits * add doc links * nits * Update frontend/src/lib/components/triggers/gcp/GcpTriggerPanel.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Update frontend/src/lib/components/triggers/gcp/GcpTriggerEditorInner.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * use trigger path as default route path * update .sqlx * update repo ref * update ref * update route path * update types * fix deploy to * nits * update repo ref * update .sqlx * Update frontend/src/lib/components/triggers/gcp/GcpTriggerEditorConfigSection.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * nits * nits * nits * remove dupliacte fn and update repo ref * remove unused import * fix missing import * fix: wong name var * update script helper and template script * Update frontend/src/lib/script_helpers.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Update ee-repo-ref.txt --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: HugoCasa <hugo@casademont.ch>
200 lines
5.1 KiB
Svelte
200 lines
5.1 KiB
Svelte
<script lang="ts">
|
|
import TableCustom from './TableCustom.svelte'
|
|
|
|
import { GroupService, UserService, GranularAclService } from '$lib/gen'
|
|
import { createEventDispatcher } from 'svelte'
|
|
import AutoComplete from 'simple-svelte-autocomplete'
|
|
import { userStore, workspaceStore } from '$lib/stores'
|
|
import { Alert, Button, Drawer } from './common'
|
|
import DrawerContent from './common/drawer/DrawerContent.svelte'
|
|
import Tooltip from './Tooltip.svelte'
|
|
import { sendUserToast } from '$lib/toast'
|
|
import { isOwner } from '$lib/utils'
|
|
import ToggleButtonGroup from './common/toggleButton-v2/ToggleButtonGroup.svelte'
|
|
import ToggleButton from './common/toggleButton-v2/ToggleButton.svelte'
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
type Kind =
|
|
| 'script'
|
|
| 'group_'
|
|
| 'resource'
|
|
| 'schedule'
|
|
| 'variable'
|
|
| 'flow'
|
|
| 'app'
|
|
| 'raw_app'
|
|
| 'http_trigger'
|
|
| 'websocket_trigger'
|
|
| 'kafka_trigger'
|
|
| 'nats_trigger'
|
|
| 'mqtt_trigger'
|
|
| 'sqs_trigger'
|
|
| 'postgres_trigger'
|
|
| 'gcp_trigger'
|
|
let kind: Kind
|
|
|
|
let path: string = ''
|
|
|
|
let ownerKind: 'user' | 'group' = 'user'
|
|
let owner: string = ''
|
|
|
|
let newOwner: string = ''
|
|
let write: boolean = false
|
|
let acls: [string, boolean][] = []
|
|
let groups: String[] = []
|
|
let usernames: string[] = []
|
|
|
|
let drawer: Drawer
|
|
|
|
$: newOwner = [ownerKind === 'group' ? 'g' : 'u', owner].join('/')
|
|
|
|
let own = false
|
|
export async function openDrawer(newPath: string, kind_l: Kind) {
|
|
path = newPath
|
|
kind = kind_l
|
|
loadAcls()
|
|
loadGroups()
|
|
loadUsernames()
|
|
loadOwner()
|
|
drawer.openDrawer()
|
|
}
|
|
|
|
async function loadOwner() {
|
|
own = isOwner(path, $userStore!, $workspaceStore!)
|
|
}
|
|
|
|
async function loadAcls() {
|
|
acls = Object.entries(
|
|
await GranularAclService.getGranularAcls({ workspace: $workspaceStore!, path, kind })
|
|
)
|
|
}
|
|
|
|
async function loadGroups(): Promise<void> {
|
|
groups = await GroupService.listGroupNames({ workspace: $workspaceStore! })
|
|
}
|
|
|
|
async function loadUsernames(): Promise<void> {
|
|
usernames = await UserService.listUsernames({ workspace: $workspaceStore! })
|
|
}
|
|
|
|
async function deleteAcl(owner: string) {
|
|
try {
|
|
await GranularAclService.removeGranularAcls({
|
|
workspace: $workspaceStore!,
|
|
path,
|
|
kind,
|
|
requestBody: { owner }
|
|
})
|
|
loadAcls()
|
|
dispatch('change', { path, kind })
|
|
} catch (err) {
|
|
sendUserToast(err.toString(), true)
|
|
}
|
|
}
|
|
|
|
async function addAcl(owner: string, write: boolean) {
|
|
await GranularAclService.addGranularAcls({
|
|
workspace: $workspaceStore!,
|
|
path,
|
|
kind,
|
|
requestBody: { owner, write }
|
|
})
|
|
loadAcls()
|
|
dispatch('change', { path, kind })
|
|
}
|
|
</script>
|
|
|
|
<Drawer bind:this={drawer}>
|
|
<DrawerContent title="Share {path}" on:close={drawer.closeDrawer}>
|
|
<div class="flex flex-col gap-6">
|
|
<h1>{path}</h1>
|
|
<h2
|
|
>Extra Permissions ({acls?.length ?? 0}) <Tooltip
|
|
>Items already have default permissions. If belonging to an user or group, that group or
|
|
user owns it and can write to it as well as modify its permisions and move it. Folders
|
|
have read/write that apply to the whole folder and are additive to the items permissions.</Tooltip
|
|
></h2
|
|
>
|
|
{#if !own}
|
|
<Alert type="warning" title="Not owner"
|
|
>Since you do not own this item, you cannot modify its permission</Alert
|
|
>
|
|
{/if}
|
|
<div>
|
|
{#if own}
|
|
<div class="flex flex-row flex-wrap gap-2 items-center">
|
|
<div>
|
|
<ToggleButtonGroup
|
|
bind:selected={ownerKind}
|
|
on:selected={() => (owner = '')}
|
|
let:item
|
|
>
|
|
<ToggleButton value="user" size="xs" label="User" {item} />
|
|
<ToggleButton value="group" size="xs" label="Group" {item} />
|
|
</ToggleButtonGroup>
|
|
</div>
|
|
{#key ownerKind}
|
|
<AutoComplete
|
|
required
|
|
noInputStyles
|
|
items={ownerKind === 'user' ? usernames : groups}
|
|
bind:selectedItem={owner}
|
|
/>
|
|
{/key}
|
|
<Button size="sm" on:click={() => addAcl(newOwner, write)}>Add permission</Button>
|
|
</div>
|
|
{/if}
|
|
<TableCustom>
|
|
<tr slot="header-row">
|
|
<th>owner</th>
|
|
<th></th>
|
|
<th></th>
|
|
</tr>
|
|
<tbody slot="body">
|
|
{#each acls as [owner, write]}
|
|
<tr>
|
|
<td>{owner}</td>
|
|
<td
|
|
>{#if own}
|
|
<div>
|
|
<ToggleButtonGroup
|
|
selected={write ? 'writer' : 'viewer'}
|
|
on:selected={async (e) => {
|
|
const role = e.detail
|
|
if (role == 'writer') {
|
|
await addAcl(owner, true)
|
|
} else {
|
|
await addAcl(owner, false)
|
|
}
|
|
loadAcls()
|
|
}}
|
|
let:item
|
|
>
|
|
<ToggleButton value="viewer" size="xs" label="Viewer" {item} />
|
|
<ToggleButton value="writer" size="xs" label="Writer" {item} />
|
|
</ToggleButtonGroup>
|
|
</div>
|
|
{:else}{write}{/if}</td
|
|
>
|
|
<td>
|
|
{#if own}
|
|
<Button
|
|
variant="border"
|
|
color="red"
|
|
size="xs"
|
|
on:click={() => deleteAcl(owner)}
|
|
>
|
|
Delete
|
|
</Button>
|
|
{/if}
|
|
</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</TableCustom>
|
|
</div>
|
|
</div>
|
|
</DrawerContent>
|
|
</Drawer>
|