Skip to content

Commit c6f7e23

Browse files
committed
downgrade deprecation to warning and remove Nais reference in workload health
1 parent 9daf8a0 commit c6f7e23

File tree

11 files changed

+119
-38
lines changed

11 files changed

+119
-38
lines changed

src/lib/components/Badge.svelte

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<script module lang="ts">
2+
export const badgeLevel = (
3+
errors: { level: WorkloadStatusErrorLevel$options }[]
4+
): WorkloadStatusErrorLevel$options => {
5+
if (errors.some((error) => error.level === 'ERROR')) {
6+
return 'ERROR';
7+
} else if (errors.some((error) => error.level === 'WARNING')) {
8+
return 'WARNING';
9+
} else {
10+
return 'TODO';
11+
}
12+
};
13+
</script>
14+
15+
<script lang="ts">
16+
import { type WorkloadStatusErrorLevel$options } from '$houdini';
17+
18+
export type BadgeProps = {
19+
count: number;
20+
level: WorkloadStatusErrorLevel$options;
21+
};
22+
23+
const { count, level }: BadgeProps = $props();
24+
</script>
25+
26+
{#if count}
27+
<div class={['badge', `badge--${level}`, { 'badge--long': `${count}`.length > 2 }]}>
28+
{count}
29+
</div>
30+
{/if}
31+
32+
<style>
33+
.badge {
34+
height: 2rem;
35+
width: 2rem;
36+
border-radius: 100%;
37+
display: flex;
38+
align-items: center;
39+
justify-content: center;
40+
41+
&.badge--WARNING {
42+
background-color: var(--a-surface-warning);
43+
color: var(--a-text-on-warning);
44+
border: 1px solid var(--a-border-warning);
45+
}
46+
47+
&.badge--ERROR {
48+
background-color: var(--a-surface-danger);
49+
color: var(--a-text-on-danger);
50+
border: 1px solid var(--a-border-danger);
51+
}
52+
53+
&.badge--TODO {
54+
background-color: var(--a-surface-info);
55+
color: var(--a-text-on-info);
56+
border: 1px solid var(--a-border-info);
57+
}
58+
59+
&.badge--long {
60+
font-size: var(--a-font-size-medium);
61+
}
62+
}
63+
</style>

src/lib/components/list/AppListItem.svelte

+10-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
name: string;
1818
environment: { name: string };
1919
team: { slug: string };
20-
status: { state: string };
20+
status: {
21+
state: string;
22+
errors: {
23+
__typename: string | null;
24+
level: 'ERROR' | 'WARNING' | 'TODO';
25+
}[];
26+
};
2127
deployments: { nodes: { createdAt: Date }[] };
2228
instances: {
2329
pageInfo: { totalCount: number };
@@ -39,11 +45,12 @@
3945
}}
4046
>
4147
{#snippet icon()}
48+
<!-- <Badge count={app.status.errors.length} level={badgeLevel(app.status.errors)} /> -->
4249
<TooltipAlignHack
4350
content={{
44-
NAIS: 'Application is Nais',
51+
NAIS: 'Application is healthy',
4552
FAILING: 'Application is failing',
46-
NOT_NAIS: 'Application is not Nais',
53+
NOT_NAIS: 'Application has issues',
4754
UNKNOWN: 'Application status is unknown'
4855
}[app.status.state] ?? ''}
4956
>

src/lib/components/list/JobListItem.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
{#snippet icon()}
4747
<TooltipAlignHack
4848
content={{
49-
NAIS: 'Job is Nais',
49+
NAIS: 'Job is healthy',
5050
FAILING: 'Job is failing',
51-
NOT_NAIS: 'Job is not Nais',
51+
NOT_NAIS: 'Job has issues',
5252
UNKNOWN: 'Job status is unknown'
5353
}[job.status.state] ?? ''}
5454
>

src/lib/components/list/ListItem.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
.list-item {
1313
background-color: #f7f8f9;
1414
display: grid;
15-
grid-template-columns: 1fr auto;
15+
grid-template-columns: 1fr;
16+
grid-auto-flow: column;
1617
align-items: center;
1718
column-gap: var(--a-spacing-4);
1819
padding: var(--a-spacing-4) var(--a-spacing-6);
+10-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
<script lang="ts">
22
import { PersonGroupIcon } from '@nais/ds-svelte-community/icons';
3+
import Badge, { type BadgeProps } from '../Badge.svelte';
34
import IconLabel from '../IconLabel.svelte';
45
import ListItem from './ListItem.svelte';
56
6-
const { team, errors }: { team: { slug: string; purpose: string }; errors: number } = $props();
7+
const {
8+
team,
9+
badge
10+
}: {
11+
team: { slug: string; purpose: string };
12+
badge?: BadgeProps;
13+
} = $props();
714
</script>
815

916
<ListItem>
@@ -15,27 +22,7 @@
1522
level="3"
1623
href="/team/{team.slug}"
1724
/>
18-
{#if errors}
19-
<div class={['errors', { 'errors--long': `${errors}`.length > 2 }]}>
20-
{errors}
21-
</div>
25+
{#if badge}
26+
<Badge {...badge} />
2227
{/if}
2328
</ListItem>
24-
25-
<style>
26-
.errors {
27-
height: 2rem;
28-
width: 2rem;
29-
border-radius: 100%;
30-
display: flex;
31-
align-items: center;
32-
justify-content: center;
33-
font-weight: var(--a-font-weight-bold);
34-
background-color: var(--a-surface-danger);
35-
color: var(--a-text-on-danger);
36-
37-
&.errors--long {
38-
font-size: var(--a-font-size-medium);
39-
}
40-
}
41-
</style>

src/routes/+page.gql

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ query UserTeams @cache(policy: CacheAndNetwork) {
2222
status {
2323
errors {
2424
__typename
25+
level
2526
}
2627
}
2728
}

src/routes/+page.svelte

+5-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@
4343
{#if $UserTeams.data.me.__typename == 'User'}
4444
<List>
4545
{#each $UserTeams.data.me.teams.nodes as node (node.team.id)}
46-
<TeamListItem
47-
team={node.team}
48-
errors={node.team.workloads.nodes.filter((w) =>
49-
w.status.errors.some((e) => e.__typename === 'WorkloadStatusDeprecatedRegistry')
50-
).length}
51-
/>
46+
<TeamListItem team={node.team} />
47+
<!-- badge={{
48+
count: node.team.workloads.nodes.length,
49+
level: badgeLevel(node.team.workloads.nodes.flatMap((w) => w.status.errors))
50+
}} -->
5251
{:else}
5352
<BodyLong>
5453
You don't seem to belong to any teams at the moment. You can create a new team or

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
{/if}
3333

3434
{#if deprecatedImages?.length}
35-
<Alert variant="error">
35+
<Alert variant="warning">
3636
Starting April 1st, applications and jobs on Nais must use images from Google Artifact Registry
3737
(GAR). The easiest way to ensure that images are stored in GAR is to use Nais' GitHub Actions in
3838
the workflow. <a

src/routes/team/[team]/[env]/app/[app]/+page.gql

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ query App($app: String!, $team: Slug!, $env: String!) {
3636
status {
3737
errors {
3838
__typename
39+
level
3940
... on WorkloadStatusDeprecatedRegistry {
4041
registry
4142
}

src/routes/team/[team]/[env]/app/[app]/+page.svelte

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { onNavigate } from '$app/navigation';
33
import { page } from '$app/state';
4-
import { graphql } from '$houdini';
4+
import { graphql, type WorkloadStatusErrorLevel$options } from '$houdini';
55
import AggregatedCostForWorkload from '$lib/components/AggregatedCostForWorkload.svelte';
66
import Confirm from '$lib/components/Confirm.svelte';
77
import Image from '$lib/components/Image.svelte';
@@ -60,6 +60,18 @@
6060
$App.data?.team.environment.application.deployments.nodes.at(0)?.statuses.nodes.at(0)?.state ===
6161
'FAILURE'
6262
);
63+
64+
const levelVariant = (level?: WorkloadStatusErrorLevel$options) => {
65+
switch (level) {
66+
case 'ERROR':
67+
return 'error';
68+
case 'WARNING':
69+
return 'warning';
70+
case 'TODO':
71+
default:
72+
return 'info';
73+
}
74+
};
6375
</script>
6476

6577
<GraphErrors errors={$App.errors} />
@@ -71,7 +83,13 @@
7183
<div class="app-content">
7284
<div class="main-section">
7385
{#if app.status.errors.some((error) => error.__typename === 'WorkloadStatusDeprecatedRegistry')}
74-
<Alert variant="error">
86+
<Alert
87+
variant={levelVariant(
88+
app.status.errors.find(
89+
(error) => error.__typename === 'WorkloadStatusDeprecatedRegistry'
90+
)?.level
91+
)}
92+
>
7593
<BodyShort spacing
7694
>This application is using a deprecated image registry ({app.status.errors.find(
7795
(error) => error.__typename === 'WorkloadStatusDeprecatedRegistry'

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

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ query Applications(
4747
}
4848
status {
4949
state
50+
errors {
51+
__typename
52+
level
53+
}
5054
}
5155
deployments(first: 1) {
5256
nodes {

0 commit comments

Comments
 (0)