Skip to content

Commit

Permalink
Merge branch 'main' into as-fix-fresh-codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 19, 2024
2 parents c3799e0 + c5d5660 commit e5ba931
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 35 deletions.
16 changes: 16 additions & 0 deletions apps/contentful-apps/pages/fields/admin-only-boolean-field.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FieldExtensionSDK } from '@contentful/app-sdk'
import { Paragraph } from '@contentful/f36-components'
import { BooleanEditor } from '@contentful/field-editor-boolean'
import { useSDK } from '@contentful/react-apps-toolkit'

const AdminOnlyBooleanField = () => {
const sdk = useSDK<FieldExtensionSDK>()

if (!sdk.user.spaceMembership.admin) {
return <Paragraph>(Only admins can edit this field)</Paragraph>
}

return <BooleanEditor field={sdk.field} isInitiallyDisabled={false} />
}

export default AdminOnlyBooleanField
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,18 @@ export const OverviewLinksSlice: React.FC<
key={index}
direction={leftImage ? 'row' : 'rowReverse'}
>
<GridColumn span={['8/8', '3/8', '4/8', '3/8']}>
<Box
width="full"
position="relative"
paddingLeft={leftImage ? undefined : [0, 0, 0, 0, 6]}
paddingRight={leftImage ? [10, 0, 0, 0, 6] : [10, 0]}
>
{/**
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error make web strict */}
<Image
url={image?.url + '?w=774&fm=webp&q=80'}
thumbnail={image?.url + '?w=50&fm=webp&q=80'}
{...image}
/>
</Box>
</GridColumn>
{image?.url && (
<GridColumn span={['8/8', '3/8', '4/8', '3/8']}>
<Box
width="full"
position="relative"
paddingLeft={leftImage ? undefined : [0, 0, 0, 0, 6]}
paddingRight={leftImage ? [10, 0, 0, 0, 6] : [10, 0]}
>
<img src={`${image.url}?w=774&fm=webp&q=80`} alt="" />
</Box>
</GridColumn>
)}
<GridColumn span={['8/8', '5/8', '4/8', '5/8']}>
<Box
display="flex"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,9 @@ export const OrganizationWrapper: React.FC<

const n = useNamespace(namespace)

const indexableBySearchEngine =
organizationPage.canBeFoundInSearchResults ?? true

