-
Notifications
You must be signed in to change notification settings - Fork 243
fix: env variable overwrite and action menu clipping in create function wizard #3097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+160
−76
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0c7b467
fix: match by key when $id is absent to prevent all variables being o…
HarshMN2345 806df25
revert: remove portal from wizard env variables popover — breaks onclick
HarshMN2345 0a21d85
fix: allow action menu to overflow table cell so popover is not clipped
HarshMN2345 56515de
fix: override table cell overflow to unclip action menu popover
HarshMN2345 9f2ef42
fix: use portal for action menu popover, set state before toggle to e…
HarshMN2345 3bdc82f
fix: replace pink Popover with custom Svelte 5 floating action menu t…
HarshMN2345 de34d5e
fix: add background, border and shadow to floating action menu
HarshMN2345 e1e5ce4
fix: portal menu div to document.body to prevent table cell layout br…
HarshMN2345 7160ccb
fix: reduce min column widths on small viewport to prevent table over…
HarshMN2345 d86ad4e
fix: use small min widths on mobile so table fits inside wizard conta…
HarshMN2345 7193390
fix: show icon-only create variable button on mobile to save horizont…
HarshMN2345 c58a082
fix: add strategy fixed, return autoUpdate cleanup from effect, use o…
HarshMN2345 d73328c
format
HarshMN2345 84a7c73
revert: undo greptile fixes (strategy fixed, effect cleanup, onclick)
HarshMN2345 2aa0eb7
fix: remove stopPropagation so outside-click handler can close other …
HarshMN2345 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| <script lang="ts"> | ||
| import { computePosition, flip, offset, shift, autoUpdate } from '@floating-ui/dom'; | ||
| import { Icon, ActionMenu } from '@appwrite.io/pink-svelte'; | ||
| import { | ||
| IconDotsHorizontal, | ||
| IconPencil, | ||
| IconEyeOff, | ||
| IconTrash | ||
| } from '@appwrite.io/pink-icons-svelte'; | ||
| import { Button as PinkButton } from '@appwrite.io/pink-svelte'; | ||
| import type { Models } from '@appwrite.io/console'; | ||
|
|
||
| let { | ||
| variable, | ||
| onUpdate, | ||
| onSecret, | ||
| onDelete | ||
| }: { | ||
| variable: Partial<Models.Variable>; | ||
| onUpdate: () => void; | ||
| onSecret: () => void; | ||
| onDelete: () => void; | ||
| } = $props(); | ||
|
|
||
| let open = $state(false); | ||
| let triggerEl = $state<HTMLElement | null>(null); | ||
| let menuEl = $state<HTMLElement | null>(null); | ||
| let cleanup: (() => void) | null = null; | ||
|
|
||
| function hide() { | ||
| open = false; | ||
| } | ||
|
|
||
| function toggle() { | ||
| open = !open; | ||
| } | ||
|
|
||
| function portalToBody(node: HTMLElement) { | ||
| document.body.appendChild(node); | ||
| return { | ||
| destroy() { | ||
| node.parentNode?.removeChild(node); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| $effect(() => { | ||
| if (open && triggerEl && menuEl) { | ||
| cleanup = autoUpdate(triggerEl, menuEl, () => { | ||
| computePosition(triggerEl, menuEl, { | ||
| placement: 'bottom-end', | ||
| middleware: [offset(2), flip(), shift()] | ||
| }).then(({ x, y }) => { | ||
| if (menuEl) { | ||
| Object.assign(menuEl.style, { left: `${x}px`, top: `${y}px` }); | ||
| } | ||
| }); | ||
| }); | ||
| } else { | ||
| cleanup?.(); | ||
| cleanup = null; | ||
| } | ||
| }); | ||
|
|
||
| function handleWindowClick(e: MouseEvent) { | ||
| if (!open) return; | ||
| const target = e.target as Node; | ||
| if (triggerEl?.contains(target) || menuEl?.contains(target)) return; | ||
| hide(); | ||
| } | ||
|
|
||
| function handleKeydown(e: KeyboardEvent) { | ||
| if (e.key === 'Escape') hide(); | ||
| } | ||
| </script> | ||
|
|
||
| <svelte:window onclick={handleWindowClick} onkeydown={handleKeydown} /> | ||
|
|
||
| <span bind:this={triggerEl}> | ||
| <PinkButton.Button | ||
| icon | ||
| variant="text" | ||
| size="s" | ||
| aria-label="More options" | ||
| onclick={(e) => { | ||
| e.preventDefault(); | ||
| toggle(); | ||
| }}> | ||
| <Icon icon={IconDotsHorizontal} size="s" /> | ||
| </PinkButton.Button> | ||
| </span> | ||
|
|
||
| {#if open} | ||
| <div | ||
| use:portalToBody | ||
| bind:this={menuEl} | ||
| style="position: fixed; z-index: 9001; background: var(--bgcolor-neutral-primary); border: var(--border-width-s) solid var(--border-neutral); border-radius: var(--border-radius-m); box-shadow: 0 1px 3px 0 rgba(0,0,0,0.03), 0 4px 4px 0 rgba(0,0,0,0.04); overflow: hidden;" | ||
| role="menu"> | ||
| <ActionMenu.Root> | ||
| {#if !variable?.secret} | ||
| <ActionMenu.Item.Button | ||
| leadingIcon={IconPencil} | ||
| on:click={() => { | ||
| hide(); | ||
| onUpdate(); | ||
| }}> | ||
| Update | ||
| </ActionMenu.Item.Button> | ||
| {/if} | ||
| {#if !variable?.secret} | ||
| <ActionMenu.Item.Button | ||
| leadingIcon={IconEyeOff} | ||
| on:click={() => { | ||
| hide(); | ||
| onSecret(); | ||
| }}> | ||
| Secret | ||
| </ActionMenu.Item.Button> | ||
| {/if} | ||
| <ActionMenu.Item.Button | ||
| status="danger" | ||
| leadingIcon={IconTrash} | ||
| on:click={() => { | ||
| hide(); | ||
| onDelete(); | ||
| }}> | ||
| Delete | ||
| </ActionMenu.Item.Button> | ||
| </ActionMenu.Root> | ||
| </div> | ||
| {/if} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.