Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
2b5caf4
chore: set up cmsParagraph create action
JohanHjelsethStorstad Oct 11, 2025
37dbb92
feat: add the ownershipChack to sub-operations
JohanHjelsethStorstad Oct 11, 2025
32144d8
fix: do not delete special paragraphs
JohanHjelsethStorstad Oct 11, 2025
4ecc7f1
chore: remove files from cmsParagraphs
JohanHjelsethStorstad Oct 11, 2025
37daf6c
feat: make types to infer action type based on suboperation/operation…
JohanHjelsethStorstad Oct 14, 2025
1039534
chore: change (home) to (frontpage) in /app to anticipate new frontpa…
JohanHjelsethStorstad Oct 14, 2025
49cf9e8
feat: add frontpage service
JohanHjelsethStorstad Oct 14, 2025
82ce6f1
chore: implement an action for reading the special cms paragraphs for…
JohanHjelsethStorstad Oct 14, 2025
2453568
chore: remove the cms_admin bypass permission as bypass will not exis…
JohanHjelsethStorstad Oct 14, 2025
87a12ab
chore: add action to update special frontpage cms paragrapgs by imple…
JohanHjelsethStorstad Oct 14, 2025
6e3e764
chore: implement special cms paragraphs for cabin booking
JohanHjelsethStorstad Oct 15, 2025
f1525ce
chore: implement special cms paragraph actions for career info
JohanHjelsethStorstad Oct 15, 2025
0165f8f
chore: implement special cms paragraph actions for interest groups
JohanHjelsethStorstad Oct 16, 2025
65f6ff1
chore: implement the method for updating school paragraph
JohanHjelsethStorstad Oct 16, 2025
a075a36
refactor: make readSchool into a operation to use it in the ownership…
JohanHjelsethStorstad Oct 16, 2025
e902b7f
refactor: change naming in operations for committees to avoid writing…
JohanHjelsethStorstad Oct 16, 2025
b75382a
chore: implement operations to update the committee paragraphs
JohanHjelsethStorstad Oct 16, 2025
3ab0650
chore: implement update operation for event paragraph
JohanHjelsethStorstad Oct 16, 2025
8eb92c1
chore: change create cms paragraph to normal operation ServerOnly as …
JohanHjelsethStorstad Oct 16, 2025
7215b30
chore: set up operations files and schemas for cms images
JohanHjelsethStorstad Oct 16, 2025
b523960
refactor: sets up cms image service as suboperations
JohanHjelsethStorstad Oct 18, 2025
3d20cd0
chore: change CmsImage frontend components to take inm interfaces for…
JohanHjelsethStorstad Oct 18, 2025
533b79d
chore: implement special read / update of cms images for frontpage se…
JohanHjelsethStorstad Oct 18, 2025
6ed51b8
chore: implement two update cms image routes for committee service
JohanHjelsethStorstad Oct 18, 2025
105e8d3
chore: implement cms image update for event cover image
JohanHjelsethStorstad Oct 20, 2025
af923c5
chore: implement update cms image for company logos
JohanHjelsethStorstad Oct 20, 2025
1ff885a
fix: make the calls to ownershipChack and autherizer also be wrapped …
JohanHjelsethStorstad Oct 20, 2025
ce4bbd8
chore: implement update cms image for schools
JohanHjelsethStorstad Oct 20, 2025
b012c0d
chore: change ombul service to use new cms image create operation
JohanHjelsethStorstad Oct 20, 2025
b5c0cd9
refactor: make the read ombul methods into service operations
JohanHjelsethStorstad Oct 20, 2025
bf1ed2d
chore: implement cms image update for ombul cover images
JohanHjelsethStorstad Oct 20, 2025
9670a66
style: fix linting and reference to old functions replacesd with serv…
JohanHjelsethStorstad Oct 20, 2025
3b39a9d
reafctor: all cmsLink services into operations
JohanHjelsethStorstad Oct 20, 2025
61ec27b
chore: set up the action types
JohanHjelsethStorstad Oct 20, 2025
ba01f37
chore: set up the action types
JohanHjelsethStorstad Oct 20, 2025
0ab86ad
chore: send action to update cms link into the cms link component
JohanHjelsethStorstad Oct 20, 2025
62d446a
chore: implement update cms link for schools
JohanHjelsethStorstad Oct 20, 2025
cbd90b8
refactor: articleSection service to be in the subservice form and rem…
JohanHjelsethStorstad Oct 20, 2025
7540da6
refactor: pass the actions needed to update cms article sections into…
JohanHjelsethStorstad Oct 20, 2025
978ed7c
chore: implement creazy utility to implement all needed article secti…
JohanHjelsethStorstad Oct 21, 2025
3023543
chore: implement cms article section actions for interest groups
JohanHjelsethStorstad Oct 21, 2025
76d341c
refactor: make seperate implement file for articleSection
JohanHjelsethStorstad Oct 22, 2025
540ab8d
chore: implement schemas for articles and remove validation
JohanHjelsethStorstad Oct 22, 2025
2df90ea
merge branch main into refactor/cms-subservice
JohanHjelsethStorstad Oct 22, 2025
0d3d2db
chore: implement a public cms article service for special cms article…
JohanHjelsethStorstad Oct 22, 2025
ff4c233
refactor: make all article actions into (sub)operations
JohanHjelsethStorstad Oct 22, 2025
45fbdd0
chore: updates Article component to take in all needed actions as props
JohanHjelsethStorstad Oct 22, 2025
3ae7a4a
fix: clearer id names in cms subservice as a schema with field 'id' c…
JohanHjelsethStorstad Oct 23, 2025
a4d7510
feat: implement creazy abstaction to implement all 10 article operati…
JohanHjelsethStorstad Oct 23, 2025
6c82a66
refactor: make articleCategories into a proper service with operation…
JohanHjelsethStorstad Oct 23, 2025
9b6800a
refactor: make news into a proper service with operations and impleme…
JohanHjelsethStorstad Oct 23, 2025
782da36
chore: implement update actions for jobAd artcile
JohanHjelsethStorstad Oct 23, 2025
b5106f2
chore: use the actions in jobads
JohanHjelsethStorstad Oct 23, 2025
516fc78
chore: implement operations for committee articles
JohanHjelsethStorstad Oct 23, 2025
1149316
chore: implement update article for public articles
JohanHjelsethStorstad Oct 23, 2025
6c1fe49
style: fix linter errors
JohanHjelsethStorstad Oct 23, 2025
90e616f
fix: use of old interfaces here and there after a lot of updates to o…
JohanHjelsethStorstad Oct 23, 2025
22a47a4
fix: bad refernce to name variable
JohanHjelsethStorstad Oct 23, 2025
d6862ec
fix: in expectedArgsArePresent it did not match with the implementati…
JohanHjelsethStorstad Oct 23, 2025
5c8841d
chore: add some useful error messages to the authers
JohanHjelsethStorstad Oct 23, 2025
e97b52c
fix: missing tx transaction reference
JohanHjelsethStorstad Oct 23, 2025
4c2eb73
fix: params schema not the operationdields were passed to operation i…
JohanHjelsethStorstad Oct 23, 2025
c3b806a
fix: must await addSectionToArticle before refreshing
JohanHjelsethStorstad Oct 23, 2025
98b11e1
style: auto-fix minor linting
JohanHjelsethStorstad Oct 23, 2025
49e3ee5
fix: on destroyOnEmpty for ArticleSections cmsLink not existing was n…
JohanHjelsethStorstad Oct 23, 2025
501a6e8
style: unnecessary passing of prisma to operation
JohanHjelsethStorstad Oct 23, 2025
483018e
style: remove duplicate special cms image owned by front-page
JohanHjelsethStorstad Oct 23, 2025
9d3c7fc
fix: missing tx client - prisma was used instead
JohanHjelsethStorstad Oct 23, 2025
5a1e9dd
style: fix spelling of OwnershipCheck type
JohanHjelsethStorstad Oct 23, 2025
648d61a
chore: remove duplicate operationImplementationFields: OperationImple…
JohanHjelsethStorstad Oct 23, 2025
3ac2278
fix: bypass auth when deleting article from article category when usi…
JohanHjelsethStorstad Oct 23, 2025
1f99601
fix: make sure cover images for articles are deleted when articles ar…
JohanHjelsethStorstad Oct 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styles from './layout.module.scss'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import React from 'react'

