Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
460a49c
chore: remove old image system
JohanHjelsethStorstad Mar 24, 2026
2af8894
refactor: make image service into a subservice with implementations
JohanHjelsethStorstad Mar 24, 2026
4621dca
refactor: make the store into a factory that implements two functions
JohanHjelsethStorstad Apr 4, 2026
cf27133
chore: make image system actually delete files when a image is deleted
JohanHjelsethStorstad Apr 4, 2026
0b3cb24
chore: set up system for generating standard images from config
JohanHjelsethStorstad Apr 13, 2026
cb1acfb
fix: mount the dobbelomegamanifest volume
JohanHjelsethStorstad Apr 13, 2026
c15a275
chore: add config for dev_profile_images
JohanHjelsethStorstad Apr 13, 2026
9fd792e
chore: add config for all images in standard store
JohanHjelsethStorstad Apr 13, 2026
aa7a731
feat: read and regenerate standard images
JohanHjelsethStorstad Apr 13, 2026
35f3820
refactor: on StandardStoreFile make a method to easily convert to ima…
JohanHjelsethStorstad Apr 14, 2026
3a08498
refacotor: use the imageUploadData to seed dynamic images for cms
JohanHjelsethStorstad Apr 14, 2026
c02ece3
chore: remove som special cms images (work in progress)
JohanHjelsethStorstad Apr 16, 2026
bebd846
chore: add semantics to tell which images are available after seeding…
JohanHjelsethStorstad Jun 9, 2026
40544a2
chore: upsering
JohanHjelsethStorstad Jul 14, 2026
3af5e2e
chore: remove timeout comment by variable name
JohanHjelsethStorstad Jul 15, 2026
0c27ff7
refactor: omegaOrder service to use serviceOperations
JohanHjelsethStorstad Jul 17, 2026
f965c92
chore: accept NOT FOUND errors as non existance in upsert function
JohanHjelsethStorstad Jul 17, 2026
b69b726
chore: defineSeedOperation using context
JohanHjelsethStorstad Jul 17, 2026
0a2cdd7
refactor: seed of article categories and orders
JohanHjelsethStorstad Jul 17, 2026
8958a3d
chore: add types to extract Data, Params, ImplementationParams from s…
JohanHjelsethStorstad Jul 17, 2026
6c81eb6
docs: simplify doc strings for seedArticleCategories
JohanHjelsethStorstad Jul 18, 2026
66ee094
refactor: flairs to implement its own special image collection
JohanHjelsethStorstad Jul 18, 2026
edd7ce9
refactor: seed images to use defineSeedOperation
JohanHjelsethStorstad Jul 18, 2026
f769f18
fix: deleting images that do not exist
JohanHjelsethStorstad Jul 18, 2026
97f0820
refactor: seeding of news articles
JohanHjelsethStorstad Jul 19, 2026
74eadd2
chore: move out ArticleCategory and NewsArticle scemas from cms to be…
JohanHjelsethStorstad Jul 19, 2026
78b7dfc
chore: migrate seedDevImages to defineSeedOperation
JohanHjelsethStorstad Jul 19, 2026
f4c9860
refactor: seedDevNews
JohanHjelsethStorstad Jul 19, 2026
545cfd7
refactor: seedSpecialCms
JohanHjelsethStorstad Jul 19, 2026
dbf5dae
refactor: update committee service to implement its own special colle…
JohanHjelsethStorstad Jul 19, 2026
dc809b5
refactor: ombul to implement OMBUL COVERS special collection
JohanHjelsethStorstad Jul 19, 2026
8478746
chore: extra sanity check for ownership of images destroyed even thou…
JohanHjelsethStorstad Jul 19, 2026
35a5c66
feat: paragraphs for ombul
JohanHjelsethStorstad Jul 19, 2026
c420549
chore: enforce allowedExt in store.createFile is narrower than that o…
JohanHjelsethStorstad Jul 19, 2026
f116f23
fix: array buffer type in upload image
JohanHjelsethStorstad Jul 19, 2026
3674f69
refactor: user service to implement special PROFILE_IMAGES collection
JohanHjelsethStorstad Jul 20, 2026
9c7276b
chore: set up main landing page for image collections list
JohanHjelsethStorstad Jul 20, 2026
8850f60
chore: tie Cursor and details types to schemas
JohanHjelsethStorstad Jul 20, 2026
b09e0ab
chore: set up new route structure for images pages
JohanHjelsethStorstad Jul 20, 2026
d10e768
chore: use StandardImage for the removed CmsImage parts
JohanHjelsethStorstad Jul 20, 2026
6cbc3f9
fix: use new standard image implementation in fallback of CmsImage co…
JohanHjelsethStorstad Jul 20, 2026
88ae394
chore: rename dynamic image actions to make clear they are for dynami…
JohanHjelsethStorstad Jul 21, 2026
5695738
chore: assemble all panel operation in a new 'service' assebling all …
JohanHjelsethStorstad Jul 21, 2026
cefa465
feat: ClientData provider for easier client getting of data
JohanHjelsethStorstad Jul 22, 2026
1883b0b
chore: merge CmsImageClient and Cmsimage into one
JohanHjelsethStorstad Jul 22, 2026
677c535
chore: add TODO comment
JohanHjelsethStorstad Jul 23, 2026
a9b569f
chore: set up ImageCollectionList to use special collections
JohanHjelsethStorstad Jul 23, 2026
8e829eb
chore: show special collections in CollectionList page
JohanHjelsethStorstad Jul 23, 2026
cca7d66
chore: show special collections in CmsImageEditor
JohanHjelsethStorstad Jul 23, 2026
211e860
fix: prismaWhereFilter not applied to a level in readCollectionPage
JohanHjelsethStorstad Jul 23, 2026
fe2ffb0
chore: validate that a user administrates the collection of the image…
JohanHjelsethStorstad Jul 23, 2026
4702d9c
chore: add note to user that exposing an image through a cmsImage mig…
JohanHjelsethStorstad Jul 23, 2026
d7360fa
chore: set up for refactoring ImageList
JohanHjelsethStorstad Jul 23, 2026
c3539be
refactor: CollectionCard does not enforce being a link - new Collecti…
JohanHjelsethStorstad Jul 23, 2026
7304c0e
chore: remove the details from image pager. Should be bound seperatly
JohanHjelsethStorstad Jul 23, 2026
21585fc
refactor: ImageList -> ImageDisplay managing displaying of images for…
JohanHjelsethStorstad Jul 23, 2026
b9fbfa8
fix: old refs do refactored systems
JohanHjelsethStorstad Jul 23, 2026
db840c0
fix: seedDevUsers to use standard store
JohanHjelsethStorstad Jul 23, 2026
dadce7a
fix: career and education pages use current standard image action
JohanHjelsethStorstad Jul 24, 2026
5355dfa
fix: event registration reads default profile image through current s…
JohanHjelsethStorstad Jul 24, 2026
1fbffb0
fix: seedDevJobAds looks up the FAIR image by standardImage
JohanHjelsethStorstad Jul 24, 2026
6355d1d
chore: .bind -> configureAction in eduaction
JohanHjelsethStorstad Jul 24, 2026
de02747
chore: StandardImageServer rename and consistent use
JohanHjelsethStorstad Jul 24, 2026
e4b6b82
chore: make migrations use new image system
JohanHjelsethStorstad Jul 24, 2026
1ef3667
fix: circular dependencies fixed by exporting implementation of speci…
JohanHjelsethStorstad Jul 24, 2026
40d5ed4
fix: standard images race condition on seeding
JohanHjelsethStorstad Jul 24, 2026
e73e23b
chore: remove 'special' fields from data in operations. The implement…
JohanHjelsethStorstad Jul 24, 2026
8447f16
chore: do not log expected not founds in seeder
JohanHjelsethStorstad Jul 24, 2026
b395f42
fix: two long name in autogenerated special articles
JohanHjelsethStorstad Jul 24, 2026
610b6df
chore: seperate function for regeneration of special cms
JohanHjelsethStorstad Jul 24, 2026
f6218fa
chore: Big speedup in image uploader
JohanHjelsethStorstad Jul 26, 2026
4bdf8ca
fix: turbopack issue with importing directory of standardFiles
JohanHjelsethStorstad Jul 26, 2026
626e450
chore: wrong standard images used on frontpage
JohanHjelsethStorstad Jul 26, 2026
9275ae9
chore: first draft of visibility admin
JohanHjelsethStorstad Jul 27, 2026
e42bcf6
chore: wrong standard images on not-found error and loader
JohanHjelsethStorstad Jul 27, 2026
8b6e387
chore: feed visibility from server to collectionAdmin
JohanHjelsethStorstad Jul 27, 2026
3c16ac9
fix: run all authorizers needed for collectionAdmin not just trus one
JohanHjelsethStorstad Jul 27, 2026
9fd7854
fix: collection cards collapse in cms image editor
JohanHjelsethStorstad Jul 27, 2026
59f157d
fix: invisible buttons on edit article
JohanHjelsethStorstad Jul 27, 2026
574c806
chore: make ImageUploader just a form to increase modularity
JohanHjelsethStorstad Jul 27, 2026
6c0b95b
feat: enforce that admin visibility is a sub visibility of regular level
JohanHjelsethStorstad Jul 27, 2026
b85ae33
chore: reuse the util to get group orders
JohanHjelsethStorstad Jul 27, 2026
787db73
chore: make description of of visibility a component
JohanHjelsethStorstad Jul 27, 2026
253de22
chore: tests for dynamic images and visibility
JohanHjelsethStorstad Jul 27, 2026
ccdff0f
style: auto fix lining
JohanHjelsethStorstad Jul 27, 2026
8a72d8c
chore: fix seeder for ci in test
JohanHjelsethStorstad Jul 27, 2026
445e699
fix: bump timeouts for seeding in test
JohanHjelsethStorstad Jul 27, 2026
7226047
refactor: omegaId service
JohanHjelsethStorstad Jul 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ src/prisma/migrations

