Skip to content

feat(next): updated version view #12027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b231bde
updated version view
AlessioGr Apr 2, 2025
7358092
fix styling, reduce re-rendering
AlessioGr Apr 4, 2025
cb44882
generic version view improvements
AlessioGr Apr 7, 2025
77a59d7
update payload-types
AlessioGr Apr 7, 2025
c06716b
update translations
AlessioGr Apr 7, 2025
65de666
Merge remote-tracking branch 'origin/main' into feat/version-view
AlessioGr Apr 7, 2025
cc9732c
fix selecting previous version
AlessioGr Apr 7, 2025
adb5bb2
improve variable naming
AlessioGr Apr 7, 2025
231426a
improve date diffing
AlessioGr Apr 7, 2025
90069d4
naming improvements
AlessioGr Apr 7, 2025
ef9fc60
fix createdAt and updatedAt diff values
AlessioGr Apr 7, 2025
c449733
more reliable search param handling
AlessioGr Apr 7, 2025
2be5efa
ensure empty tab and collapsible fields are not shown if modifiedOnly…
AlessioGr Apr 7, 2025
529e97c
fix unsafe variable access
AlessioGr Apr 7, 2025
d64a721
fix scss
AlessioGr Apr 7, 2025
32a46a2
fix global versions
AlessioGr Apr 7, 2025
c383b6d
Merge remote-tracking branch 'origin/main' into feat/version-view
AlessioGr Apr 11, 2025
ec6502a
lexical diff style adjustments
AlessioGr Apr 11, 2025
75b6a3d
style improvements
AlessioGr Apr 11, 2025
ffee43d
restructure html differ location
AlessioGr Apr 11, 2025
7060fb0
get rid of react-diff-viewer-continued, implement character tokenizat…
AlessioGr Apr 11, 2025
2e6addd
style improvements
AlessioGr Apr 11, 2025
77662ca
nicely centered styling
AlessioGr Apr 11, 2025
f51ccae
fix lint
AlessioGr Apr 11, 2025
bde7a2d
fix lint
AlessioGr Apr 11, 2025
e833332
Merge remote-tracking branch 'origin/main' into feat/version-view
AlessioGr Apr 11, 2025
76b28d4
fix vertical line
AlessioGr Apr 11, 2025
37b1f04
fix diff collapser spacing
AlessioGr Apr 11, 2025
5d35989
fix locale label styling
AlessioGr Apr 11, 2025
53e7a98
fix selected locales reactivity
AlessioGr Apr 11, 2025
e1a9ef4
fix richtext styling, ensure even diff paddings
AlessioGr Apr 11, 2025
1c5edfc
diff collapser hover background
AlessioGr Apr 11, 2025
9bfd472
fix pre background color
AlessioGr Apr 11, 2025
c18e570
improve fields changed styling
AlessioGr Apr 11, 2025
832ee4e
new locale selector
AlessioGr Apr 12, 2025
b3d367c
Merge remote-tracking branch 'origin/main' into feat/version-view
AlessioGr Apr 12, 2025
b4af0b1
fix: separator line not always in the center and overlapped by parent…
AlessioGr Apr 12, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"clean:build": "node ./scripts/delete-recursively.js 'media/' '**/dist/' '**/.cache/' '**/.next/' '**/.turbo/' '**/tsconfig.tsbuildinfo' '**/payload*.tgz' '**/meta_*.json'",
"clean:build:allowtgz": "node ./scripts/delete-recursively.js 'media/' '**/dist/' '**/.cache/' '**/.next/' '**/.turbo/' '**/tsconfig.tsbuildinfo' '**/meta_*.json'",
"clean:cache": "node ./scripts/delete-recursively.js node_modules/.cache! packages/payload/node_modules/.cache! .next/*",
"dev": "cross-env NODE_OPTIONS=--no-deprecation tsx ./test/dev.ts",
"dev": "cross-env NODE_OPTIONS=\"--no-deprecation --max-old-space-size=16384\" tsx ./test/dev.ts",
"dev:generate-db-schema": "pnpm runts ./test/generateDatabaseSchema.ts",
"dev:generate-graphql-schema": "pnpm runts ./test/generateGraphQLSchema.ts",
"dev:generate-importmap": "pnpm runts ./test/generateImportMap.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
"http-status": "2.1.0",
"path-to-regexp": "6.3.0",
"qs-esm": "7.0.2",
"react-diff-viewer-continued": "4.0.5",
"sass": "1.77.4",
"uuid": "10.0.0"
},
Expand Down
18 changes: 11 additions & 7 deletions packages/next/src/views/Version/Default/SetStepNav.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'use client'
import type { StepNavItem } from '@payloadcms/ui'
import type { ClientCollectionConfig, ClientField, ClientGlobalConfig } from 'payload'
import type {
ClientCollectionConfig,
ClientField,
ClientGlobalConfig,
TypeWithVersion,
} from 'payload'
import type React from 'react'