type PropTypes = {
Expand All @@ -14,7 +15,14 @@ export default function AuthLayout({ children }: PropTypes) {
{children}
</div>
<div className={styles.image}>
<SpecialCmsImage special="AUTH_ICON" alt="en kappemann sin hatt" width={200}/>
<SpecialCmsImage
special="AUTH_ICON"
alt="en kappemann sin hatt"
width={200}
//TODO: Probably call through other service see comments in frontpage operations
readSpecialCmsImageAction={readSpecialCmsImageFrontpage}
updateCmsImageAction={updateSpecialCmsImageFrontpage}
/>
</div>
</div>
</div>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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 { faAngleDown } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
Expand All @@ -28,7 +29,12 @@ export default async function LoggedInLandingPage() {
<div className={`${styles.part} ${styles.frontImg}`}>
<div className={styles.frontInfo}>
<div>
<SpecialCmsImage special="FRONTPAGE_LOGO" width={300} />
<SpecialCmsImage
special="FRONTPAGE_LOGO"
width={300}
readSpecialCmsImageAction={readSpecialCmsImageFrontpage}
updateCmsImageAction={updateSpecialCmsImageFrontpage}
/>
<div className={styles.socials}>
<SocialIcons />
</div>
Expand Down
14 changes: 11 additions & 3 deletions src/app/(home)/LoggedOut.tsx → src/app/(frontpage)/LoggedOut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MazeMap from '@/components/MazeMap/MazeMap'
import SocialIcons from '@/components/SocialIcons/SocialIcons'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
import YouTube from '@/components/YouTube/YouTube'
import { readSpecialCmsImageFrontpage, updateSpecialCmsImageFrontpage } from '@/services/frontpage/actions'
import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Link from 'next/link'
Expand All @@ -15,7 +16,12 @@ export default async function LoggedOutLandingPage() {
<div className={`${styles.part} ${styles.frontImg}`}>
<div className={styles.frontInfo}>
<div>
<SpecialCmsImage special="FRONTPAGE_LOGO" width={300}/>
<SpecialCmsImage
special="FRONTPAGE_LOGO"
width={300}
readSpecialCmsImageAction={readSpecialCmsImageFrontpage}
updateCmsImageAction={updateSpecialCmsImageFrontpage}
/>

<Link href="login">Logg inn</Link>
<Link href="infopages/nystudent">Ny student</Link>
Expand All @@ -30,6 +36,7 @@ export default async function LoggedOutLandingPage() {
</div>
</div>
<Section
position="left"
specialCmsImage="FRONTPAGE_1"
specialCmsParagraph="FRONTPAGE_1"
lesMer="/articles"
Expand All @@ -39,7 +46,7 @@ export default async function LoggedOutLandingPage() {

<InfoBubbles />
<Section
right
position="right"
specialCmsImage="FRONTPAGE_2"
specialCmsParagraph="FRONTPAGE_2"
lesMer="/articles"
Expand All @@ -52,13 +59,14 @@ export default async function LoggedOutLandingPage() {
<YouTube src="https://www.youtube.com/watch?v=I-zNLW4ILu4" />
<div className={styles.emptyPart} />
<Section
position="left"
specialCmsImage="FRONTPAGE_3"
specialCmsParagraph="FRONTPAGE_3"
lesMer="/career"
imgWidth={550}
/>
<Section
right
position="right"
specialCmsImage="FRONTPAGE_4"
specialCmsParagraph="FRONTPAGE_4"
lesMer="infopages/loccom"
Expand Down
54 changes: 54 additions & 0 deletions src/app/(frontpage)/Section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import styles from './Section.module.scss'
import SpecialCmsParagraph from '@/components/Cms/CmsParagraph/SpecialCmsParagraph'
import SpecialCmsImage from '@/components/Cms/CmsImage/SpecialCmsImage'
import {
readSpecialCmsImageFrontpage,
readSpecialCmsParagraphFrontpageSection,
updateSpecialCmsImageFrontpage,
updateSpecialCmsParagraphFrontpageSection
} from '@/services/frontpage/actions'
import React from 'react'
import Link from 'next/link'
import type {
SpecialCmsImage as SpecialCmsImageT,
SpecialCmsParagraph as SpecialCmsParagraphT
} from '@prisma/client'

type PropTypes = {
specialCmsImage: SpecialCmsImageT,
specialCmsParagraph: SpecialCmsParagraphT,
lesMer: string,
position: 'left' | 'right',
imgWidth: number,
id?: string,
}

function Section({ specialCmsImage, specialCmsParagraph, lesMer, position, imgWidth, id }: PropTypes) {
const imgContainer = (
<div style={{ width: imgWidth }} className={styles.imgContainer}>
<SpecialCmsImage
special={specialCmsImage}
width={imgWidth}
readSpecialCmsImageAction={readSpecialCmsImageFrontpage}
updateCmsImageAction={updateSpecialCmsImageFrontpage}
/>
</div>
)
return (
<div id={id} className={`${styles.section} ${position === 'right' && styles.blue}`}>
{position === 'left' && imgContainer}
<div>
<SpecialCmsParagraph
className={styles.paragraph}
special={specialCmsParagraph}
readSpecialCmsParagraphAction={readSpecialCmsParagraphFrontpageSection}
updateCmsParagraphAction={updateSpecialCmsParagraphFrontpageSection}
/>
<Link className={styles.readMore} href={lesMer}>Les mer</Link>
</div>
{position === 'right' && imgContainer}
</div>
)
}

export default Section
File renamed without changes.
File renamed without changes.
38 changes: 0 additions & 38 deletions src/app/(home)/Section.tsx

This file was deleted.

24 changes: 16 additions & 8 deletions src/app/_components/Cms/Article/AddSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,36 @@

import styles from './AddSection.module.scss'
import AddParts from '@/cms/AddParts'
import { addSectionToArticleAction } from '@/cms/articles/actions'
import { maxSections } from '@/cms/articles/ConfigVars'
import { maxSections } from '@/cms/articles/constants'
import useEditing from '@/hooks/useEditing'
import { useRouter } from 'next/navigation'
import type { ArticleSectionPart } from '@/cms/articleSections/types'
import type { AddSectionToArticleAction } from '@/cms/articles/types'
import type { ConfiguredAction } from '@/services/actionTypes'

type PropTypes = {
articleId: number,
currentNumberSections: number,
addSectionToArticleAction: ConfiguredAction<AddSectionToArticleAction>
}

export default function AddSection({ articleId, currentNumberSections }: PropTypes) {
export default function AddSection({
currentNumberSections,
addSectionToArticleAction
}: PropTypes) {
const { refresh } = useRouter()
const canEdit = useEditing({}) //TODO: check visibility of article for user and pass it to useEditing
if (!canEdit) return null

const handleAdd = async (part: ArticleSectionPart) => {
addSectionToArticleAction(articleId, {
[part]: true,
const handleAdd = async (includePart: ArticleSectionPart) => {
await addSectionToArticleAction({
data: {
includeParts: {
[includePart]: true,
}
}
})
refresh()
}
if (!canEdit) return null
return (
<span className={styles.AddSection}>
{
Expand Down
62 changes: 54 additions & 8 deletions src/app/_components/Cms/Article/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ import SectionMover from './SectionMover'
import ChangeName from './ChangeName'
import CmsImage from '@/cms/CmsImage/CmsImage'
import SlideInOnView from '@/components/SlideInOnView/SlideInOnView'
import ArticleSection from '@/cms/ArticleSection/ArticleSection'
import { configureAction } from '@/services/configureAction'
import ArticleSection, {
type ArticleSectionActions
} from '@/cms/ArticleSection/ArticleSection'
import type { ReactNode } from 'react'
import type { ExpandedArticle } from '@/cms/articles/types'
import type {
AddSectionToArticleAction,
ExpandedArticle,
ReorderArticleSectionsAction,
UpdateArticleAction
} from '@/cms/articles/types'
import type { UpdateCmsImageAction } from '@/cms/images/types'

export type PropTypes = {
article: ExpandedArticle,
Expand All @@ -15,6 +24,13 @@ export type PropTypes = {
noMargin?: boolean
sideBarContent?: ReactNode
sideBarClassName?: string
actions: {
updateCoverImageAction: UpdateCmsImageAction,
updateArticleAction: UpdateArticleAction,
addSectionToArticleAction: AddSectionToArticleAction,
reorderArticleSectionsAction: ReorderArticleSectionsAction,
articleSections: ArticleSectionActions
}
}

export default function Article({
Expand All @@ -24,14 +40,27 @@ export default function Article({
noMargin = false,
sideBarContent,
sideBarClassName,
actions,
}: PropTypes) {
return (
<span className={styles.Article}>
{hideCoverImage ? <></> : (
<span className={`${coverImageClass} ${styles.coverImage}`}>
<CmsImage width={500} cmsImage={article.coverImage} />
<CmsImage
width={500}
cmsImage={article.coverImage}
updateCmsImageAction={actions.updateCoverImageAction}
/>
<SlideInOnView direction="bottom">
<ChangeName article={article} />
<ChangeName
article={article}
updateArticleAction={
configureAction(
actions.updateArticleAction,
{ params: { articleId: article.id } }
)
}
/>
</SlideInOnView>
</span>
)}
Expand All @@ -41,13 +70,22 @@ export default function Article({
article.articleSections.sort((a, b) => (a.order - b.order)).map((section, i) => (
<SlideInOnView direction="left" key={section.id}>
<span className={styles.moveSection}>
<ArticleSection articleSection={section} />
<ArticleSection actions={actions.articleSections} articleSection={section} />
<SectionMover
showUp={i !== 0}
showDown={i !== article.articleSections.length - 1}
articleId={article.id}
sectionId={section.id}
className={styles.moverComponent}
reorderArticleSectionsAction={
configureAction(
actions.reorderArticleSectionsAction,
{
params: {
articleId: article.id,
sectionId: section.id
}
}
)
}
/>
</span>
</SlideInOnView>
Expand All @@ -63,7 +101,15 @@ export default function Article({
</aside>
)}
<div className={styles.addSection}>
<AddSection articleId={article.id} currentNumberSections={article.articleSections.length} />
<AddSection
currentNumberSections={article.articleSections.length}
addSectionToArticleAction={
configureAction(
actions.addSectionToArticleAction,
{ params: { articleId: article.id } }
)
}
/>
</div>
</span>
)
Expand Down
10 changes: 5 additions & 5 deletions src/app/_components/Cms/Article/ChangeName.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use client'
import styles from './ChangeName.module.scss'
import EditableTextField from '@/components/EditableTextField/EditableTextField'
import { updateArticleAction } from '@/services/cms/articles/actions'
import React, { useState } from 'react'
import { usePathname } from 'next/navigation'
import type { ExpandedArticle } from '@/cms/articles/types'
import type { ExpandedArticle, UpdateArticleAction } from '@/cms/articles/types'
import type { ConfiguredAction } from '@/services/actionTypes'

type PropTypes = {
article: ExpandedArticle
updateArticleAction: ConfiguredAction<UpdateArticleAction>
}

export default function ChangeName({ article }: PropTypes) {
const changeName = updateArticleAction.bind(null, article.id)
export default function ChangeName({ article, updateArticleAction }: PropTypes) {
const currentPath = usePathname()
const [currentName, setCurrentName] = useState(article.name)
const successCallback = (data: ExpandedArticle | undefined) => {
Expand All @@ -27,7 +27,7 @@ export default function ChangeName({ article }: PropTypes) {
<EditableTextField
formProps={
{
action: changeName,
action: updateArticleAction,
successCallback
}
}
Expand Down
Loading