Files
console/src/lib/components/copy.svelte
T
Darshan b1df97a4c3 svelte5: cleanups, improvements (#1966)
* update: cleanups, improvements.

* fix: protocol usage.

* update: load failed invoice as non-blocking.

* address comments, make stuff faster!

* fix: missing type on org loads.

* fix: connect button shown on org. page.

* fix: error check.

* update: comment, just ocd things.

* update: flip `localStorage` check after `browser` check.

* update: comment.

* perf: parallelize fetch for faster loads [↓49%]

* update: compute things later.

* update: don't rely on dependency or reload if scope doesn't allow.

* update: simplify.

* update: do not load credits if the organization plan does not support it.

* update: just some cleaning.

* address comments for promise handling.

* address comments; remove: unused api calls!!!

* address comments;

* address comment.

* misc.

* cleaner endpoint creation.

* fix: required to optional.

* update: url to quick load.

* address comments.

* update: load payments on ui.

* update: load non-urgent calls on UI.

* fix: unnecessary runs of root layout.

* reduce: calls to countries, locale api.

* reduce: calls to countries, locale api in org settings.

* update: simplify api calls and data passing.

* address comments.

* remove: id from `UsageProjectInfo`.

* update: make api call only when needed.

* fix: text.

* fix: endpoint flag design <> verified by design.

* fix: `inline` inner stack so project name has enough space.

* fix: tests.

* update: improve orgs loading?

* update: misc.

* remove: todo.

* updates: more billing cleanups.

* misc.

* misc.

* fix: tests and a warning.

* address comment.

* fix: merge leftover issues.

* fix: tab selection on overview.

* fix: issues with user store on main project layout.

* remove: `selectedTab` store.

* fix: account menu regression.

* fix: reactive logic. use `svelte5` syntax.

* Remove trailing comma in invalidate array

* remove: unused method.

* updates: misc optimizations.

* fix: lint.

* update: changes after merge.

* update: modal size for credits and show loader.

* update: misc and PR freeze!

* update: use a default credit card icon if one isn't supported by the API.

* fix: project loading state as per updated org ID. LAST FIX.

* address comments.

---------

Co-authored-by: Torsten Dittmann <torsten.dittmann@googlemail.com>
2025-06-20 15:17:23 +02:00

55 lines
1.4 KiB
Svelte

<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { clickOnEnter } from '$lib/helpers/a11y';
import { copy } from '$lib/helpers/copy';
import { addNotification } from '$lib/stores/notifications';
import { Tooltip } from '@appwrite.io/pink-svelte';
export let value: string;
export let event: string = null;
export let eventContext = 'click_id_tag';
export let tooltipDisabled = false;
export let copyText: string = 'Click to copy';
let content = copyText;
async function handleClick() {
const success = await copy(value);
if (success) {
content = 'Copied';
} else {
addNotification({
message: 'Unable to copy to clipboard',
type: 'error'
});
}
if (event) {
trackEvent(eventContext, {
name: event
});
}
}
//TODO: remove this component
</script>
<Tooltip disabled={tooltipDisabled}>
<span
data-private
style:display="inline-flex"
role="button"
tabindex="0"
style:cursor="pointer"
on:click|preventDefault|stopPropagation={handleClick}
on:keyup={clickOnEnter}
on:mouseenter={() => setTimeout(() => (content = copyText))}>
<slot />
</span>
<p slot="tooltip" let:showing>
{#if showing}
{content}
{/if}
</p>
</Tooltip>