import { getTranslation } from '@payloadcms/translations'
Expand All @@ -12,7 +17,7 @@ import { useEffect } from 'react'
export const SetStepNav: React.FC<{
readonly collectionConfig?: ClientCollectionConfig
readonly collectionSlug?: string
readonly doc: any
readonly doc: TypeWithVersion<any>
readonly fields: ClientField[]
readonly globalConfig?: ClientGlobalConfig
readonly globalSlug?: string
Expand All @@ -36,20 +41,19 @@ export const SetStepNav: React.FC<{

const useAsTitle = collectionConfig?.admin?.useAsTitle || 'id'
const pluralLabel = collectionConfig?.labels?.plural
const formattedDoc = doc.version ? doc.version : doc

if (formattedDoc) {
if (doc.version) {
if (useAsTitle !== 'id') {
const titleField = fields.find((f) => {
const fieldName = 'name' in f ? f.name : undefined
return Boolean(fieldAffectsData(f) && fieldName === useAsTitle)
})

if (titleField && formattedDoc[useAsTitle]) {
if (titleField && doc.version[useAsTitle]) {
if ('localized' in titleField && titleField.localized) {
docLabel = formattedDoc[useAsTitle]?.[locale.code]
docLabel = doc.version[useAsTitle]?.[locale.code]
} else {
docLabel = formattedDoc[useAsTitle]
docLabel = doc.version[useAsTitle]
}
} else {
docLabel = `[${t('general:untitled')}]`
Expand Down
135 changes: 103 additions & 32 deletions packages/next/src/views/Version/Default/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,143 @@
width: 100%;
padding-bottom: var(--spacing-view-bottom);

&__wrap {
padding-top: calc(var(--base) * 1.5);
display: flex;
flex-direction: column;
gap: var(--base);
}
&-controls-top {
border-bottom: 1px solid var(--theme-elevation-100);
padding: 16px var(--gutter-h) 16px var(--gutter-h);

&__header-wrap {
display: flex;
flex-direction: column;
gap: calc(var(--base) / 4);
}
&__wrapper {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;

&__header {
display: flex;
align-items: center;
flex-wrap: wrap;
&-actions {
display: flex;
flex-direction: row;
align-items: center;
gap: var(--base);
}
}

h2 {
margin: 0;
font-size: 18px;
}
}

&__created-at {
margin: 0;
color: var(--theme-elevation-500);
}
&-controls-bottom {
border-bottom: 1px solid var(--theme-elevation-100);
padding: 16px var(--gutter-h) 16px var(--gutter-h);
position: relative;

&__controls {
display: flex;
gap: var(--base);
// Vertical separator line
&::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 50%;
width: 1px;
background-color: var(--theme-elevation-100);
transform: translateX(-50%); // Center the line
}

&__wrapper {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: var(--base);
gap: var(--base);
}

&__version-from {
}

> * {
flex-basis: 100%;
&__version-to {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: var(--base);

h2 {
font-size: 13px;
font-weight: 400;
}
}
}

&__restore {
margin: 0 0 0 var(--base);
div {
margin-block: 0;
}
}

&__modifiedCheckBox {
margin: 0 0 0 var(--base);
display: flex;
align-items: center;
}

@include mid-break {
&__intro,
&__header {
display: block;
&__diff-wrap {
padding-top: calc(var(--base) * 1.5);
display: flex;
flex-direction: column;
gap: var(--base);
position: relative;

// Vertical separator line
&::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 50%;
width: 1px;
background-color: var(--theme-elevation-100);
transform: translateX(-50%); // Center the line
z-index: 2;
}
}

@include mid-break {
&__controls {
flex-direction: column;
gap: calc(var(--base) / 4);
}


&__restore {
margin: calc(var(--base) * 0.5) 0 0 0;
}

&-controls-top {
&__wrapper {
flex-direction: column;
align-items: flex-start;

.view-version__modifiedCheckBox {
margin-left: 0;
}
}
}

&-controls-bottom {
&__version-from {
display: flex;
justify-content: flex-start;
align-items: center;
}

&__version-to {
flex-direction: column;
align-items: flex-start;
gap: 0;
}
}
}

@include small-break {
&__wrap {
&__diff-wrap {
padding-top: calc(var(--base) / 2);
gap: calc(var(--base) / 2);
}
}
}
Expand Down
Loading
Loading