.rest

.vscode
.vscode

.claude
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RUN mkdir -p usr/src/app/store/images
COPY public public
COPY next-env.d.t[s] next.config.ts tsconfig.json ./

COPY standard_store standard_store

############################################################
FROM base AS prod

Expand All @@ -52,5 +54,6 @@ CMD ["npm", "run", "test"]
FROM base AS dev

ENV NODE_ENV=development
# src is expected to be binded in dev

CMD ["npm", "run", "dev-seed"]
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- ${PROJECT_ROOT:-.}/logs:/usr/src/app/logs
- devstore:/usr/src/app/store
- dotnext:/usr/src/app/.next
- dobbelOmegaManifest:/usr/src/app/dobbelOmegaManifest

db:
extends:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
volumes:
- store:/usr/src/app/store
- logs:/usr/src/app/logs
- dobbelOmegaManifest:/usr/src/app/dobbelOmegaManifest
deploy:
replicas: 2
restart: always
Expand Down
1 change: 1 addition & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
environment:
DOMAIN: omega.ntnu.no
MAIL_DOMAIN: sanctus.omega.ntnu.no
CI: ${CI:-}
volumes:
- ${PROJECT_ROOT:-.}/src:/usr/src/app/src
- ${PROJECT_ROOT:-.}/tests:/usr/src/app/tests
Expand Down
4 changes: 4 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const config: Config = {
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
coverageReporters: ['text-summary'],
// Each suite's beforeAll re-seeds all standard images through sharp/avif, which is CPU-heavy.
// Running many suites' seeds concurrently starves CI's limited cores and blows past the 30s
// beforeAll timeout in tests/setup.ts, even though a single seed() run only takes a few seconds.
maxWorkers: process.env.CI ? 2 : undefined,
moduleNameMapper: {
// This is needed becaue jest doesn't handle the this code is inside node_modules
'^@/prisma-dobbel-omega/(.*)$': '<rootDir>/node_modules/.prisma-dobbel-omega/$1',
Expand Down
20 changes: 4 additions & 16 deletions src/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
import styles from './layout.module.scss'
import { ServerSession } from '@/auth/session/ServerSession'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import { frontpageAuth } from '@/services/frontpage/auth'
import StandardImageServer from '@/components/Image/StandardImageServer'
import React from 'react'

type PropTypes = {
children: React.ReactNode
}

export default async function AuthLayout({ children }: PropTypes) {
const session = await ServerSession.fromNextAuth()
const canEditAuthIcon = frontpageAuth.updateSpecialCmsImage.dynamicFields({}).auth(
session
).toJsObject()

export default function AuthLayout({ children }: PropTypes) {
return (
<div className={styles.wrapper}>
<div className={styles.card}>
<div className={styles.input}>
{children}
</div>
<div className={styles.image}>
<SpecialCmsImage
canEdit={canEditAuthIcon}
special="AUTH_ICON"
<StandardImageServer
standardImage="MAGISK_HATT"
alt="en kappemann sin hatt"
width={200}
//TODO: Probably call through other service see comments in frontpage operations
readSpecialCmsImageAction={readSpecialCmsImageFrontpage}
updateCmsImageAction={updateSpecialCmsImageFrontpage}
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/(auth)/register/RegistrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import Checkbox from '@/components/UI/Checkbox'
import { SelectString } from '@/components/UI/Select'
import TextInput from '@/components/UI/TextInput'
import { sexConfig } from '@/services/users/constants'
import { SEX, type User } from '@/prisma-generated-pn-types'
import { signIn } from 'next-auth/react'
import { useSearchParams } from 'next/navigation'
import { useState } from 'react'
import { SEX, type User } from '@/prisma-generated-pn-types'

export default function RegistrationForm({
userData,
Expand Down
16 changes: 4 additions & 12 deletions src/app/(frontpage)/LoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import EventCard from '@/app/_components/Event/EventCard'
import JobAd from '@/app/career/jobads/JobAd'
import NewsCard from '@/app/news/NewsCard'
import SocialIcons from '@/components/SocialIcons/SocialIcons'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
import StandardImageServer from '@/components/Image/StandardImageServer'
import { unwrapActionReturn } from '@/app/redirectToErrorPage'
import { readNewsCurrentAction } from '@/services/news/actions'
import { readActiveJobAdsAction } from '@/services/career/jobAds/actions'
import { readCurrentEventsAction } from '@/services/events/actions'
import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import { frontpageAuth } from '@/services/frontpage/auth'
import { eventAuth } from '@/services/events/auth'
import { ServerSession } from '@/auth/session/ServerSession'
import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
Expand All @@ -28,9 +26,6 @@ export default async function LoggedInLandingPage() {
.slice(0, MAX_NUMBER_OF_ELEMENTS)

const session = await ServerSession.fromNextAuth()
const canEditFrontpageCmsImage = frontpageAuth.updateSpecialCmsImage.dynamicFields({}).auth(
session
).toJsObject()

const canEditEventCmsImage = eventAuth.updateCmsCoverImage.dynamicFields({}).auth(
session
Expand All @@ -41,12 +36,9 @@ export default async function LoggedInLandingPage() {
<div className={`${styles.part} ${styles.frontImg}`}>
<div className={styles.frontInfo}>
<div>
<SpecialCmsImage
canEdit={canEditFrontpageCmsImage}
special="FRONTPAGE_LOGO"
<StandardImageServer
standardImage="LOGO_WHITE"
width={300}
readSpecialCmsImageAction={readSpecialCmsImageFrontpage}
updateCmsImageAction={updateSpecialCmsImageFrontpage}
/>
<div className={styles.socials}>
<SocialIcons />
Expand Down Expand Up @@ -74,7 +66,7 @@ export default async function LoggedInLandingPage() {
<JobAd key={key} jobAd={jobAd} />
))}
</LoggedInSection>
<LoggedInSection title="Bilder" link="/images">
<LoggedInSection title="Bilder" link="/image-collections">
Her kan man kanskje vise noen bilder ellerno
</LoggedInSection>
</div>
Expand Down
10 changes: 3 additions & 7 deletions src/app/(frontpage)/LoggedOut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import styles from './page.module.scss'
import InfoBubbles from './InfoBubbles'
import MazeMap from '@/components/MazeMap/MazeMap'
import SocialIcons from '@/components/SocialIcons/SocialIcons'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
import StandardImageServer from '@/components/Image/StandardImageServer'
import YouTube from '@/components/YouTube/YouTube'
import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import { ServerSession } from '@/auth/session/ServerSession'
import { frontpageAuth } from '@/services/frontpage/auth'
import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
Expand All @@ -26,12 +25,9 @@ export default async function LoggedOutLandingPage() {
<div className={`${styles.part} ${styles.frontImg}`}>
<div className={styles.frontInfo}>
<div>
<SpecialCmsImage
canEdit={canEditSpecialCmsImage}
special="FRONTPAGE_LOGO"
<StandardImageServer
standardImage="LOGO_WHITE"
width={300}
readSpecialCmsImageAction={readSpecialCmsImageFrontpage}
updateCmsImageAction={updateSpecialCmsImageFrontpage}
/>

<Link href="login">Logg inn</Link>
Expand Down
1 change: 0 additions & 1 deletion src/app/(frontpage)/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
updateSpecialCmsImageFrontpage,
updateSpecialCmsParagraphFrontpageSection
} from '@/services/frontpage/actions'
import React from 'react'
import Link from 'next/link'
import type {
SpecialCmsImage as SpecialCmsImageT,
Expand Down
2 changes: 1 addition & 1 deletion src/app/_components/Cms/AddParts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function AddParts({
<BorderButton
key={i}
onClick={() => onClick(part.part)}
color="secondary"
color="primary"
>
<FontAwesomeIcon icon={faPlus} />
{part.text}
Expand Down
82 changes: 51 additions & 31 deletions src/app/_components/Cms/CmsImage/ChangeImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@
import styles from './ChangeImage.module.scss'
import ChangeImageForm from './ChangeImageForm'
import Image from '@/components/Image/Image'
import { ImageSelectionContext } from '@/contexts/ImageSelection'
import Form from '@/components/Form/Form'
import { configureAction } from '@/services/configureAction'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faTurnUp } from '@fortawesome/free-solid-svg-icons'
import React, { useContext, useEffect, useEffectEvent, useState } from 'react'
import React, { useEffect, useEffectEvent, useState } from 'react'
import type { ImageSize, Image as ImageT } from '@/prisma-generated-pn-types'
import type { UpdateCmsImageAction } from '@/cms/images/types'

type PropTypes = {
currentImage: ImageT,
currentImage: ImageT | null,
selectedImage: ImageT | null,
cmsImageId: number,
currentImageSize: ImageSize,
updateCmsImageAction: UpdateCmsImageAction
}

export default function ChangeImage({ currentImage, cmsImageId, currentImageSize, updateCmsImageAction }: PropTypes) {
const selectedContext = useContext(ImageSelectionContext)
if (!selectedContext) throw new Error('ImageSelectionContext required to use ChangeImage')

export default function ChangeImage({
currentImage,
selectedImage,
cmsImageId,
currentImageSize,
updateCmsImageAction,
}: PropTypes) {
//What is the next option in quality. The image always cycles up.
const [changeToSize, setChangeToSize] = useState<ImageSize>(currentImageSize)

Expand All @@ -46,47 +49,64 @@
handleChangeSize()
}, [currentImageSize])

// A selection only counts as "new" if it differs from the current image - or there is no
// current image yet, in which case this is the user's first choice for this slot.
const hasNewSelection = selectedImage !== null && selectedImage.id !== currentImage?.id
const displayImage = selectedImage ?? currentImage

const renderSubmitControls = () => {
if (hasNewSelection && selectedImage) {
return (
<ChangeImageForm
cmsImageId={cmsImageId}
selectedImage={selectedImage}
updateCmsImageAction={updateCmsImageAction}
/>
)
}
if (!currentImage) {
return <p>Velg et bilde for å legge det til</p>
}
return (
<div className={styles.resolution}>
<p>Resolution: {currentImageSize.toLowerCase()}</p>
<Form
action={
configureAction(
updateCmsImageAction,
{ params: { cmsImageId } }
).bind(null, { data: { imageSize: changeToSize } })
}
submitText={`change to ${changeToSize.toLocaleLowerCase()}`}
refreshOnSuccess
submitColor="primary"
/>
</div>
)
}

return (
<div className={styles.ChangeImage}>
{
selectedContext.selectedImage && selectedContext.selectedImage.id !== currentImage.id ? (
currentImage && selectedImage && hasNewSelection ? (
<div className={styles.currentAndSelected}>
<div className={styles.imageClip}>
<Image width={200} image={currentImage} />

Check warning on line 94 in src/app/_components/Cms/CmsImage/ChangeImage.tsx

View workflow job for this annotation

GitHub Actions / lint

Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images
</div>
<div className={styles.imageClip}>
<Image width={200} image={selectedContext.selectedImage} />
<Image width={200} image={selectedImage} />

Check warning on line 97 in src/app/_components/Cms/CmsImage/ChangeImage.tsx

View workflow job for this annotation

GitHub Actions / lint

Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images
</div>
<FontAwesomeIcon className={styles.arrow1} icon={faTurnUp} />
<FontAwesomeIcon className={styles.arrow2} icon={faTurnUp} />
</div>
) : (
<div className={`${styles.onlyCurrent} ${styles.imageClip}`}>
<Image width={200} image={currentImage} />
</div>
)
}
<i>image name: {currentImage.name}</i>
{
selectedContext.selectedImage && selectedContext.selectedImage.id !== currentImage.id ? (
<ChangeImageForm cmsImageId={cmsImageId} updateCmsImageAction={updateCmsImageAction} />
) : (
<div className={styles.resolution}>
<p>Resolution: {currentImageSize.toLowerCase()}</p>
<Form
action={
configureAction(
updateCmsImageAction,
{ params: { cmsImageId } }
).bind(null, { data: { imageSize: changeToSize } })
}
submitText={`change to ${changeToSize.toLocaleLowerCase()}`}
refreshOnSuccess
submitColor="primary"
/>
{displayImage ? <Image width={200} image={displayImage} /> : <p>Ingen bilde valgt enda</p>}

Check warning on line 104 in src/app/_components/Cms/CmsImage/ChangeImage.tsx

View workflow job for this annotation

GitHub Actions / lint

Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images
</div>
)
}
<i>{displayImage ? `image name: ${displayImage.name}` : 'ingen bilde valgt enda'}</i>
{renderSubmitControls()}
</div>
)
}
Expand Down
12 changes: 4 additions & 8 deletions src/app/_components/Cms/CmsImage/ChangeImageForm.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
'use client'
import Form from '@/components/Form/Form'
import { ImageSelectionContext } from '@/contexts/ImageSelection'
import { configureAction } from '@/services/configureAction'
import { useContext } from 'react'
import type { Image as ImageT } from '@/prisma-generated-pn-types'
import type { UpdateCmsImageAction } from '@/cms/images/types'

type PropTypes = {
cmsImageId: number
selectedImage: ImageT
className?: string
updateCmsImageAction: UpdateCmsImageAction
}

export default function ChangeImageForm({ cmsImageId, className, updateCmsImageAction }: PropTypes) {
const selection = useContext(ImageSelectionContext)

if (!selection?.selectedImage) throw new Error('ImageSelectionContext required to use ChangeImage')

export default function ChangeImageForm({ cmsImageId, selectedImage, className, updateCmsImageAction }: PropTypes) {
return (
<Form
className={className}
Expand All @@ -24,7 +20,7 @@ export default function ChangeImageForm({ cmsImageId, className, updateCmsImageA
configureAction(
updateCmsImageAction,
{ params: { cmsImageId } }
).bind(null, { data: { imageId: selection?.selectedImage?.id } })
).bind(null, { data: { imageId: selectedImage.id } })
}
submitText="change"
refreshOnSuccess
Expand Down
Loading
Loading