This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a60bc22
commit 7db7aab
Showing
4 changed files
with
134 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Alert, Box, CopyButton, ExpansionCard, Link, Loader, Tooltip } from "@navikt/ds-react" | ||
import { JoinableView, useJoinableViewQuery } from "../../lib/schema/graphql" | ||
import { ExternalLink } from "@navikt/ds-icons" | ||
import LoaderSpinner from "../lib/spinner" | ||
import { useState } from "react" | ||
|
||
interface JoinableViewCardProps { | ||
joinableView: JoinableView | ||
} | ||
|
||
export const JoinableViewCardContent = ({ joinableViewId }: { joinableViewId: string }) => { | ||
const { data, loading, error } = useJoinableViewQuery({ variables: { id: joinableViewId } }) | ||
const urlComps = data?.joinableView.bigqueryViewUrls && data?.joinableView.bigqueryViewUrls.length | ||
? data?.joinableView.bigqueryViewUrls[0].split('.') : ["", "", ""] | ||
const projectID = urlComps[0] | ||
const datasetID = urlComps[1] | ||
const bigQueryUrl = `https://console.cloud.google.com/bigquery?d=${datasetID}&p=${projectID}&page=dataset` | ||
|
||
return <div> | ||
{loading && <LoaderSpinner />} | ||
{error && <Alert variant="error">Klarte ikke hente data om views tilrettelagt for kobling</Alert>} | ||
{data && <> | ||
<Link href={bigQueryUrl}>{"Åpne BigQuery dataset i Google Cloud Console"}<ExternalLink /></Link> | ||
{data?.joinableView.bigqueryViewUrls.map((bqv, index) => <Box key={bqv} padding="1" className="w-[55rem]"> | ||
{data?.joinableView.accessToViews[index] ? <div className="flex flex-row items-center bg-gray-200">{bqv}<CopyButton copyText={bqv}></CopyButton></div> | ||
: <Tooltip content="Har ikke tilgang til datasettet"><div className="flex flex-row items-center text-gray-200" >{bqv}</div></Tooltip>} | ||
</Box>)} | ||
{data?.joinableView.expires && | ||
<div className="mt-3 italic"> | ||
BigQuery datasettet slettes {data?.joinableView.expires.split("T")[0]} | ||
</div> | ||
} | ||
</>} | ||
</div> | ||
} | ||
|
||
export const JoinableViewCard = ({ joinableView }: JoinableViewCardProps) => { | ||
const [expanded, setExpanded] = useState(false) | ||
|
||
return <div key={joinableView.id} className="w-[60rem]"> | ||
<ExpansionCard aria-label="default-demo" onToggle={open => setExpanded(open)}> | ||
<ExpansionCard.Header> | ||
<ExpansionCard.Title>{`${joinableView?.name} - ${joinableView?.created}`}</ExpansionCard.Title> | ||
<ExpansionCard.Description> | ||
<p>Klikk for å vise BigQuery dataset</p></ExpansionCard.Description> | ||
</ExpansionCard.Header> | ||
<ExpansionCard.Content> | ||
{expanded && <JoinableViewCardContent joinableViewId={joinableView.id} />} | ||
</ExpansionCard.Content> | ||
</ExpansionCard> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { gql } from 'graphql-tag'; | ||
|
||
export const GET_JOINABLEVIEWINDETAIL = gql` | ||
query JoinableView($id: ID!) { | ||
joinableView(id: $id) { | ||
name | ||
created | ||
expires | ||
bigqueryViewUrls | ||
accessToViews | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters