Skip to content

Commit fb8875d

Browse files
committed
Add GitHub and Slack icons to team page header and display team info
1 parent ff32704 commit fb8875d

File tree

7 files changed

+123
-9
lines changed

7 files changed

+123
-9
lines changed
+47-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
11
<script lang="ts">
22
import { page } from '$app/state';
3+
import GitHubIcon from '$lib/icons/GitHubIcon.svelte';
4+
import SlackIcon from '$lib/icons/SlackIcon.svelte';
35
import { urlToPageHeader } from '$lib/urlToPageHeader';
6+
import { BodyShort } from '@nais/ds-svelte-community';
7+
import IconLabel from './IconLabel.svelte';
48
import DumbPageHeader from './PageHeader.svelte';
59
6-
const props = $derived(urlToPageHeader(page.url));
10+
interface Props {
11+
purpose?: string;
12+
gitHubOrganization?: string;
13+
gitHubTeam?: string;
14+
slackChannel?: string;
15+
}
16+
17+
const { purpose, gitHubOrganization, slackChannel, gitHubTeam }: Props = $props();
18+
19+
const dumbPageHeaderProps = $derived(urlToPageHeader(page.url));
720
</script>
821

9-
<DumbPageHeader {...props} />
22+
<DumbPageHeader {...dumbPageHeaderProps} />
23+
24+
<div class="team-info">
25+
{#if dumbPageHeaderProps.heading === gitHubTeam}
26+
<div>
27+
<BodyShort>{purpose}</BodyShort>
28+
</div>
29+
<div>
30+
<IconLabel
31+
href="https://github.com/orgs/{gitHubOrganization}/teams/{gitHubTeam}"
32+
icon={GitHubIcon}
33+
>
34+
{#snippet label()}
35+
<span class="label">Visit {gitHubTeam} on GitHub</span>
36+
{/snippet}
37+
</IconLabel>
38+
<IconLabel icon={SlackIcon}>
39+
{#snippet label()}
40+
<span class="label">Reach out on Slack: {slackChannel}</span>
41+
{/snippet}
42+
</IconLabel>
43+
</div>
44+
{/if}
45+
</div>
46+
47+
<style>
48+
.team-info {
49+
display: grid;
50+
grid-template-columns: 2fr 1fr;
51+
gap: var(--spacing-layout);
52+
margin-top: calc(-1 * var(--spacing-layout));
53+
}
54+
</style>

src/lib/icons/GitHubIcon.svelte

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script lang="ts">
2+
interface Props {
3+
size?: string;
4+
[key: string]: unknown;
5+
}
6+
7+
let { size = '1em', ...rest }: Props = $props();
8+
</script>
9+
10+
<svg
11+
height={size}
12+
width={size}
13+
aria-hidden="true"
14+
viewBox="0 0 24 24"
15+
version="1.1"
16+
data-view-component="true"
17+
class="octicon octicon-mark-github v-align-middle"
18+
{...rest}
19+
>
20+
<path
21+
d="M12.5.75C6.146.75 1 5.896 1 12.25c0 5.089 3.292 9.387 7.863 10.91.575.101.79-.244.79-.546 0-.273-.014-1.178-.014-2.142-2.889.532-3.636-.704-3.866-1.35-.13-.331-.69-1.352-1.18-1.625-.402-.216-.977-.748-.014-.762.906-.014 1.553.834 1.769 1.179 1.035 1.74 2.688 1.25 3.349.948.1-.747.402-1.25.733-1.538-2.559-.287-5.232-1.279-5.232-5.678 0-1.25.445-2.285 1.178-3.09-.115-.288-.517-1.467.115-3.048 0 0 .963-.302 3.163 1.179.92-.259 1.897-.388 2.875-.388.977 0 1.955.13 2.875.388 2.2-1.495 3.162-1.179 3.162-1.179.633 1.581.23 2.76.115 3.048.733.805 1.179 1.825 1.179 3.09 0 4.413-2.688 5.39-5.247 5.678.417.36.776 1.05.776 2.128 0 1.538-.014 2.774-.014 3.162 0 .302.216.662.79.547C20.709 21.637 24 17.324 24 12.25 24 5.896 18.854.75 12.5.75Z"
22+
></path>
23+
</svg>

src/lib/icons/SlackIcon.svelte

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script lang="ts">
2+
interface Props {
3+
size?: string;
4+
[key: string]: unknown;
5+
}
6+
7+
let { size = '1em', ...rest }: Props = $props();
8+
</script>
9+
10+
<svg
11+
height={size}
12+
width={size}
13+
aria-hidden="true"
14+
viewBox="0 0 24 24"
15+
version="1.1"
16+
data-view-component="true"
17+
class="octicon octicon-mark-github v-align-middle"
18+
{...rest}
19+
>
20+
<path
21+
fill-rule="evenodd"
22+
clip-rule="evenodd"
23+
d="M13 10C13 11.1046 13.8954 12 15 12C16.1046 12 17 11.1046 17 10V5C17 3.89543 16.1046 3 15 3C13.8954 3 13 3.89543 13 5V10ZM5 8C3.89543 8 3 8.89543 3 10C3 11.1046 3.89543 12 5 12H10C11.1046 12 12 11.1046 12 10C12 8.89543 11.1046 8 10 8H5ZM15 13C13.8954 13 13 13.8954 13 15C13 16.1046 13.8954 17 15 17H20C21.1046 17 22 16.1046 22 15C22 13.8954 21.1046 13 20 13H15ZM10 22C8.89543 22 8 21.1046 8 20L8 15C8 13.8954 8.89543 13 10 13C11.1046 13 12 13.8954 12 15V20C12 21.1046 11.1046 22 10 22ZM8 5C8 3.89543 8.89543 3 10 3C11.1046 3 12 3.89543 12 5V7H10C8.89543 7 8 6.10457 8 5ZM3 15C3 16.1046 3.89543 17 5 17C6.10457 17 7 16.1046 7 15V13H5C3.89543 13 3 13.8954 3 15ZM17 20C17 21.1046 16.1046 22 15 22C13.8954 22 13 21.1046 13 20V18H15C16.1046 18 17 18.8954 17 20ZM22 10C22 8.89543 21.1046 8 20 8C18.8954 8 18 8.89543 18 10V12H20C21.1046 12 22 11.1046 22 10Z"
24+
fill="#000000"
25+
/>
26+
</svg>

src/routes/team/[team]/+layout.gql

+7
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@ query TeamRoles($team: Slug!) {
44
viewerIsMember
55
deletionInProgress
66
lastSuccessfulSync
7+
externalResources {
8+
gitHubTeam {
9+
slug
10+
}
11+
}
12+
purpose
13+
slackChannel
714
}
815
}

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

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
<script lang="ts">
2+
// import { page } from '$app/stores';
3+
import { page } from '$app/state';
24
import PageHeader from '$lib/components/UrlBasedPageHeader.svelte';
35
import { Alert } from '@nais/ds-svelte-community';
46
import type { LayoutProps } from './$houdini';
57
import Menu from './Menu.svelte';
68
79
let { data, children }: LayoutProps = $props();
8-
let { deletionInProgress, lastSuccessfulSync, teamSlug, UserInfo, viewerIsMember } =
9-
$derived(data);
10+
let {
11+
deletionInProgress,
12+
lastSuccessfulSync,
13+
teamSlug,
14+
UserInfo,
15+
viewerIsMember,
16+
purpose,
17+
externalResources,
18+
slackChannel
19+
} = $derived(data);
20+
const gitHubOrganization = page.data.githubOrganization;
21+
const gitHubTeam = $derived(externalResources.gitHubTeam?.slug);
1022
</script>
1123

1224
<svelte:head><title>{teamSlug} - Console</title></svelte:head>
@@ -27,7 +39,8 @@
2739
<div class="main">
2840
<Menu features={UserInfo.data?.features} member={viewerIsMember} {teamSlug} />
2941
<div class="container">
30-
<PageHeader />
42+
<PageHeader {gitHubOrganization} {gitHubTeam} {purpose} {slackChannel} />
43+
3144
<div>{@render children?.()}</div>
3245
</div>
3346
</div>

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

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
query TeamOverview($team: Slug!) @cache(policy: NetworkOnly) {
22
team(slug: $team) {
3+
purpose
34
workloads(first: 600) {
45
nodes {
56
__typename

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import Card from '$lib/Card.svelte';
44
import AggregatedCostForTeam from '$lib/components/AggregatedCostForTeam.svelte';
55
import Deploys from '$lib/components/TeamDeployments.svelte';
6-
import TeamInfo from '$lib/components/TeamInfo.svelte';
76
import TeamUtilizationAndOverage from '$lib/components/TeamUtilizationAndOverage.svelte';
87
import VulnerabilitySummary from '$lib/components/VulnerabilitySummary.svelte';
98
import { Alert, Heading } from '@nais/ds-svelte-community';
@@ -13,7 +12,7 @@
1312
import type { PageProps } from './$houdini';
1413
1514
let { data }: PageProps = $props();
16-
let { TeamOverview, teamSlug, viewerIsMember } = $derived(data);
15+
let { TeamOverview, teamSlug } = $derived(data);
1716
1817
const getWorkloadsWithError = (errorType: (typeof supportedErrorTypes)[number]) => {
1918
const workloads = $TeamOverview.data?.team.workloads.nodes.filter((workload) =>
@@ -55,9 +54,9 @@
5554
{/each}
5655
</div>
5756
<div class="grid">
58-
<Card rows={1} columns={3}>
57+
<!--Card rows={1} columns={3}>
5958
<TeamInfo {teamSlug} {viewerIsMember} />
60-
</Card>
59+
</Card-->
6160

6261
<Card rows={1} columns={3}>
6362
<VulnerabilitySummary {teamSlug} />

0 commit comments

Comments
 (0)