return (
<>
<HeadWithSocialSharing
Expand All @@ -1184,7 +1187,11 @@ export const OrganizationWrapper: React.FC<
imageContentType={pageFeaturedImage?.contentType}
imageWidth={pageFeaturedImage?.width?.toString()}
imageHeight={pageFeaturedImage?.height?.toString()}
/>
>
{!indexableBySearchEngine && (
<meta name="robots" content="noindex, nofollow" />
)}
</HeadWithSocialSharing>
<OrganizationHeader
organizationPage={organizationPage}
isSubpage={isSubpage}
Expand Down
1 change: 1 addition & 0 deletions apps/web/screens/queries/Organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export const GET_ORGANIZATION_PAGE_QUERY = gql`
slug
title
description
canBeFoundInSearchResults
topLevelNavigation {
links {
label
Expand Down
3 changes: 3 additions & 0 deletions libs/cms/src/lib/generated/contentfulTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3249,6 +3249,9 @@ export interface IOrganizationPageFields {

/** Sitemap */
sitemap?: ISitemap | undefined

/** Can be found in search results */
canBeFoundInSearchResults?: boolean | undefined
}

export interface IOrganizationPage extends Entry<IOrganizationPageFields> {
Expand Down
4 changes: 4 additions & 0 deletions libs/cms/src/lib/models/organizationPage.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export class OrganizationPage {

@CacheField(() => OrganizationPageTopLevelNavigation, { nullable: true })
topLevelNavigation?: OrganizationPageTopLevelNavigation | null

@Field(() => Boolean, { nullable: true })
canBeFoundInSearchResults?: boolean
}

export const mapOrganizationPage = ({
Expand Down Expand Up @@ -144,5 +147,6 @@ export const mapOrganizationPage = ({
? mapImage(fields.defaultHeaderImage)
: undefined,
topLevelNavigation,
canBeFoundInSearchResults: fields.canBeFoundInSearchResults ?? true,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class OrganizationPageSyncService
return entries.filter(
(entry: Entry<any>): entry is IOrganizationPage =>
entry.sys.contentType.sys.id === 'organizationPage' &&
!!entry.fields.title,
!!entry.fields.title &&
(entry.fields.canBeFoundInSearchResults ?? true),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export class OrganizationSubpageSyncService
!!entry.fields.slug &&
!!entry.fields.organizationPage?.fields?.slug &&
// Standalone organization pages have their own search, we don't want subpages there to be found in the global search
entry.fields.organizationPage.fields.theme !== 'standalone',
entry.fields.organizationPage.fields.theme !== 'standalone' &&
// Subpage should not be searchable if the organization frontpage isn't searchable
(entry.fields.organizationPage.fields.canBeFoundInSearchResults ??
true),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
NestedFullTable,
SimpleBarChart,
formatDate,
numberFormat,
} from '@island.is/portals/my-pages/core'
import { Box, Text, Button } from '@island.is/island-ui/core'
import { AssetsPaths } from '../../lib/paths'
Expand Down Expand Up @@ -137,6 +138,7 @@ export const VehicleBulkMileageSubData = ({
labels: {
mileage: formatMessage(vehicleMessage.odometer),
},
valueFormat: (arg: number) => `${numberFormat(arg)} km`,
}}
/>
) : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { theme } from '@island.is/island-ui/theme'
interface Axis {
label?: string
datakey: string
valueFormat?: (arg: number) => string
}

interface BarType {
Expand All @@ -29,6 +30,7 @@ interface BarType {

interface TooltipType {
labels: Record<string, string>
valueFormat?: (arg: number) => string
}

interface GraphDataProps {
Expand Down Expand Up @@ -96,7 +98,12 @@ export const SimpleBarChart = ({
/>
<YAxis stroke="#CCDFFF" tick={<CustomizedAxisTick />} />
<Tooltip
content={<CustomTooltip valueLabels={tooltip?.labels} />}
content={
<CustomTooltip
valueLabels={tooltip?.labels}
valueFormat={tooltip?.valueFormat}
/>
}
/>
<Legend
iconType="circle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,54 @@ import * as styles from './charts.css'
import cn from 'classnames'
import { LegendProps, TooltipProps } from 'recharts'
import { Box, Text } from '@island.is/island-ui/core'
import { isDefined } from '@island.is/shared/utils'

interface AxisTickProps {
x?: number
y?: number
className?: string
payload?: { value: string }
valueFormat?: (arg: number) => string
}

interface CustomTooltipProps extends TooltipProps<number, string> {
valueLabels?: Record<string, string>
valueFormat?: (arg: number) => string
}

export const CustomTooltip = ({
payload,
active,
label,
valueLabels,
valueFormat,
}: CustomTooltipProps) => {
if (active && payload && payload.length) {
return (
<Box className={cn(styles.tooltip)}>
<Text variant="small">{label}</Text>
{payload.map((item, index) => (
<Box as="li" className={cn(styles.list)} key={`item-${index}`}>
<div
className={cn(styles.dot)}
style={{
border: '3px solid ' + item.color,
}}
/>
<Text variant="small">
{valueLabels && item.name ? valueLabels[item.name] : item.name} :
{item.value}
</Text>
</Box>
))}
{payload
.map((item, index) => {
if (!item.value) return null

return (
<Box as="li" className={cn(styles.list)} key={`item-${index}`}>
<div
className={cn(styles.dot)}
style={{
border: '3px solid ' + item.color,
}}
/>
<Text variant="small">
{valueLabels && item.dataKey
? valueLabels[item.dataKey]
: item.name}
: {valueFormat ? valueFormat(item.value) : item.value}
</Text>
</Box>
)
})
.filter(isDefined)}
</Box>
)
}
Expand Down

0 comments on commit e5ba931

Please sign in to comment.