Skip to content

Commit

Permalink
Merge branch 'main' into bose/2547
Browse files Browse the repository at this point in the history
  • Loading branch information
BorghildSelle committed Oct 16, 2024
2 parents 1cb8255 + 8075a2a commit aecb7a5
Show file tree
Hide file tree
Showing 47 changed files with 335 additions and 738 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/DEV-studio-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/upgradeEnvironment.py studio ${{ env.IMAGE_TAG_SHA }} ${{ secrets.ENV }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PREPROD-studios-v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/upgradeEnvironment.py studio ${{ env.IMAGE_TAG_SHA }} ${{ secrets.ENV }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PREPROD-webs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/upgradeEnvironment.py web ${{ env.IMAGE_TAG_SHA }} ${{ secrets.ENV }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PROD-all-studios-v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/promoteAllToProduction.py studio
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PROD-all-webs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/promoteAllToProduction.py web
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PROD-studios-selected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/promoteToProduction.py studio ${{ github.event.inputs.site }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PROD-webs-rollback.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ jobs:
shell: bash
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/upgradeEnvironment.py web ${{ github.event.inputs.image-sha }} ${{ secrets.ENV }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/PROD-webs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/promoteToProduction.py web ${{ github.event.inputs.site }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/TEST-studio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/upgradeEnvironment.py studio ${{ env.IMAGE_TAG_SHA }} ${{ secrets.ENV }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/TEST-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ jobs:
id: modify-radix
run: |
# Install pre-requisite
python -m pip install --user ruamel.yaml
python3 -m venv venv
source venv/bin/activate
python -m pip install ruamel.yaml
python ci/upgradeEnvironment.py web ${{ env.IMAGE_TAG_SHA }} ${{ secrets.ENV }}
git config --global user.name 'github'
git config --global user.email '[email protected]'
Expand Down
7 changes: 2 additions & 5 deletions sanityv3/actions/fieldActions/CustomCopyFieldAction.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { CopyIcon } from '@sanity/icons'
import { Toast, useToast } from '@sanity/ui'
import { useToast } from '@sanity/ui'
import { useCallback } from 'react'

import { defineDocumentFieldAction } from 'sanity'
import { useTranslation } from 'sanity'
import { useCopyPaste } from 'sanity'
import { useGetFormValue } from 'sanity'
import { defineDocumentFieldAction, useTranslation, useCopyPaste, useGetFormValue } from 'sanity'
import { type FormDocumentValue } from 'sanity'

export const copyAction = defineDocumentFieldAction({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { useEffect, useCallback, forwardRef, useState, useRef } from 'react'
import { createPortal } from 'react-dom'
import { Dialog } from '@sanity/ui'
import styled from 'styled-components'

const BM_EVENT_NAME = 'dam:plugin-assets-selected-event'
const BM_URL = process.env.SANITY_STUDIO_BRANDMASTER_URL || ''
const BM_SOURCE = BM_URL + process.env.SANITY_STUDIO_BRANDMASTER_PLUGIN_SOURCE || ''

const Content = styled.div`
margin: 2em;
`

const BrandmasterAssetSource = forwardRef<HTMLDivElement>((props: any, ref) => {
const { onSelect, onClose } = props

Expand Down Expand Up @@ -81,17 +76,17 @@ const BrandmasterAssetSource = forwardRef<HTMLDivElement>((props: any, ref) => {
{container && createPortal(props.children, container)}

{BM_SOURCE ? (
<Content>
<div style={{ margin: '32px' }}>
<p>Select an image from Brandmaster in the popup window.</p>
<p>Once selected, the upload process should start automatically.</p>
</Content>
</div>
) : (
<Content>
<div style={{ margin: '32px' }}>
<p>
No Brandmaster source URL found. Please define the URL and path in the enviromental variables to load the
iframe.
</p>
</Content>
</div>
)}
</Dialog>
)
Expand Down
2 changes: 1 addition & 1 deletion sanityv3/plugins/asset-source-fotoware/src/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const FotowareWidget = forwardRef<HTMLDivElement, FotowareWidgetProps>((p
ref={ref}
>
<Content>
<StyledIframe src={url} title="Fotoware" frameBorder="0" ref={iframeRef}></StyledIframe>
<StyledIframe src={url} title="Fotoware" ref={iframeRef}></StyledIframe>
</Content>
</FullScreenDialog>
)
Expand Down
3 changes: 1 addition & 2 deletions sanityv3/sanity.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
PluginOptions,
SchemaTypeDefinition,
Template,
} from 'sanity'
buildLegacyTheme } from 'sanity'

import type {
InputProps,
Expand Down Expand Up @@ -39,7 +39,6 @@ import { createCustomDuplicateAction } from './actions/CustomDuplicateAction'
import { LangBadge } from './schemas/components/LangBadge'
import './customStyles.css'
import { partialStudioTheme } from './studioTheme'
import { buildLegacyTheme } from 'sanity'
import { copyAction } from './actions/fieldActions/CustomCopyFieldAction'

export const customTheme = buildLegacyTheme(partialStudioTheme)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Text, Card, Grid, Stack, Heading, Radio, Inline, Flex, Switch, TextInput } from '@sanity/ui'
import { Text, Card, Grid, Stack, Heading, Radio, Inline, Flex, Switch } from '@sanity/ui'
import { set, MemberField } from 'sanity'
import { getObjectMemberField } from '../utils/getObjectMemberField'
import type { ObjectInputProps } from 'sanity'
Expand Down
13 changes: 10 additions & 3 deletions sanityv3/schemas/documents/localNews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,21 @@ export default {
media: 'heroImage.image',
description: 'ingress',
publishedDate: 'publishDateTime',
firstPublishedAt: 'firstPublishedAt',
isCustomDate: 'customPublicationDate',
},
prepare(selection: any) {
const { title, media, description, publishedDate } = selection
const date = publishedDate ? formatDate(publishedDate) : 'Ikke oppgitt'
const { title, media, description, publishedDate, firstPublishedAt, isCustomDate } = selection
const currentDate = new Date()
const date =
publishedDate && isCustomDate ? new Date(publishedDate) : firstPublishedAt ? new Date(firstPublishedAt) : null

const displayDate = date && date <= currentDate ? formatDate(date) : 'Not Published'

const ingressBlock = (description || []).find((ingressBlock: any) => ingressBlock._type === 'block')
return {
title,
subtitle: `Published date: ${date}`,
subtitle: `Published date: ${displayDate}`,
description: ingressBlock
? ingressBlock.children
.filter((child: any) => child._type === 'span')
Expand Down
14 changes: 5 additions & 9 deletions sanityv3/schemas/documents/localNewsTag.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import { languages } from '../../languages'
import type { CurrentUser } from 'sanity'
import styled from 'styled-components'
import { EdsIcon } from '../../icons'
import { tag_more } from '@equinor/eds-icons'

const StyledSpan = styled.span`
display: block;
margin-top: 0.5em;
`

const LocalNewsTagDescription = () => (
<>
<StyledSpan>The translated names used to display the tag on the web and generate the slugs.</StyledSpan>
<StyledSpan>
<span style={{ display: 'block', marginTop: '8px' }}>
The translated names used to display the tag on the web and generate the slugs.
</span>
<span style={{ display: 'block', marginTop: '8px' }}>
<span role="img" aria-label="warning icon">
⚠️
</span>{' '}
Since these values are used to automatically generate slugs; they should only be changed if you know what you are
doing.
</StyledSpan>
</span>
</>
)

Expand Down
12 changes: 6 additions & 6 deletions sanityv3/schemas/documents/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ export default {
},
prepare(selection) {
const { title, media, description, publishedDate, firstPublishedAt, isCustomDate } = selection
const currentDate = new Date()
const date =
publishedDate && isCustomDate
? formatDate(publishedDate)
: firstPublishedAt
? formatDate(firstPublishedAt)
: 'Not Published'
publishedDate && isCustomDate ? new Date(publishedDate) : firstPublishedAt ? new Date(firstPublishedAt) : null

const displayDate = date && date <= currentDate ? formatDate(date) : 'Not Published'

const ingressBlock = (description || []).find((ingressBlock) => ingressBlock._type === 'block')
return {
title,
subtitle: `Published date: ${date}`,
subtitle: `Published date: ${displayDate}`,
description: ingressBlock
? ingressBlock.children
.filter((child) => child._type === 'span')
Expand Down
27 changes: 25 additions & 2 deletions sanityv3/schemas/documents/news/sharedNewsFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,34 @@ export const publishDateTime = [
validation: (Rule: Rule) =>
Rule.custom((value: PublishDateTimeType, context: ValidationContext) => {
const { parent } = context as { parent: PublishDateTimeType }
if (!parent.customPublicationDate || value) {
// If customPublicationDate is false, skip validation
if (!parent.customPublicationDate) {
return true
} else {
}

// If customPublicationDate is true and no value is provided, return an error
if (!value) {
return 'Field is required'
}

// Parse the selected publish date and today's date
const publishedDate = new Date(value.toString())
const today = new Date()

// Set time to 00:00:00 for both dates, so only the date part is compared
const publishedDateNoTime = new Date(
publishedDate.getFullYear(),
publishedDate.getMonth(),
publishedDate.getDate(),
)
const todayNoTime = new Date(today.getFullYear(), today.getMonth(), today.getDate())

// Allow publication if the selected date is today or in the past
if (publishedDateNoTime <= todayNoTime) {
return true // Valid date
} else {
return 'The date can’t be in the future'
}
}),
},
{
Expand Down
9 changes: 0 additions & 9 deletions sanityv3/schemas/editors/blockContentType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ export const ExtraLargeTextRender = (props: any) => {
const { children } = props
return <span style={{ fontSize: `${em(56, 16)}`, fontWeight: '600' }}>{children}</span>
}
const Level2BaseStyle = (props: any) => {
const { children } = props
return <h2 style={{ fontSize: `${em(18, 16)}`, fontWeight: '600' }}>{children} </h2>
}

const Level3BaseStyle = (props: any) => {
const { children } = props
return <h3 style={{ fontSize: `${em(16, 16)}`, fontWeight: '600' }}>{children} </h3>
}

// H1 not allowed in block content since it should be a document title.
export const configureBlockContent = (options: BlockContentProps = {}): BlockDefinition => {
Expand Down
9 changes: 2 additions & 7 deletions sanityv3/schemas/objects/anchorLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@ import { Rule } from 'sanity'
import { validateComponentAnchor } from '../validations/validateAnchorReference'
import { EdsIcon } from '../../icons'
import { Heading, Text, Box } from '@sanity/ui'
import styled from 'styled-components'

export type AnchorLink = {
_type: 'anchorLink'
}

const StyledText = styled(Text)`
margin: 1em 0;
`

const Description = () => {
return (
<Box>
<Heading size={2}>How to use</Heading>
<StyledText>
<Text style={{ margin: '1em 0' }}>
Add this component before the component for which you want to have an anchor reference. The anchor reference
will be ignored when there is no component following it.
</StyledText>
</Text>
</Box>
)
}
Expand Down
22 changes: 10 additions & 12 deletions sanityv3/schemas/objects/anchorReferenceField.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { validateAnchorReference } from '../validations/validateAnchorReference'
import styled from 'styled-components'
import { Rule } from 'sanity'

const StyledSpan = styled.span`
display: block;
margin-top: 0.3em;
`

export const AnchorComponentDescription = () => (
<>
<StyledSpan>Add an optional anchor reference that can be used to link directly to this component.</StyledSpan>
<StyledSpan>
<span style={{ display: 'block', marginTop: '4.8px' }}>
Add an optional anchor reference that can be used to link directly to this component.
</span>
<span style={{ display: 'block', marginTop: '4.8px' }}>
Allowed characters are: letters, numbers, hyphens, and underscores. The # symbol is not needed.
</StyledSpan>
</span>
</>
)

export const AnchorLinkDescription = () => (
<>
<StyledSpan>Optional: add the anchor reference of the component/section you want to link directly to.</StyledSpan>
<StyledSpan>Results cannot be guaranteed for external URLs.</StyledSpan>
<span style={{ display: 'block', marginTop: '4.8px' }}>
Optional: add the anchor reference of the component/section you want to link directly to.
</span>
<span style={{ display: 'block', marginTop: '4.8px' }}>Results cannot be guaranteed for external URLs.</span>
</>
)

export default {
name: 'anchorReferenceField',
title: 'Anchor reference',
Expand Down
Loading

0 comments on commit aecb7a5

Please sign in to comment.