-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathbody.svelte
51 lines (44 loc) · 1.82 KB
/
body.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { getServiceLimit, type PlanServices } from '$lib/stores/billing';
import { wizard } from '$lib/stores/wizard';
import { isCloud } from '$lib/system';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { Button } from '../forms';
let tableBody: HTMLDivElement;
export let service: PlanServices = null;
export let name = service;
export let total: number = null;
export let event: string = null;
let columns = 0;
const limit = getServiceLimit(service) || Infinity;
const upgradeMethod = () => {
wizard.start(ChangeOrganizationTierCloud);
};
$: limitReached = limit !== 0 && limit < Infinity && total >= limit;
$: if (tableBody) {
columns = tableBody?.parentNode?.querySelectorAll('.table-thead-col')?.length;
}
</script>
<div class="table-tbody" role="rowgroup" bind:this={tableBody}>
<slot />
</div>
{#if isCloud && limitReached && service}
<tr class="table-row">
<td class="table-col" width="100%" colspan={columns}>
<span class="u-flex u-gap-24 u-main-center u-cross-center">
<slot name="limit" {upgradeMethod} {limit}>
<span class="text">Upgrade your plan to add {name} to your organization</span>
<Button
secondary
on:click={upgradeMethod}
on:click={() =>
trackEvent('click_organization_upgrade', {
from: 'button',
source: event ?? 'table_row_limit_reached'
})}>Upgrade plan</Button>
</slot>
</span>
</td>
</tr>
{/if}