Skip to content

Commit 8891995

Browse files
committed
feat: add CDNBucket component and integrate it into PersistencePage with conditional rendering
1 parent 5169281 commit 8891995

File tree

5 files changed

+71
-21
lines changed

5 files changed

+71
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script lang="ts">
2+
import { Heading } from '@nais/ds-svelte-community';
3+
4+
interface Props {
5+
cdnBucket: string;
6+
}
7+
8+
let { cdnBucket }: Props = $props();
9+
</script>
10+
11+
<div>
12+
<Heading size="small" level="3">Team CDN Bucket</Heading>
13+
14+
<a href="https://console.cloud.google.com/storage/browser/{cdnBucket}">
15+
{cdnBucket}
16+
</a>
17+
</div>

src/lib/components/persistence/PersistenceCost.svelte

+4-6
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@
2727
height: '230px',
2828
width: '300px',
2929
tooltip: {
30-
// axisPointer: {
31-
// type: 'shadow'
32-
// },
3330
trigger: 'axis',
3431
formatter: (params: CallbackDataParams[]) =>
3532
`${params[0].name}: <b>${euroValueFormatter(params[0].value as number)}</b>`
3633
},
3734
grid: {
38-
top: '50',
35+
top: '20',
3936
left: '0',
4037
containLabel: true
4138
},
@@ -170,8 +167,9 @@
170167
</Detail>
171168
</div>
172169
</div>
173-
174-
<EChart options={costTransform(costData.daily.series)} />
170+
<div style="height: 270px;">
171+
<EChart options={costTransform(costData.daily.series)} />
172+
</div>
175173

176174
<a href="/team/{teamSlug}/cost">See cost details</a>
177175
</div>

src/lib/components/persistence/PersistencePage.svelte

+34-8
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import { Tag } from '@nais/ds-svelte-community';
1414
import { endOfYesterday, startOfMonth, subMonths } from 'date-fns';
1515
import type { Snippet } from 'svelte';
16+
import CdnBucket from './CDNBucket.svelte';
1617
1718
let {
1819
description,
1920
notFound,
21+
cdnBucket,
2022
cost,
2123
list,
2224
pageInfo,
@@ -25,6 +27,7 @@
2527
}: {
2628
description: Snippet;
2729
notFound: Snippet;
30+
cdnBucket?: string;
2831
cost?: {
2932
costData: CostData;
3033
teamSlug: string;
@@ -101,16 +104,34 @@
101104
}}
102105
/>
103106
</div>
104-
{#if cost}
105-
<PersistenceCost
106-
{...cost}
107-
from={startOfMonth(subMonths(new Date(), 1))}
108-
to={endOfYesterday()}
109-
/>
110-
{/if}
107+
<div class="right-column">
108+
{#if cost}
109+
<div>
110+
<PersistenceCost
111+
{...cost}
112+
from={startOfMonth(subMonths(new Date(), 1))}
113+
to={endOfYesterday()}
114+
/>
115+
</div>
116+
{/if}
117+
{#if cdnBucket}
118+
<div>
119+
<CdnBucket {cdnBucket} />
120+
</div>
121+
{/if}
122+
</div>
111123
</div>
112124
{:else}
113-
{@render notFound()}
125+
<div class="content-wrapper">
126+
{@render notFound()}
127+
<div class="right-column">
128+
{#if cdnBucket}
129+
<div>
130+
<CdnBucket {cdnBucket} />
131+
</div>
132+
{/if}
133+
</div>
134+
</div>
114135
{/if}
115136

116137
<style>
@@ -124,4 +145,9 @@
124145
gap: var(--a-spacing-1-alt);
125146
align-items: center;
126147
}
148+
149+
.right-column {
150+
display: grid;
151+
gap: var(--a-spacing-6);
152+
}
127153
</style>

src/routes/team/[team]/buckets/+page.gql

+6
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,11 @@ query Buckets(
5656
}
5757
}
5858
}
59+
60+
externalResources {
61+
cdn {
62+
bucket
63+
}
64+
}
5965
}
6066
}

src/routes/team/[team]/buckets/+page.svelte

+10-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
{#if $Buckets.data}
1515
<PersistencePage
16+
cdnBucket={$Buckets.data.team.externalResources.cdn?.bucket}
1617
cost={{
1718
costData: $Buckets.data.team.cost,
1819
teamSlug: $Buckets.data.team.slug,
@@ -32,13 +33,15 @@
3233
</BodyLong>
3334
{/snippet}
3435
{#snippet notFound()}
35-
<BodyLong>
36-
<strong>No Buckets found.</strong> Storage buckets are containers for storing and managing
37-
data in the cloud.
38-
<a href="https://docs.nais.io/persistence/buckets">
39-
Learn more about Buckets and how to get started.
40-
</a>
41-
</BodyLong>
36+
<div>
37+
<BodyLong>
38+
<strong>No Buckets found.</strong> Storage buckets are containers for storing and managing
39+
data in the cloud.
40+
<a href="https://docs.nais.io/persistence/buckets">
41+
Learn more about Buckets and how to get started.
42+
</a>
43+
</BodyLong>
44+
</div>
4245
{/snippet}
4346
</PersistencePage>
4447
{/if}

0 commit comments

Comments
 (0)