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

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/follow-redirects-1.15.4
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvatt authored Jan 15, 2024
2 parents 4a635fe + b94b7ad commit 46aaad4
Show file tree
Hide file tree
Showing 41 changed files with 9,592 additions and 16,897 deletions.
34 changes: 0 additions & 34 deletions components/lib/storySelector.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions components/lib/tokenModal.tsx

This file was deleted.

28 changes: 5 additions & 23 deletions components/productArea/content.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Tabs } from "@navikt/ds-react";
import { PAItem } from "../../pages/productArea/[id]";
import SearchResultLink from "../search/searchResultLink";
import { Story, useProductAreasQuery, useTeamkatalogenQuery, useUserInfoDetailsQuery } from "../../lib/schema/graphql";
import { owner } from "../../lib/schema/yupValidations";
import { useProductAreasQuery, useTeamkatalogenQuery } from "../../lib/schema/graphql";
import { useContext } from "react";
import { UserState } from "../../lib/context";

Expand All @@ -12,27 +11,10 @@ interface ProductAreaContentProps {
setCurrentTab: React.Dispatch<React.SetStateAction<string>>
}

interface UnifiedStory{
__typename?: "Story" | "QuartoStory" | undefined
id: string
name: string
created: any
keywords: string[]
description?: string
lastModified?: any
owner?: {
__typename?: "Owner" | undefined;
group: string;
teamkatalogenURL?: string;
}
}

