Skip to content

Commit

Permalink
Merge branch 'main' into chore/format-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 4, 2024
2 parents 5e883df + 47df0c0 commit c007259
Show file tree
Hide file tree
Showing 116 changed files with 2,340 additions and 526 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/config-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
working-directory: infra
run: node -r esbuild-register src/secrets.ts get-all-required-secrets --env=${{ matrix.env }} >> LOCAL_SECRETS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DESCRIBE_SSM_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DESCRIBE_SSM_AWS_SECRET_ACCESS_KEY }}
Expand All @@ -156,7 +156,7 @@ jobs:
working-directory: infra

- name: Configure AWS Credentials for IDS Prod
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DESCRIBE_SSM_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DESCRIBE_SSM_AWS_SECRET_ACCESS_KEY }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
Expand Down Expand Up @@ -664,7 +664,7 @@ jobs:
run: '[[ ${{ needs.docker-build.result }} != "failure" ]] || exit 1'
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
.yarn
/infra/helm/
/.nx/cache
/.nx/workspace-data
/.nx/workspace-data
apps/web/public/assets/pdf.worker.min.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ export const MideindTranslationSidebar = () => {
isDisabled={loading}
style={{ width: '100%' }}
onClick={async () => {
const shouldContinue = await sdk.dialogs.openConfirm({
title: 'Are you sure?',
message:
'All english text fields will be replaced with a "Miðeind" translation',
})

if (!shouldContinue) {
return
}

setLoading(true)
await handleClick(sdk)
setLoading(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import { Box, FormControl, Text } from '@contentful/f36-components'

import { mapLocalesToFieldApis } from './utils'

export const ContentfulField = (props: {
export interface ContentfulFieldProps {
sdk: EditorExtensionSDK
localeToFieldMapping: Record<string, ReturnType<typeof mapLocalesToFieldApis>>
fieldID: keyof typeof props.localeToFieldMapping
fieldID: keyof ContentfulFieldProps['localeToFieldMapping']
displayName: string
widgetId?: string
helpText?: string
}) => {
}

export const ContentfulField = (props: ContentfulFieldProps) => {
const availableLocales = useMemo(() => {
const validLocales = props.sdk.locales.available.filter(
(locale) => props.localeToFieldMapping[props.fieldID]?.[locale],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { useEffect, useMemo, useState } from 'react'
import type { EntryProps, KeyValueMap } from 'contentful-management'
import dynamic from 'next/dynamic'
import type { EditorExtensionSDK } from '@contentful/app-sdk'
import { Box } from '@contentful/f36-components'
import { useCMA, useSDK } from '@contentful/react-apps-toolkit'

import { mapLocalesToFieldApis } from '../utils'
import { TeamMemberFilterTagsField } from './TeamMemberFilterTagsField'

const ContentfulField = dynamic(
() =>
// Dynamically import via client side rendering since the @contentful/default-field-editors package accesses the window and navigator global objects
import('../ContentfulField').then(({ ContentfulField }) => ContentfulField),
{
ssr: false,
},
)

const createField = (name: string, sdk: EditorExtensionSDK) => {
return mapLocalesToFieldApis(sdk.entry.fields[name].locales, sdk, name)
}

const createLocaleToFieldMapping = (sdk: EditorExtensionSDK) => {
return {
name: createField('name', sdk),
title: createField('title', sdk),
mynd: createField('mynd', sdk),
imageOnSelect: createField('imageOnSelect', sdk),
filterTags: createField('filterTags', sdk),
email: createField('email', sdk),
phone: createField('phone', sdk),
intro: createField('intro', sdk),
}
}

export const TeamMemberEditor = () => {
const sdk = useSDK<EditorExtensionSDK>()
const cma = useCMA()

const localeToFieldMapping = useMemo(() => {
return createLocaleToFieldMapping(sdk)
}, [sdk])

const [teamList, setTeamList] = useState<EntryProps<KeyValueMap>>()

useEffect(() => {
const fetchTeamList = async () => {
const teamLists = await cma.entry.getMany({
query: {
content_type: 'teamList',
links_to_entry: sdk.entry.getSys().id,
},
})
if (teamLists.items.length > 0) setTeamList(teamLists.items[0])
}

fetchTeamList()
}, [cma.entry, sdk.entry])

const teamListIsAccordionVariant =
teamList?.fields?.variant?.[sdk.locales.default] === 'accordion'

return (
<Box
paddingLeft="spacingS"
paddingRight="spacingS"
paddingTop="spacingL"
paddingBottom="spacingL"
style={{
display: 'flex',
flexFlow: 'column nowrap',
gap: '16px',
margin: '0 auto',
maxWidth: '768px',
}}
>
<ContentfulField
displayName="Name"
fieldID="name"
localeToFieldMapping={localeToFieldMapping}
sdk={sdk}
/>
<ContentfulField
displayName="Title"
fieldID="title"
localeToFieldMapping={localeToFieldMapping}
sdk={sdk}
/>

<ContentfulField
displayName="Image"
fieldID="mynd"
localeToFieldMapping={localeToFieldMapping}
sdk={sdk}
widgetId="assetLinkEditor"
/>

<ContentfulField
displayName="Image on hover"
fieldID="imageOnSelect"
localeToFieldMapping={localeToFieldMapping}
sdk={sdk}
widgetId="assetLinkEditor"
helpText="Leave empty unless there is a .gif that displays the person pronouncing their name in sign language"
/>
{teamListIsAccordionVariant && (
<Box>
<ContentfulField
displayName="Email"
fieldID="email"
localeToFieldMapping={localeToFieldMapping}
sdk={sdk}
/>
<ContentfulField
displayName="Phone"
fieldID="phone"
localeToFieldMapping={localeToFieldMapping}
sdk={sdk}
/>
<ContentfulField
displayName="Free text"
fieldID="intro"
localeToFieldMapping={localeToFieldMapping}
sdk={sdk}
widgetId="richTextEditor"
/>
</Box>
)}
<TeamMemberFilterTagsField sdk={sdk} />
</Box>
)
}
Loading

0 comments on commit c007259

Please sign in to comment.