Skip to content

Commit

Permalink
Merge branch 'malj/1637' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
padms committed Sep 1, 2023
2 parents 0d19149 + edfc6f7 commit 9d34b3d
Show file tree
Hide file tree
Showing 64 changed files with 75 additions and 234 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ legacy/js/dist
legacy/css
web/public/legacy/legacy.minified.js
legacy
sanityv3
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"lint:web": "eslint ./web/ --ext .js,.jsx,.ts,.tsx",
"lint:studio": "eslint ./studio/ --ext .js,.jsx,.ts,.tsx",
"lint:search": "eslint ./search/ --ext .ts",
"lint": "pnpm lint:web && pnpm lint:studio && pnpm lint:search",
"lint:sanityv3": "eslint ./sanityv3/ --ext .js,.jsx,.ts,.tsx",
"lint": "pnpm lint:web && pnpm lint:studio && pnpm lint:search && pnpm lint:sanityv3",
"studio": "yarn --cwd ./studio",
"web": "pnpm --filter ./web",
"sanityv3": "pnpm --filter ./sanityv3",
Expand Down
9 changes: 6 additions & 3 deletions sanityv3/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// {
// "extends": "@sanity/eslint-config-studio"
// }
{
"rules": {
"import/default": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
2 changes: 1 addition & 1 deletion sanityv3/components/CustomArrayFunctions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// custom implementation of @sanity/form-builder/src/inputs/arrays/common/ArrayFunctions.tsx
import { ArraySchemaType, isReferenceSchemaType } from 'sanity'
import { AddIcon } from '@sanity/icons'
import React, { ReactNode, useMemo, useCallback } from 'react'
import { ReactNode, useMemo, useCallback } from 'react'
import { Button, Grid, Menu, MenuButton, MenuItem } from '@sanity/ui'
import { useId } from '@reach/auto-id'

Expand Down
1 change: 0 additions & 1 deletion sanityv3/icons/SvgIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import type { IconData } from '@equinor/eds-icons'

type IconProps = {
Expand Down
2 changes: 0 additions & 2 deletions sanityv3/icons/countries/Argentina.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

const Argentina = ({ width = 30, height = 30 }: { width: number; height: number }) => {
return (
<svg width={width} xmlns="http://www.w3.org/2000/svg" version="1.0" height={height}>
Expand Down
2 changes: 0 additions & 2 deletions sanityv3/icons/countries/Brazil.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

const Brazil = ({ width = 30, height = 30 }: { width: number; height: number }) => {
return (
<svg
Expand Down
3 changes: 0 additions & 3 deletions sanityv3/icons/countries/GreatBritain.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint max-len: off */
import React from 'react'

const GreatBritain = ({ width = 30, height = 31 }: { width: number; height: number }) => {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="15 0 30 31" width={width} height={height}>
Expand Down
3 changes: 0 additions & 3 deletions sanityv3/icons/countries/Norway.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint max-len: off */
import React from 'react'

const Norway = ({ width = 30, height = 30 }: { width: number; height: number }) => {
return (
<svg
Expand Down
2 changes: 0 additions & 2 deletions sanityv3/icons/customIcons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

export const IconSuperScript = (): JSX.Element => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 25 25">
Expand Down
1 change: 0 additions & 1 deletion sanityv3/icons/edsIcons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { list, IconData } from '@equinor/eds-icons'

import { SvgIcon, BlockEditorSvgIcon } from './SvgIcon'
Expand Down
9 changes: 0 additions & 9 deletions sanityv3/initialValueTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ const localNewsWithTagTemplate: Template<any, any> = {
}),
}

const promotedMagazineTagTemplate: Template<any, any> = {
id: `promoted-magazine-tags`,
title: `Promoted magazine tags`,
schemaType: `promotedMagazineTags`,
value: () => {
return { tags: [] }
},
}

export const initialValueTemplates = [
//promotedMagazineTagTemplate,
localNewsWithTagTemplate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useCallback, forwardRef, useState, useRef } from 'react'
import { useEffect, useCallback, forwardRef, useState, useRef } from 'react'
import { createPortal } from 'react-dom'
import { Dialog } from '@sanity/ui'
import styled from 'styled-components'
Expand Down
2 changes: 0 additions & 2 deletions sanityv3/plugins/asset-source-brandmaster/src/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

export default function BrandmasterIcon() {
return (
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import React, { useEffect, useCallback, forwardRef, useState, useRef } from 'react'
import { useEffect, useCallback, forwardRef, useState, useRef } from 'react'
// @ts-ignore
import { createPortal } from 'react-dom'
import { Dialog, Spinner } from '@sanity/ui'
Expand Down
1 change: 0 additions & 1 deletion sanityv3/plugins/asset-source-fotoware/src/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { useColorSchemeValue } from 'sanity'

export default function FotowareIcon() {
Expand Down
2 changes: 1 addition & 1 deletion sanityv3/plugins/asset-source-fotoware/src/Placeholder.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef } from 'react'
import { forwardRef } from 'react'
import { ErrorMessage } from './components'

const PlacholderAssetSource = forwardRef<HTMLDivElement>((props: any, ref) => {
Expand Down
6 changes: 3 additions & 3 deletions sanityv3/plugins/asset-source-fotoware/src/components.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { forwardRef } from 'react'
import { Box, Dialog } from '@sanity/ui'
import { ReactNode, forwardRef } from 'react'
import { Dialog, Box } from '@sanity/ui'
import styled from 'styled-components'

export const Content = styled.div`
Expand Down Expand Up @@ -49,7 +49,7 @@ export const FullScreenDialog = styled(Dialog)`
type ErrorMessageProps = {
onClose: any
ref: any
children?: React.ReactNode
children?: ReactNode
}

export const ErrorMessage = forwardRef<HTMLDivElement, ErrorMessageProps>((props, ref) => {
Expand Down
1 change: 0 additions & 1 deletion sanityv3/sanity.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { visionTool } from '@sanity/vision'
import { media } from 'sanity-plugin-media'

import {
Config,
ConfigContext,
createAuthStore,
defineConfig,
Expand Down
5 changes: 3 additions & 2 deletions sanityv3/schemas/components/CharCounterEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { Stack, Text } from '@sanity/ui'
import { ArrayOfObjectsInputProps, PortableTextBlock } from 'sanity'

export function CharCounterEditor(props: ArrayOfObjectsInputProps) {
const content = props.value ? blocksToText(props.value as PortableTextBlock[]) : []
const { value, renderDefault } = props
const content = value ? blocksToText(value as PortableTextBlock[]) : []
return (
<Stack space={3}>
{props.renderDefault(props)}
{renderDefault(props)}
<Text muted size={1}>
Characters: {content?.length || 0}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const InlinePreview = ({ value }: { value: EventPromotion | undefined }) => {
}

export const EventPromotionInput = (props: EventPromotionInputProps) => {
const { value, members, renderField, renderInput, renderItem, renderPreview, onChange } = props
const { value, members, renderField, renderInput, renderItem, renderPreview, onChange, renderDefault } = props

const useTags = getObjectMemberField(members, 'useTags')
const promotePastEvents = getObjectMemberField(members, 'promotePastEvents')
Expand All @@ -36,7 +36,7 @@ export const EventPromotionInput = (props: EventPromotionInputProps) => {
const promotedEvents = getObjectMemberField(members, 'promotedEvents')

if (!promotePastEvents || !pastEventsCount || !useTags || !selectedTags || !promotedEvents)
return props.renderDefault(props)
return renderDefault(props)

return (
<Stack space={4}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ type EventPromotionPreviewProps = {
} & PreviewProps

export const EventPromotionPreview = (props: EventPromotionPreviewProps) => {
const { manuallySelectEvents, promotedEvents, promotePastEvents, pastEventsCount, useTags, tags } = props
const { manuallySelectEvents, promotedEvents, promotePastEvents, pastEventsCount, useTags, tags, renderDefault } =
props
const [title, setTitle] = useState('Event promotion')

useEffect(() => {
Expand All @@ -32,7 +33,7 @@ export const EventPromotionPreview = (props: EventPromotionPreviewProps) => {
return (
<Flex align="center">
<Box flex={1}>
{props.renderDefault({ ...props, title: title, subtitle: 'Event promotion', media: EdsIcon(calendar_event) })}
{renderDefault({ ...props, title: title, subtitle: 'Event promotion', media: EdsIcon(calendar_event) })}
</Box>

{manuallySelectEvents ? (
Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/components/HLSPlayer.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable import/no-named-as-default-member */
/* eslint-disable jsx-a11y/media-has-caption */
import React, { useRef, HTMLProps, useEffect } from 'react'
import { FC, useRef, HTMLProps, useEffect } from 'react'
import Hls from 'hls.js'

type Props = Omit<HTMLProps<HTMLVideoElement>, 'src'> & {
src: string
}

const HLSPlayer: React.FC<Props> = ({ src, ...props }) => {
const HLSPlayer: FC<Props> = ({ src, ...props }) => {
const videoRef = useRef<HTMLVideoElement>(null)
const hlsRef = useRef<Hls | null>(null)

Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/components/RadioIconSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Box, Inline } from '@sanity/ui'
import React, { useCallback, useState } from 'react'
import { ReactNode, useCallback, useState } from 'react'
import { PatchEvent, set } from 'sanity'
import styled from 'styled-components'

type StyledBoxProps = {
children: React.ReactNode
children: ReactNode
}

const StyledBox = ({ children }: StyledBoxProps) => (
Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/components/SlugInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Button, Card, Flex, Stack, TextInput } from '@sanity/ui'
import React, { useCallback, useMemo } from 'react'
import { useCallback, useMemo } from 'react'
import {
getValueAtPath,
ObjectInputProps,
Expand Down Expand Up @@ -77,7 +77,7 @@ export function SlugInput(props: SlugInputProps) {

const isUpdating = generateState?.status === 'pending'

const handleChange = React.useCallback((event: any) => updateSlug(event.currentTarget.value), [updateSlug])
const handleChange = useCallback((event: any) => updateSlug(event.currentTarget.value), [updateSlug])

return (
<Stack space={3}>
Expand Down
15 changes: 6 additions & 9 deletions sanityv3/schemas/components/SlugInput/utils/useAsync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import { DependencyList, useState, useRef, useCallback } from 'react'

export type AsyncCompleteState<T> = {
status: 'complete'
Expand All @@ -12,10 +12,7 @@ export type AsyncErrorState = {
error: Error
}

export type AsyncState<T> =
| AsyncPendingState
| AsyncCompleteState<T>
| AsyncErrorState
export type AsyncState<T> = AsyncPendingState | AsyncCompleteState<T> | AsyncErrorState

/**
* Takes an async function and returns a [AsyncState<value>, callback] pair.
Expand All @@ -26,13 +23,13 @@ export type AsyncState<T> =
*/
export function useAsync<T, U>(
fn: (arg: U) => Promise<T>,
dependencies: React.DependencyList,
dependencies: DependencyList,
): [null | AsyncState<T>, (arg: U) => void] {
const [state, setState] = React.useState<AsyncState<T> | null>(null)
const [state, setState] = useState<AsyncState<T> | null>(null)

const lastId = React.useRef(0)
const lastId = useRef(0)

const wrappedCallback = React.useCallback(
const wrappedCallback = useCallback(
(arg: U) => {
const asyncId = ++lastId.current
setState({ status: 'pending' })
Expand Down
8 changes: 4 additions & 4 deletions sanityv3/schemas/components/TimeInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react'
import { FormEvent, useCallback, useState } from 'react'
import { useId } from '@reach/auto-id'
import { ResetIcon } from '@sanity/icons'
import { Box, Button, Flex, Select, Text } from '@sanity/ui'
Expand Down Expand Up @@ -46,7 +46,7 @@ type TimeType = {
}

const TimeInput = (props: ObjectInputProps<string>) => {
const { value, onChange, elementProps, validation } = props
const { value, onChange, elementProps } = props
const [time, setTime] = useState(formatTime(value))

const updateValue = useCallback(
Expand All @@ -65,14 +65,14 @@ const TimeInput = (props: ObjectInputProps<string>) => {
)

const handleHoursChange = useCallback(
(event: React.FormEvent<HTMLSelectElement>) => {
(event: FormEvent<HTMLSelectElement>) => {
updateValue({ ...time, hours: event.currentTarget.value })
},
[time, updateValue],
)

const handleMinutesChange = useCallback(
(event: React.FormEvent<HTMLSelectElement>) => {
(event: FormEvent<HTMLSelectElement>) => {
updateValue({ ...time, minutes: event.currentTarget.value })
},
[time, updateValue],
Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/components/TimezoneInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import { FormEvent } from 'react'

import { useId } from '@reach/auto-id'
import { Select } from '@sanity/ui'
Expand All @@ -8,7 +8,7 @@ import { set, unset, StringInputProps } from 'sanity'
const TimezoneInput = (props: StringInputProps) => {
const { value = '', onChange, elementProps } = props
const id = useId()
const handleChange = (event: React.FormEvent<HTMLSelectElement>) => {
const handleChange = (event: FormEvent<HTMLSelectElement>) => {
onChange(event.currentTarget.value === '' ? unset() : set(event.currentTarget.value))
}

Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/components/VideoSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback, useRef, forwardRef, useEffect } from 'react'
import { ReactNode, useState, useCallback, useRef, forwardRef, useEffect } from 'react'
import { MemberField, set, unset } from 'sanity'
import { createPortal } from 'react-dom'
import type { ObjectInputProps } from 'sanity'
Expand All @@ -17,7 +17,7 @@ type VideoSelector = {

type VideoSelectorProps = {
value?: VideoSelector
children?: React.ReactNode
children?: ReactNode
} & ObjectInputProps

const MEDIABANK_DOMAIN = 'https://communicationtoolbox.equinor.com'
Expand Down
4 changes: 2 additions & 2 deletions sanityv3/schemas/components/renderers.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import {ReactNode} from 'react'

type Props = {
children: React.ReactNode
children: ReactNode
}

export const ExternalLinkRenderer = ({ children }: Props) => <span>{children}</span>
Expand Down
3 changes: 1 addition & 2 deletions sanityv3/schemas/documents/404.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { flight_land } from '@equinor/eds-icons'
import { flight_land, collection_4 } from '@equinor/eds-icons'
import type { PortableTextBlock, Rule } from 'sanity'
import blocksToText from '../../helpers/blocksToText'
import { EdsIcon } from '../../icons'
import CompactBlockEditor from '../components/CompactBlockEditor'
import { i18n } from '../documentTranslation'
import { configureTitleBlockContent } from '../editors'
import { configureBlockContent } from '../editors/blockContentType'
import { collection_4 } from '@equinor/eds-icons'

const titleContentType = configureTitleBlockContent()
const textContentType = configureBlockContent({
Expand Down
1 change: 0 additions & 1 deletion sanityv3/schemas/documents/assetFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
microsoft_powerpoint,
library_pdf,
file,
library_books,
calendar_event,
attach_file,
} from '@equinor/eds-icons'
Expand Down
1 change: 0 additions & 1 deletion sanityv3/schemas/documents/localNews.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { file_description } from '@equinor/eds-icons'
import {
defineType,
Rule,
SanityDocument,
SlugSchemaType,
Expand Down
1 change: 0 additions & 1 deletion sanityv3/schemas/documents/localNewsTag.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { languages } from '../../languages'
import type { CurrentUser } from 'sanity'
import styled from 'styled-components'
Expand Down
2 changes: 1 addition & 1 deletion sanityv3/schemas/documents/magazineTag.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultLanguage, languages } from '../../languages'
import { TagIcon, EdsIcon } from '../../icons'
import { EdsIcon } from '../../icons'
import type { Rule } from 'sanity'
import { tag_main_equipment } from '@equinor/eds-icons'

Expand Down
Loading

0 comments on commit 9d34b3d

Please sign in to comment.