Skip to content

Commit

Permalink
Merge branch 'main' into chore/remove-old-feature-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 18, 2024
2 parents fb09683 + 4922c4f commit 415803a
Show file tree
Hide file tree
Showing 402 changed files with 10,673 additions and 4,768 deletions.
2 changes: 2 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Empty config file so defaults will be respected instead of users' own global config
# (prevent directory traversal)
7 changes: 0 additions & 7 deletions apps/air-discount-scheme/api/infra/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ export const serviceSetup = (services: {
staging: ['loftbru', 'loftbru-cf'],
prod: ['loftbru'],
},
extraAnnotations: {
dev: {},
staging: {},
prod: {
'nginx.ingress.kubernetes.io/enable-global-auth': 'false',
},
},
paths: ['/api/graphql'],
public: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export const serviceSetup = (): ServiceBuilder<'air-discount-scheme-backend'> =>
staging: {
'nginx.ingress.kubernetes.io/enable-global-auth': 'false',
},
prod: {
'nginx.ingress.kubernetes.io/enable-global-auth': 'false',
},
prod: {},
},
paths: ['/api/swagger', '/api/public'],
},
Expand Down
7 changes: 0 additions & 7 deletions apps/api/infra/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,6 @@ export const serviceSetup = (services: {
prod: ['', 'www.island.is'],
},
paths: ['/api'],
extraAnnotations: {
dev: {},
staging: {
'nginx.ingress.kubernetes.io/enable-global-auth': 'false',
},
prod: {},
},
public: true,
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export class TemplateApiApplicationService extends BaseTemplateApiApplicationSer
const s3key = `${application.id}/${attachmentKey}`
const url = await this.awsService.uploadFile(
buffer,
uploadBucket,
s3key,
{ bucket: uploadBucket, key: s3key },
uploadParameters,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const serviceSetup = (services: {
'nginx.ingress.kubernetes.io/proxy-buffer-size': '8k',
},
staging: {
'nginx.ingress.kubernetes.io/enable-global-auth': 'false',
'nginx.ingress.kubernetes.io/proxy-buffering': 'on',
'nginx.ingress.kubernetes.io/proxy-buffer-size': '8k',
},
Expand Down
39 changes: 39 additions & 0 deletions apps/consultation-portal/components/svg/RSSFeedIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react'

const RSSIcon = (
props: React.JSX.IntrinsicAttributes & React.SVGProps<SVGSVGElement>,
) => {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
enableBackground="new 0 0 512 512"
version="1.1"
viewBox="0 0 512 512"
xmlSpace="preserve"
{...props}
>
<g>
<rect
width="512"
height="512"
x="-512"
y="-512"
fill="#ea7819"
fillOpacity="1"
stroke="none"
rx="70"
ry="70"
transform="scale(-1)"
></rect>
<path
fill="#fff"
d="M81.056 267.05c43.705 0 84.79 17.072 115.665 48.124 30.931 31.051 47.961 72.411 47.961 116.44h67.35c0-127.885-103.62-231.921-230.976-231.921v67.357zm.106-119.4c155.76 0 282.488 127.42 282.488 284.049H431C431 237.925 274.054 80.301 81.162 80.301v67.35zm93.135 236.998c0 25.757-20.892 46.649-46.649 46.649-25.756 0-46.648-20.885-46.648-46.649C81 358.878 101.885 338 127.641 338c25.757 0 46.656 20.878 46.656 46.648z"
></path>
</g>
</svg>
)
}

export default RSSIcon
1 change: 1 addition & 0 deletions apps/consultation-portal/components/svg/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as HeroImage } from './HeroImage'
export { default as RSSIcon } from './RSSFeedIcon'
1 change: 0 additions & 1 deletion apps/consultation-portal/infra/samradsgatt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const serviceSetup = (services: {
'nginx.ingress.kubernetes.io/proxy-buffer-size': '8k',
},
staging: {
'nginx.ingress.kubernetes.io/enable-global-auth': 'false',
'nginx.ingress.kubernetes.io/proxy-buffering': 'on',
'nginx.ingress.kubernetes.io/proxy-buffer-size': '8k',
},
Expand Down
61 changes: 61 additions & 0 deletions apps/consultation-portal/pages/api/rss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { NextApiRequest } from 'next'
import initApollo from '../../graphql/client'
import { SUB_GET_CASES } from '../../graphql/queries.graphql'
import { SubGetCasesQuery } from '../../graphql/queries.graphql.generated'
import { SUB_PAGE_SIZE, SUB_STATUSES_TO_FETCH } from '../../utils/consts/consts'

type CaseItem = {
id?: number | null
caseNumber?: string | null
name?: string | null
institutionName?: string | null
policyAreaName?: string | null
}

export default async function handler(req: NextApiRequest, res) {
const client = initApollo()
try {
const {
data: { consultationPortalGetCases },
} = await client.query<SubGetCasesQuery>({
query: SUB_GET_CASES,
variables: {
input: {
caseStatuses: SUB_STATUSES_TO_FETCH,
pageSize: SUB_PAGE_SIZE,
},
},
})

const host: string = req.headers.host
const protocol = `http${host.startsWith('localhost') ? '' : 's'}://`
const baseUrl = `${protocol}${host}`

const getCases = (post: CaseItem) => {
return `<item>
<title>${post.name}</title>
<description>${post.name}</description>
<link>${baseUrl}/samradsgatt/mal/${post.id}</link>
</item>`
}

const feed = `<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Samráðsgátt - Áskriftir RSS Veita</title>
<description>Island.is</description>
${consultationPortalGetCases.cases.map((i) => getCases(i)).join('')}
</channel>
</rss>`

res.set('Content-Type', 'text/xml;charset=UTF-8')
return res.status(200).send(feed)
} catch (error) {
if (error.networkError) {
res.status(500).send('Network error')
return
} else {
res.status(500).send('Internal Server Error')
}
}
}
2 changes: 1 addition & 1 deletion apps/consultation-portal/screens/Case/Case.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"failure": "Ekki tókst á afskrá áskrift fyrir mál"
},
"loginCardSkeleton": {
"text": "Þú þarft að skrá þig inn á island.is til þess að geta skráð þig í eða úr áskrift.",
"text": "Þú þarft að skrá þig inn á Island.is til þess að geta skráð þig í eða úr áskrift.",
"button": "Skrá mig inn"
},
"setEmailCardSkeleton": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
"text": " Hægt er að afskrá sig hér",
"href": "/minaraskriftir"
},
"rssFeedSubscription": {
"description": "Áskrift að RSS veitir þér aðgang að nýjustu málum í Samráðsgátt.",
"text": "Hér er hægt að skrá sig í áskrift að RSS veitu"
},
"tabsLabel": "Veldu tegund áskrifta"
},
"subscriptionTable": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Link from 'next/link'
import { useUser } from '../../../../hooks/useUser'
import localization from '../../Subscriptions.json'
import { useFetchEmail, useIsMobile } from '../../../../hooks'
import { RSSIcon } from '../../../../components/svg'

