Skip to content

Commit

Permalink
fix notifications on status tab
Browse files Browse the repository at this point in the history
  • Loading branch information
rbjornstad committed Oct 25, 2023
1 parent ee227f6 commit 20c6f89
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 35 deletions.
13 changes: 4 additions & 9 deletions src/lib/AppErrorTypeToMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,25 @@
graphql(`
fragment AppErrorFragment on StateError {
revision @loading
level
type: __typename
... on DeprecatedIngressError {
level
ingress
}
... on DeprecatedRegistryError {
level
name
registry
repository
revision
tag
}
... on InvalidNaisYamlError {
level
detail
}
... on NewInstancesFailingError {
level
failingInstances
}
... on NoRunningInstancesError {
level
}
... on InboundAccessError {
level
rule {
application
cluster
Expand All @@ -45,8 +38,10 @@
namespace
}
}
... on OutboundAccessError {
... on NoRunningInstancesError {
level
}
... on OutboundAccessError {
rule {
application
cluster
Expand Down
5 changes: 2 additions & 3 deletions src/routes/team/[team]/[env]/app/[app]/+layout.gql
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
query AppNotificationState($app: String!, $team: String!, $env: String!)
@cache(policy: NetworkOnly) {
query AppNotificationState($app: String!, $team: String!, $env: String!) {
app(name: $app, team: $team, env: $env) {
appState {
state
errors {
level
__typename
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/routes/team/[team]/[env]/app/[app]/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script lang="ts">
import { page } from '$app/stores';
import { State } from '$houdini/graphql/enums';
import Tab from '$lib/Tab.svelte';
import Tabs from '$lib/Tabs.svelte';
import { replacer } from '$lib/replacer';
import type { LayoutData } from './$houdini';
$: team = $page.params.team;
$: env = $page.params.env;
Expand Down Expand Up @@ -36,12 +38,11 @@
routeId: '/team/[team]/[env]/app/[app]/cost'
}
];
//export let data: PageData;
//$: ({ AppNotificationState } = data);
export let data: LayoutData;
$: ({ AppNotificationState } = data);
//$: state = $AppNotificationState.data?.app.appState.state;
//$: numberOfErrors = $AppNotificationState.data?.app.appState.errors.length;
//$: console.log($AppNotificationState);
$: state = $AppNotificationState.data?.app.appState.state;
$: numberOfErrors = $AppNotificationState.data?.app.appState.errors.length;
</script>

<svelte:head><title>{team} - Console</title></svelte:head>
Expand Down Expand Up @@ -71,20 +72,19 @@
title={tab}
/>
{/if}
<!--
{#if tab === 'Status' && state !== 'NAIS'}
{#if state === 'NOTNAIS'}
{#if tab === 'Status' && state !== State.NAIS}
{#if state === State.NOTNAIS}
<div class="circle warning">{numberOfErrors}</div>
{:else if state === 'FAILING' || state !== 'UNKNOWN'}
{:else if state === State.FAILING || state !== State.UNKNOWN}
<div class="circle error">{numberOfErrors}</div>
{/if}
{/if}-->
{/if}
{/each}
</Tabs>
<slot />

<style>
/*.error {
.error {
background-color: var(--a-icon-danger);
color: var(--a-text-on-danger);
}
Expand All @@ -104,5 +104,5 @@
font:
8px Arial,
sans-serif;
}*/
}
</style>
6 changes: 3 additions & 3 deletions src/routes/team/[team]/[env]/job/[job]/+layout.gql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
query JobNotificationState($job: String!, $team: String!, $env: String!) {
naisjob(name: $job, team: $team, env: $env) @loading(cascade: true) {
jobState @loading {
naisjob(name: $job, team: $team, env: $env) {
jobState {
state
errors {
level
__typename
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions src/routes/team/[team]/[env]/job/[job]/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script lang="ts">
import { page } from '$app/stores';
import { State } from '$houdini/graphql/enums';
import Tab from '$lib/Tab.svelte';
import Tabs from '$lib/Tabs.svelte';
import { replacer } from '$lib/replacer';
import type { LayoutData } from './$houdini';
$: team = $page.params.team;
$: env = $page.params.env;
Expand Down Expand Up @@ -35,11 +37,11 @@
routeId: '/team/[team]/[env]/job/[job]/cost'
}
];
//export let data: PageData;
//$: ({ JobNotificationState } = data);
export let data: LayoutData;
$: ({ JobNotificationState } = data);
//$: state = $JobNotificationState.data?.naisjob.jobState.state;
//$: numberOfErrors = $JobNotificationState.data?.naisjob.jobState.errors.length;
$: state = $JobNotificationState.data?.naisjob.jobState.state;
$: numberOfErrors = $JobNotificationState.data?.naisjob.jobState.errors.length;
</script>

<svelte:head><title>{team} - Console</title></svelte:head>
Expand All @@ -66,19 +68,19 @@
title={tab}
/>
{/if}
<!--{#if tab === 'Status' && state !== State.NAIS}
{#if tab === 'Status' && state !== State.NAIS}
{#if state === State.NOTNAIS}
<div class="circle warning">{numberOfErrors}</div>
{:else if state === State.FAILING || state !== State.UNKNOWN}
<div class="circle error">{numberOfErrors}</div>
{/if}
{/if}-->
{/if}
{/each}
</Tabs>
<slot />

<style>
/*.error {
.error {
background-color: var(--a-icon-danger);
color: var(--a-text-on-danger);
}
Expand All @@ -98,5 +100,5 @@
font:
8px Arial,
sans-serif;
}*/
}
</style>

0 comments on commit 20c6f89

Please sign in to comment.