const ProductAreaContent = ({ currentItem, currentTab, setCurrentTab }: ProductAreaContentProps) => {
const tk = useTeamkatalogenQuery({
variables: { q: '' },
})
var allStories = currentItem.stories.map(it=> it as UnifiedStory)
.concat(currentItem.quartoStories.map(it=> it as UnifiedStory))
const po = useProductAreasQuery()
const userInfo= useContext(UserState)

Expand All @@ -50,7 +32,7 @@ const ProductAreaContent = ({ currentItem, currentTab, setCurrentTab }: ProductA
/>}
<Tabs.Tab
value="stories"
label={`Fortellinger (${allStories.length})`}
label={`Fortellinger (${currentItem.stories.length})`}
/>
<Tabs.Tab
value="products"
Expand All @@ -76,7 +58,7 @@ const ProductAreaContent = ({ currentItem, currentTab, setCurrentTab }: ProductA
className="h-full w-full py-4"
>
<div className="flex flex-col gap-2">
{allStories && allStories.map((s: any, idx: number) => (
{currentItem.stories && currentItem.stories.map((s: any, idx: number) => (
<SearchResultLink
resourceType="datafortelling"
key={idx}
Expand All @@ -87,13 +69,13 @@ const ProductAreaContent = ({ currentItem, currentTab, setCurrentTab }: ProductA
name={s.name}
description={s.description ? s.description : undefined}
keywords={s.keywords}
link={`${s.__typename === 'Story'? '/story/' : '/quarto/'}${s.id}`}
link={`/story/${s.id}`}
type={s.__typename}
teamkatalogen={tk.data}
productAreas={po.data}
/>
))}
{allStories.length == 0 && "Ingen fortellinger"}
{currentItem.stories.length == 0 && "Ingen fortellinger"}
</div>
</Tabs.Panel>
<Tabs.Panel
Expand Down
7 changes: 3 additions & 4 deletions components/productArea/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const ProductAreaSidebar = ({
(it) =>
it.dataproducts.length ||
it.stories.length ||
it.quartoStories.length ||
it.insightProducts.length
).sort((l, r) => (l.name < r.name ? -1 : 1))
return (
Expand All @@ -48,7 +47,7 @@ const ProductAreaSidebar = ({
</Select>
<div className="flex text-base w-full flex-col gap-2">
{productAreaItems.map((d: any, idx: number) =>
d.stories.length + d.quartoStories.length + d.dataproducts.length + d.insightProducts.length ? (
d.stories.length + d.dataproducts.length + d.insightProducts.length ? (
<div
key={idx}
className={`border-l-[6px] py-1 px-2 hover:cursor-default ${
Expand All @@ -70,7 +69,7 @@ const ProductAreaSidebar = ({
aria-label="datafortellinger"
className="text-text-subtle"
/>{' '}
{d.stories.length + d.quartoStories.length}
{d.stories.length}
</span>
<span className="flex gap-2 items-center">
<div className="h-[14px] w-[14px] text-text-subtle">
Expand Down Expand Up @@ -102,7 +101,7 @@ const ProductAreaSidebar = ({
aria-label="datafortellinger"
className="text-text-subtle"
/>{' '}
{d.stories.length + d.quartoStories.length}
{d.stories.length}
</span>
<span className="flex gap-2 items-center">
<div className="h-[18px] w-[18px] text-text-subtle">
Expand Down
61 changes: 12 additions & 49 deletions components/search/resultList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Exact,
SearchContentWithOptionsQuery,
SearchOptions,
useDeleteQuartoStoryMutation,
useDeleteStoryMutation,
useProductAreasQuery,
useTeamkatalogenQuery,
} from '../../lib/schema/graphql'
Expand Down Expand Up @@ -38,13 +38,6 @@ type ResultListInterface = {
__typename?: 'Story'
id: string
name: string
keywords?: string[]
owner?: { __typename?: 'Owner'; group: string } | null | undefined
}[]
quartoStories?: {
__typename?: 'QuartoStory'
id: string
name: string
group: string
keywords?: string[]
teamkatalogenURL?: string | null | undefined
Expand All @@ -68,7 +61,6 @@ const ResultList = ({
search,
dataproducts,
stories,
quartoStories,
insightProducts,
searchParam,
updateQuery,
Expand Down Expand Up @@ -96,9 +88,9 @@ const ResultList = ({
})

const po = useProductAreasQuery()
const [deleteQuartoQuery] = useDeleteQuartoStoryMutation()
const [deleteStoryQuery] = useDeleteStoryMutation()
const userInfo= useContext(UserState)
const deleteQuarto = (id: string) => deleteQuartoQuery({
const deleteStory = (id: string) => deleteStoryQuery({
variables:{
id: id
},
Expand All @@ -120,9 +112,6 @@ const ResultList = ({
const datastories = data.search.filter(
(d) => d.result.__typename === 'Story'
)
const quartostories = data.search.filter(
(d)=> d.result.__typename === 'QuartoStory'
)

return (
<Results>
Expand All @@ -137,7 +126,7 @@ const ResultList = ({
<Tabs.List>
<Tabs.Tab
value="story"
label={`Fortellinger (${datastories.length + quartostories.length})`}
label={`Fortellinger (${datastories.length})`}
/>
<Tabs.Tab
value="dataproduct"
Expand All @@ -146,31 +135,16 @@ const ResultList = ({
</Tabs.List>
<Tabs.Panel className="flex flex-col pt-4 gap-4" value="story">
{datastories.map(
(d, idx) =>
d.result.__typename === 'Story' && (
<SearchResultLink
key={idx}
group={d.result.group!}
name={d.result.name}
type={'story'}
keywords={d.result.keywords}
description={d.excerpt}
link={`/story/${d.result.id}`}
teamkatalogen={tk.data}
productAreas={po.data}
/>
)
).concat(quartostories.map(
(it, idx)=>
(
it.result.__typename ==='QuartoStory' && (
it.result.__typename ==='Story' && (
<SearchResultLink
key={idx}
name={it.result.name}
type={'story'}
keywords={it.result.keywords}
description={it.excerpt}
link={`/quarto/${it.result.id}`}
link={`/story/${it.result.id}`}
group={{
group: it.result.groupName,
teamkatalogenURL: it.result.teamkatalogenURL,
Expand All @@ -181,7 +155,7 @@ const ResultList = ({
)
)

))}
)}
</Tabs.Panel>
<Tabs.Panel className="flex flex-col gap-4" value="dataproduct">
{dataproducts.map(
Expand Down Expand Up @@ -224,11 +198,11 @@ const ResultList = ({
)
}

if (stories || quartoStories) {
if (stories) {
return (
<div>
<Results>
{quartoStories?.map((s, idx) => (
{stories?.map((s, idx) => (
<SearchResultLink
key={idx}
group={{
Expand All @@ -237,25 +211,14 @@ const ResultList = ({
}}
id={s.id}
name={s.name}
resourceType={"Quarto fortelling"}
link={`/quarto/${s.id}`}
resourceType={"datafortelling"}
link={`/story/${s.id}`}
teamkatalogen={tk.data}
productAreas={po.data}
keywords={s.keywords}
editable = {true}
description= {s.description}
deleteResource = {deleteQuarto}
/>
))}
{stories?.map((s, idx) => (
<SearchResultLink
key={idx}
group={s.owner}
name={s.name}
keywords={s.keywords}
link={`/story/${s.id}`}
teamkatalogen={tk.data}
productAreas={po.data}
deleteResource = {deleteStory}
/>
))}
</Results>
Expand Down
8 changes: 4 additions & 4 deletions components/search/searchResultLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Detail, Heading, Link } from '@navikt/ds-react'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { CoApplicant, Table } from '@navikt/ds-icons'
import { ProductAreasQuery, TeamkatalogenQuery, useDeleteInsightProductMutation, useDeleteQuartoStoryMutation } from '../../lib/schema/graphql'
import { ProductAreasQuery, TeamkatalogenQuery, useDeleteInsightProductMutation, useDeleteStoryMutation } from '../../lib/schema/graphql'
import humanizeDate from '../../lib/humanizeDate'
import DeleteModal from '../lib/deleteModal'
import { useState } from 'react'
Expand Down Expand Up @@ -63,8 +63,8 @@ export const SearchResultLink = ({
const [deleteInsightProductMutation] = useDeleteInsightProductMutation();

const editResource = () => {
if (resourceType == 'Quarto fortelling') {
router.push(`/quarto/${id}/edit`)
if (resourceType == 'datafortelling') {
router.push(`/story/${id}/edit`)
} else if (resourceType == 'innsiktsprodukt') {
router.push(`/insightProduct/edit?id=${id}`)
}
Expand Down Expand Up @@ -122,7 +122,7 @@ export const SearchResultLink = ({
</div>
{editable && <div>
<Link className="m-2" href="#" onClick={editResource}
>Endre beskrivelse</Link>
>Endre metadata</Link>
<Link className='m-2' href="#" onClick={openDeleteModal}>Slett</Link>
</div>}
</div>
Expand Down
Loading

0 comments on commit 46aaad4

Please sign in to comment.