Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit 711b0c6

Browse files
committed
use user info query
1 parent 3e9cb1d commit 711b0c6

29 files changed

+123
-420
lines changed

components/dataproducts/dataset/dataset.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { isAfter, parseISO } from 'date-fns'
2-
import {
3-
UserInfoDetailsQuery,
4-
} from '../../../lib/schema/graphql'
52
import * as React from 'react'
63
import { useState } from 'react'
74
import EditDataset from './editDataset'
@@ -11,7 +8,7 @@ import LoaderSpinner from '../../lib/spinner'
118
import { Alert } from '@navikt/ds-react'
129

1310
const findAccessType = (
14-
groups: UserInfoDetailsQuery['userInfo']['groups'] | undefined,
11+
groups: any,
1512
dataset: any,
1613
isOwner: boolean
1714
) => {
@@ -29,7 +26,7 @@ const findAccessType = (
2926
interface EntryProps {
3027
dataproduct: any
3128
datasetID: string
32-
userInfo: UserInfoDetailsQuery['userInfo'] | undefined
29+
userInfo: any
3330
isOwner: boolean
3431
}
3532

components/dataproducts/dataset/datasetSourceForm.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export const DataproductSourceForm = ({
3434
register('bigquery.table')
3535

3636
const teamProjects = userInfo?.gcpProjects
37-
.filter((project) => project.group.email == team)
38-
.map((group) => group.id)
37+
.filter((project: any) => project.group.email == team)
38+
.map((group: any) => group.id)
3939

4040
const handleNodeSelect = (e: any, node: string) => {
4141
const [projectID, datasetID, tableID] = node.split('/')
@@ -59,7 +59,7 @@ export const DataproductSourceForm = ({
5959
onNodeSelect={handleNodeSelect}
6060
onNodeToggle={(x, n) => setActivePaths(n)}
6161
>
62-
{teamProjects?.map((projectID) => (
62+
{teamProjects?.map((projectID: any) => (
6363
<Project
6464
key={projectID}
6565
projectID={projectID}

components/dataproducts/dataset/viewDataset.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { PluggableList } from 'react-markdown/lib'
77
import remarkGfm from 'remark-gfm'
88
import {
99
PiiLevel,
10-
UserInfoDetailsQuery,
1110
} from '../../../lib/schema/graphql'
1211
import { backendHost } from '../../header/user'
1312
import TagPill from '../../lib/tagPill'
@@ -27,7 +26,7 @@ interface ViewDatasetProps {
2726
type: string
2827
expires?: any
2928
}
30-
userInfo: UserInfoDetailsQuery['userInfo'] | undefined
29+
userInfo: any
3130
isOwner: boolean
3231
setEdit: (value: boolean) => void
3332
}

components/dataproducts/newDataproductForm.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export const NewDataproductForm = () => {
129129
})
130130
}
131131

132+
const gcpProjects = userInfo?.gcpProjects as any[] || []
133+
132134
return (
133135
<div className="mt-8 md:w-[46rem]">
134136
<Heading level="1" size="large">
@@ -160,11 +162,11 @@ export const NewDataproductForm = () => {
160162
<option value="">Velg gruppe</option>
161163
{[
162164
...new Set(
163-
userInfo?.gcpProjects.map(
165+
gcpProjects.map(
164166
({ group }: { group: { name: string } }) => (
165167
<option
166168
value={
167-
userInfo?.groups.filter((g) => g.name === group.name)[0]
169+
userInfo?.groups.filter((g:any) => g.name === group.name)[0]
168170
.email
169171
}
170172
key={group.name}

components/header/user.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export const backendHost = () => {
99
}
1010

1111
export default function User() {
12-
const userInfo = useContext(UserState)
13-
const userOfNada = userInfo?.groups.find((gr) => gr.name === 'nada')
12+
const userData = useContext(UserState)
13+
const userOfNada = userData?.googleGroups.find((gr: any) => gr.name === 'nada')
1414

1515
const router = useRouter()
16-
return userInfo ? (
16+
return userData ? (
1717
<div className="flex flex-row min-w-fit">
1818
<Dropdown>
1919
<Header.Button
@@ -127,7 +127,7 @@ export default function User() {
127127
className="whitespace-nowrap hidden md:block text-base"
128128
as={Dropdown.Toggle}
129129
>
130-
{userInfo.name}
130+
{userData.name}
131131
</Header.Button>
132132
<Header.Button
133133
className="md:hidden w-[48px] flex justify-center"

components/insightProducts/editInsightProduct.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ import * as yup from 'yup'
1717
import { useContext, useState } from 'react'
1818
import TagsSelector from '../lib/tagsSelector'
1919
import { UserState } from "../../lib/context";
20-
import { UPDATE_INSIGHT_PRODUCT_METADATA } from '../../lib/queries/insightProducts/editInsightProduct'
2120
import { useUpdateInsightProductMetadataMutation } from '../../lib/schema/graphql'
22-
import { USER_INFO } from '../../lib/queries/userInfo/userInfo'
2321

2422
const schema = yup.object().shape({
2523
name: yup.string().nullable().required('Skriv inn navnet på innsiktsproduktet'),
@@ -109,10 +107,6 @@ export const EditInsightProductMetadataForm = ({ id, name, description, type, li
109107
teamID: teamID,
110108
group: data.group,
111109
},
112-
refetchQueries: [
113-
{
114-
query: USER_INFO,
115-
}]
116110
}
117111

118112
updateInsightProductQuery(editInsightProductData).then(() => {
@@ -164,7 +158,7 @@ export const EditInsightProductMetadataForm = ({ id, name, description, type, li
164158
control={control}
165159
/>
166160
<TeamkatalogenSelector
167-
gcpGroups={userInfo?.gcpProjects.map(it => it.group.email)}
161+
gcpGroups={userInfo?.gcpProjects.map((it: any) => it.group.email)}
168162
register={register}
169163
watch={watch}
170164
errors={errors}

components/insightProducts/newInsightProduct.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export const NewInsightProductForm = () => {
126126
CREATE_INSIGHT_PRODUCT,
127127
{
128128
onCompleted: (data) => {
129-
console.log(data)
130129
router.push("/")
131130
},
132131
}
@@ -153,6 +152,8 @@ export const NewInsightProductForm = () => {
153152
})
154153
}
155154

155+
const gcpProjects = userInfo?.gcpProjects as any[] || []
156+
156157
return (
157158
<div className="mt-8 md:w-[46rem]">
158159
<Heading level="1" size="large">
@@ -205,11 +206,11 @@ export const NewInsightProductForm = () => {
205206
<option value="">Velg gruppe</option>
206207
{[
207208
...new Set(
208-
userInfo?.gcpProjects.map(
209+
gcpProjects.map(
209210
({ group }: { group: { name: string } }) => (
210211
<option
211212
value={
212-
userInfo?.groups.filter((g) => g.name === group.name)[0]
213+
userInfo?.groups.filter((g: any) => g.name === group.name)[0]
213214
.email
214215
}
215216
key={group.name}
@@ -222,7 +223,7 @@ export const NewInsightProductForm = () => {
222223
]}
223224
</Select>
224225
<TeamkatalogenSelector
225-
gcpGroups={userInfo?.gcpProjects.map(it => it.group.email)}
226+
gcpGroups={userInfo?.gcpProjects.map((it: any) => it.group.email)}
226227
register={register}
227228
watch={watch}
228229
errors={errors}

components/lib/tagsSelector.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,35 @@ const useBuildTagOptionsList = () => {
6363
const userInfo = useContext(UserState)
6464
let tagsMap = new Map(
6565
userInfo?.dataproducts
66-
?.flatMap((it) => it.keywords)
67-
.map((it) => [it, 100000])
66+
?.flatMap((it: any) => it.keywords)
67+
.map((it: any) => [it, 100000])
6868
)
6969
if (!error) {
70-
data?.keywords.forEach((it) =>
70+
data?.keywords.forEach((it: any) =>
7171
tagsMap.set(it.keyword, it.count + (tagsMap.get(it.keyword) || 0))
7272
)
7373
}
7474
return Array.from(tagsMap.entries())
75-
.sort((l, r) => r[1] - l[1])
75+
.sort((l: any, r: any) => r[1] - l[1])
7676
.map((it) => it[0])
7777
}
7878

7979
export const TagsSelector = ({ onAdd, onDelete, tags }: TagsSelectorProps) => {
8080
let tagOptions = useBuildTagOptionsList()
8181
const userInfo = useContext(UserState)
8282
const teamNames = userInfo?.allGoogleGroups?.map(
83-
(it) => it.name.split('@')[0]
83+
(it: any) => it.name.split('@')[0]
8484
)
8585

8686
const tagsLikeTeamName = tags.filter((it) =>
87-
teamNames?.find((tn) => tn.toLocaleLowerCase() === it.toLocaleLowerCase())
87+
teamNames?.find((tn: any) => tn.toLocaleLowerCase() === it.toLocaleLowerCase())
8888
)
8989
const addNewTag = (text: string) => {
9090
//if there is a similar tag in the list, use it as the text
9191
const newTag = (
9292
tagOptions.find(
93-
(t) => t.toLocaleLowerCase() === text.toLocaleLowerCase()
94-
) ?? text
93+
(t: any) => t.toLocaleLowerCase() === text.toLocaleLowerCase()
94+
) as string ?? text
9595
).trim()
9696
onAdd(newTag)
9797
}
@@ -160,8 +160,8 @@ export const TagsSelector = ({ onAdd, onDelete, tags }: TagsSelectorProps) => {
160160
<CreatableSelect
161161
isMulti
162162
options={tagOptions.map((it) => ({
163-
value: it,
164-
label: it,
163+
value: it as string,
164+
label: it as string,
165165
}))}
166166
styles={styles}
167167
theme={theme}

components/productArea/content.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const ProductAreaContent = ({ currentItem, currentTab, setCurrentTab }: ProductA
112112
link={ip.link}
113113
id={ip.id}
114114
innsiktsproduktType={ip.type}
115-
editable={!!userInfo?.googleGroups?.find(it=> it.email == ip.group)}
115+
editable={!!userInfo?.googleGroups?.find((it: any)=> it.email == ip.group)}
116116
teamkatalogenTeam={ip.teamName}
117117
productArea={ip.productAreaName}
118118
/>

components/search/resultList.tsx

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { QueryResult } from '@apollo/client'
21
import ErrorMessage from '../lib/error'
32
import LoaderSpinner from '../lib/spinner'
43
import SearchResultLink from './searchResultLink'
54
import { Tabs } from '@navikt/ds-react'
65
import React, { useContext, useEffect, useState } from 'react'
76
import { SearchParam } from '../../pages/search'
8-
import { USER_INFO } from '../../lib/queries/userInfo/userInfo'
97
import { UserState } from '../../lib/context'
108
import { useSearchTeamKatalogen } from '../../lib/rest/teamkatalogen'
119
import { useGetProductAreas } from '../../lib/rest/productAreas'
@@ -65,11 +63,6 @@ const ResultList = ({
6563
variables: {
6664
id: id
6765
},
68-
refetchQueries: [
69-
{
70-
query: USER_INFO,
71-
}
72-
]
7366
})
7467

7568
const isDataProduct = (item: any) => !!item.datasets
@@ -89,7 +82,7 @@ const ResultList = ({
8982
}
9083

9184
if (search && !!searchParam) {
92-
const { data, loading, error } = search
85+
var { data, loading, error } = search
9386

9487
if (error) return <ErrorMessage error={error} />
9588
if (loading || !data) return <LoaderSpinner />
@@ -100,7 +93,6 @@ const ResultList = ({
10093
(d) => !isDataProduct(d.result)
10194
)
10295

103-
//dataproducts.forEach((d) => console.log(getTeamKatalogenInfo(d.result)?.teamkatalogenTeam))
10496
return (
10597
<Results>
10698
<Tabs
@@ -228,7 +220,7 @@ const ResultList = ({
228220
{...getTeamKatalogenInfo(p)}
229221
description={p.description}
230222
innsiktsproduktType={p.type}
231-
editable={!!userInfo?.googleGroups?.find(it => it.email == p.group)}
223+
editable={!!userInfo?.googleGroups?.find((it: any) => it.email == p.group)}
232224
/>
233225
))}
234226
</Results>

components/search/searchResultLink.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import humanizeDate from '../../lib/humanizeDate'
99
import DeleteModal from '../lib/deleteModal'
1010
import { useState } from 'react'
1111
import { useRouter } from 'next/router'
12-
import { USER_INFO } from '../../lib/queries/userInfo/userInfo'
1312
import TagPill from '../lib/tagPill'
1413

1514
export interface SearchResultProps {
@@ -72,11 +71,6 @@ export const SearchResultLink = ({
7271
variables:{
7372
id: id
7473
},
75-
refetchQueries:[
76-
{
77-
query: USER_INFO,
78-
}
79-
]
8074
})
8175
}
8276

components/stories/editStoryMetadata.tsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { useContext, useState } from 'react'
1616
import TagsSelector from '../lib/tagsSelector'
1717
import {UserState} from "../../lib/context";
1818
import { useUpdateStoryMetadataMutation } from '../../lib/schema/graphql'
19-
import { USER_INFO } from '../../lib/queries/userInfo/userInfo'
2019

2120
const schema = yup.object().shape({
2221
name: yup.string().nullable().required('Skriv inn navnet på datafortellingen'),
@@ -88,11 +87,6 @@ export const EditStoryMetadataForm = ({id, name, description, keywords, teamkata
8887
teamID: teamID,
8988
group: data.group,
9089
},
91-
refetchQueries:[
92-
{
93-
query: USER_INFO,
94-
}
95-
]
9690
}
9791

9892
updateStoryQuery(editStoryData).then(()=>{
@@ -123,6 +117,7 @@ export const EditStoryMetadataForm = ({id, name, description, keywords, teamkata
123117
})
124118
}
125119

120+
const gcpProjects = userInfo?.gcpProjects as any[] || []
126121

127122
return (
128123
<div className="mt-8 md:w-[46rem]">
@@ -155,11 +150,11 @@ export const EditStoryMetadataForm = ({id, name, description, keywords, teamkata
155150
<option value="">Velg gruppe</option>
156151
{[
157152
...new Set(
158-
userInfo?.gcpProjects.map(
153+
gcpProjects.map(
159154
({ group }: { group: { name: string } }) => (
160155
<option
161156
value={
162-
userInfo?.groups.filter((g) => g.name === group.name)[0]
157+
userInfo?.groups.filter((g: any) => g.name === group.name)[0]
163158
.email
164159
}
165160
key={group.name}
@@ -172,7 +167,7 @@ export const EditStoryMetadataForm = ({id, name, description, keywords, teamkata
172167
]}
173168
</Select>
174169
<TeamkatalogenSelector
175-
gcpGroups={userInfo?.gcpProjects.map(it=> it.group.email)}
170+
gcpGroups={userInfo?.gcpProjects.map((it: any)=> it.group.email)}
176171
register={register}
177172
watch={watch}
178173
errors={errors}

components/stories/newStory.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ export const NewStoryForm = () => {
230230
});
231231
};
232232

233+
const gcpProjects = userInfo?.gcpProjects as any[] || []
234+
233235
return (
234236
<div className="mt-8 md:w-[46rem]">
235237
<Heading level="1" size="large">
@@ -261,11 +263,11 @@ export const NewStoryForm = () => {
261263
<option value="">Velg gruppe</option>
262264
{[
263265
...new Set(
264-
userInfo?.gcpProjects.map(
266+
gcpProjects.map(
265267
({ group }: { group: { name: string } }) => (
266268
<option
267269
value={
268-
userInfo?.groups.filter((g) => g.name === group.name)[0]
270+
userInfo?.groups.filter((g: any) => g.name === group.name)[0]
269271
.email
270272
}
271273
key={group.name}
@@ -278,7 +280,7 @@ export const NewStoryForm = () => {
278280
]}
279281
</Select>
280282
<TeamkatalogenSelector
281-
gcpGroups={userInfo?.gcpProjects.map(it => it.group.email)}
283+
gcpGroups={userInfo?.gcpProjects.map((it: any) => it.group.email)}
282284
register={register}
283285
watch={watch}
284286
errors={errors}

0 commit comments

Comments
 (0)