Skip to content

Commit a3b07f7

Browse files
committed
🎨 add campaign blocks to sponsorship and add roles based access to them
1 parent 7ea3303 commit a3b07f7

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

FeatureFlags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const MAGAZINE = [...GLOBAL_PROD, ...GLOBAL_DEV]
4242
/* Allows same slug for different languages */
4343
const SAME_SLUG = [...GLOBAL_DEV, 'japan', 'southkorea']
4444
const LINE_BREAK_TYPO = ['southkorea']
45-
const CAMPAIGN = [...GLOBAL_PROD, ...GLOBAL_DEV]
45+
const CAMPAIGN = [...GLOBAL_PROD, 'sponsorship', ...GLOBAL_DEV]
4646

4747
/**
4848
* @param {string} dataset
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import { Role, useCurrentUser } from 'sanity'
1+
import { type Role, useCurrentUser } from 'sanity'
22

3-
const restrictedComponents = ['videoPlayer', 'videoPlayerCarousel', 'fullWidthVideo', 'promoteExternalLinkV2']
3+
const restrictedComponents = [
4+
'videoPlayer',
5+
'videoPlayerCarousel',
6+
'fullWidthVideo',
7+
'promoteExternalLinkV2',
8+
'grid',
9+
'campaignBanner',
10+
]
411

512
export function RolesBasedArrayInput(props: any) {
613
const { schemaType, renderDefault } = props
714

815
//get the role of the current user
9-
//@ts-ignore CurrentUser has roles in types...
16+
//@ts-expect-error CurrentUser has roles in types...
1017
const { roles } = useCurrentUser()
1118

1219
const allowedRoles = ['administrator', 'developer', 'designer']
@@ -18,5 +25,8 @@ export function RolesBasedArrayInput(props: any) {
1825
: schemaType.of?.filter((type: any) => !restrictedComponents.includes(type.name))
1926

2027
//render the default component and replace the allowed types
21-
return renderDefault({ ...props, schemaType: { ...schemaType, of: allowedTypes } })
28+
return renderDefault({
29+
...props,
30+
schemaType: { ...schemaType, of: allowedTypes },
31+
})
2232
}

sanityv3/schemas/documents/route.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { calendar_event, library_books } from '@equinor/eds-icons'
2+
// eslint-disable-next-line import/namespace
3+
import type { SanityClient, SanityDocument } from '@sanity/client'
4+
import type { Reference, Rule, SlugParent, SlugSchemaType, SlugSourceContext } from 'sanity'
15
import slugify from 'slugify'
2-
import { Reference, Rule, SlugParent, SlugSchemaType, SlugSourceContext } from 'sanity'
36
import blocksToText from '../../helpers/blocksToText'
4-
import { calendar_event, library_books } from '@equinor/eds-icons'
57
import { EdsIcon, TopicDocuments } from '../../icons'
68
import { Flags } from '../../src/lib/datasetHelpers'
7-
import { withSlugValidation } from '../validations/validateSlug'
89
import SlugInput from '../components/SlugInput'
9-
// eslint-disable-next-line import/namespace
10-
import { SanityClient, SanityDocument } from '@sanity/client'
10+
import { withSlugValidation } from '../validations/validateSlug'
1111

1212
export default (isoCode: string, title: string) => {
1313
return {
@@ -102,7 +102,9 @@ export default (isoCode: string, title: string) => {
102102

103103
if (refId) {
104104
return client
105-
.fetch(/* groq */ `*[_id == $refId][0].slug.current`, { refId: refId })
105+
.fetch(/* groq */ `*[_id == $refId][0].slug.current`, {
106+
refId: refId,
107+
})
106108
.then((parentSlug: string) => `${parentSlug}/${slugify(input)}`)
107109
} else {
108110
return `/${slugify(input)}`

sanityv3/schemas/documents/routeHomepage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { SchemaType } from '../../types'
2-
import blocksToText from '../../helpers/blocksToText'
31
import { calendar_event, home } from '@equinor/eds-icons'
2+
import type { ValidationContext } from 'sanity'
3+
import blocksToText from '../../helpers/blocksToText'
44
import { EdsIcon, TopicDocuments } from '../../icons'
55
import { defaultLanguage, languages } from '../../languages'
6-
import { ValidationContext } from 'sanity'
76
import { apiVersion } from '../../sanity.client'
7+
import type { SchemaType } from '../../types'
88

99
export default {
1010
type: 'document',
@@ -27,7 +27,7 @@ export default {
2727
},
2828
{ perspective: 'published' },
2929
)
30-
return result == languages.length || result == 0 || 'Translations of this home page must be published'
30+
return result === languages.length || result === 0 || 'Translations of this home page must be published'
3131
} else return 'Required'
3232
})
3333
},

0 commit comments

Comments
 (0)