interface Props {
children: ReactNode
Expand All @@ -28,6 +29,7 @@ interface Props {
const loc = localization['subscriptionSkeleton']
const locSubs = loc['subscriptions']
const locMySubs = loc['mySubscriptions']
const locRss = loc['rssFeedSubscription']

const BREADCRUMBS_LIST = [
{ title: loc.breadcrumbs[0].title, href: loc.breadcrumbs[0].href },
Expand Down Expand Up @@ -135,6 +137,15 @@ const SubscriptionsSkeleton = ({
<></>
)}
</Box>
<Stack space={1}>
<Box display="flex" alignItems="center" columnGap={1}>
<Text variant="default">{locRss.text}</Text>
<Link href="/api/rss" target="_blank">
<RSSIcon />
</Link>
</Box>
<Text variant="small">{locRss.description}</Text>
</Stack>
</GridContainer>
</Layout>
)
Expand Down
7 changes: 0 additions & 7 deletions apps/contentful-apps/infra/contentful-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ export const serviceSetup = (): ServiceBuilder<'contentful-apps'> =>
prod: 'contentful-apps',
},
paths: ['/'],
extraAnnotations: {
dev: {
'nginx.ingress.kubernetes.io/enable-global-auth': 'false',
},
staging: {},
prod: {},
},
},
})
.replicaCount({
Expand Down
149 changes: 149 additions & 0 deletions apps/contentful-apps/pages/fields/project-subpage-slug-field.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { useEffect, useRef, useState } from 'react'
import { useDebounce } from 'react-use'
import type { EntryProps } from 'contentful-management'
import { FieldExtensionSDK } from '@contentful/app-sdk'
import { Stack, Text, TextInput } from '@contentful/f36-components'
import { useCMA, useSDK } from '@contentful/react-apps-toolkit'
import slugify from '@sindresorhus/slugify'

const DEBOUNCE_TIME = 100

const ProjectSubpageSlugField = () => {
const sdk = useSDK<FieldExtensionSDK>()
const cma = useCMA()
const [value, setValue] = useState(sdk.field?.getValue() ?? '')
const [isValid, setIsValid] = useState(true)
const [projectPage, setProjectPage] = useState<EntryProps | null>(null)
const initialTitleChange = useRef(true)
const [hasEntryBeenPublished, setHasEntryBeenPublished] = useState(
Boolean(sdk.entry.getSys()?.firstPublishedAt),
)

const defaultLocale = sdk.locales.default

useEffect(() => {
const fetchProjectPage = async () => {
const response = await cma.entry.getMany({
query: {
links_to_entry: sdk.entry.getSys().id,
content_type: 'projectPage',
'sys.archivedVersion[exists]': false,
limit: 1,
},
})
if (response.items.length > 0) {
setProjectPage(response.items[0])
}
}
fetchProjectPage()
}, [cma.entry, sdk.entry])

useEffect(() => {
sdk.entry.onSysChanged((newSys) => {
setHasEntryBeenPublished(Boolean(newSys?.firstPublishedAt))
})
}, [sdk.entry])

// Update slug field if the title field changes
useEffect(() => {
return sdk.entry.fields.title
.getForLocale(sdk.field.locale)
.onValueChanged((newTitle) => {
if (hasEntryBeenPublished) {
return
}

// Callback gets called on initial render, so we want to ignore that
if (initialTitleChange.current) {
initialTitleChange.current = false
return
}

if (newTitle) {
setValue(slugify(String(newTitle)))
}
})
}, [hasEntryBeenPublished, sdk.entry.fields.title, sdk.field.locale])

useEffect(() => {
sdk.window.startAutoResizer()
}, [sdk.window])

// Validate the user input
useDebounce(
async () => {
if (!projectPage) {
setIsValid(true)
return
}

const subpageIds: string[] =
projectPage?.fields?.projectSubpages?.[defaultLocale]?.map(
(subpage) => subpage.sys.id,
) ?? []

const subpagesWithSameSlug = (
await cma.entry.getMany({
query: {
locale: sdk.field.locale,
content_type: 'projectSubpage',
'fields.slug': value,
'sys.id[ne]': sdk.entry.getSys().id,
'sys.archivedVersion[exists]': false,
limit: 1000,
select: 'sys',
},
})
).items

const subpageExistsWithSameSlug = subpagesWithSameSlug.some((subpage) =>
subpageIds.includes(subpage.sys.id),
)

if (subpageExistsWithSameSlug) {
setIsValid(false)
return
}
setIsValid(true)
},
DEBOUNCE_TIME,
[value, projectPage],
)

useDebounce(
() => {
if (isValid) {
sdk.field.setValue(value)
} else {
sdk.field.setValue(null) // Set to null to prevent entry publish
}
sdk.field.setInvalid(!isValid)
},
DEBOUNCE_TIME,
[isValid, value],
)

const isInvalid = value.length === 0 || !isValid

return (
<Stack spacing="spacingXs" flexDirection="column" alignItems="flex-start">
<TextInput
value={value}
onChange={(ev) => {
setValue(ev.target.value)
}}
isInvalid={isInvalid}
/>
{value.length === 0 && sdk.field.locale === defaultLocale && (
<Text fontColor="red400">Invalid slug</Text>
)}
{value.length > 0 && isInvalid && (
<Text fontColor="red400">
Project subpage already exists with this slug
</Text>
)}
</Stack>
)
}

export default ProjectSubpageSlugField
Loading

0 comments on commit 415803a

Please sign in to comment.