Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@ import React, { useState, useEffect } from 'react'
import { Dialog, Button } from '@neos-project/react-ui-components'

type ApiData = {
clientNotificationTimestamp: string
clientNotificationTimestamp: number
}

const WhatsNewNotificationModal = () => {
const [showModal, setShowModal] = useState<boolean>(false)
const [apiData, setApiData] = useState<ApiData | null>(null);
const [apiTimestamp, setApiTimestamp] = useState<number>(0);

// Fetch data from an API
const fetchData = async () => {
try {
const response = await fetch('/api/whats-new/in-project');
const data = await response.json();
setApiData(data);
const data:ApiData = await response.json();
setApiTimestamp(data.clientNotificationTimestamp);
} catch (error) {
console.error('Error fetching API data:', error);
}
};

useEffect(() => {
const cookies = Object.fromEntries(document.cookie.split('; ').map(c => c.split('=')));
fetchData();
}, [])

!apiData && fetchData();
useEffect(() => {
if (!apiTimestamp) {
return;
}
const cookies = Object.fromEntries(document.cookie.split('; ').map(c => c.split('=')));
const timestamp = cookies.whatsNewNoteClosedTimestamp ? parseInt(cookies.whatsNewNoteClosedTimestamp) : 0;
const currentTime = Date.now();

if (!cookies.whatsNewNoteClosedTimestamp || (apiData && cookies.whatsNewNoteClosedTimestamp < apiData.clientNotificationTimestamp)) {
if (!timestamp || (timestamp < apiTimestamp && currentTime > apiTimestamp)) {
setShowModal(true)
}
}, [apiData, fetchData])
}, [apiTimestamp])

const closeModal = () => {
const expires = new Date();
Expand Down
96 changes: 27 additions & 69 deletions Resources/Private/build.mjs
Original file line number Diff line number Diff line change
@@ -1,89 +1,47 @@
import esbuild from 'esbuild'
import { sassPlugin } from 'esbuild-sass-plugin'
import extensibilityMap from '@neos-project/neos-ui-extensibility/extensibilityMap.json' assert { type: 'json' }
import extensibilityMap from '@neos-project/neos-ui-extensibility/extensibilityMap.json' with { type: 'json' }

const isWatchMode = process.argv.includes('--watch')

/**
* This file contains the JS/CSS bundler configuration, as executed on `npm run build`
* This file contains the JS/CSS bundler configuration, as executed on `yarn build`
*/
/* esbuild
.build({
// Generic Options (shared between build.js and build-watch.js)
entryPoints: {
BackendModal: './BackendModal/src/index.js',
main: './main.scss'
},
sourceRoot: './BackendModal/src',
target: ['esnext'],
// To prevent shortening of top, right, bottom, left into inset because it is not well supported yet (https://github.com/evanw/esbuild/pull/1758/files)
supported: { 'inset-property': false },
bundle: true,
sourcemap: isWatchMode,
plugins: [sassPlugin({ watch: isWatchMode })],
outdir: '../Public/',
loader: {
'.js': 'jsx',
'.json': 'json'
},

// Specific options for "npm run build"
minify: false,
//watch: isWatchMode,
external: ['react'],
alias: extensibilityMap
})
.then(ctx => ctx.watch())
.catch(() => process.exit(1)) */
const defaultOptions = {
entryPoints: {
BackendModal: './BackendModal/src/index.js',
main: './main.ts',
styles: './main.scss'
},
sourceRoot: './BackendModal/src',
target: ['esnext'],
supported: { 'inset-property': false },
bundle: true,
sourcemap: true,
plugins: [sassPlugin({ watch: isWatchMode })],
outdir: '../Public/',
loader: {
'.js': 'jsx',
'.json': 'json'
},
minify: false,
external: ['react', '/_Resources/*'],
alias: extensibilityMap
}


if (isWatchMode) {
console.log('Watching for changes...');
esbuild
.context({
entryPoints: {
BackendModal: './BackendModal/src/index.js',
main: './main.ts',
styles: './main.scss'
},
sourceRoot: './BackendModal/src',
target: ['esnext'],
supported: { 'inset-property': false },
bundle: true,
sourcemap: true,
plugins: [sassPlugin({ watch: true })],
outdir: '../Public/',
loader: {
'.js': 'jsx',
'.json': 'json'
},
minify: false,
external: ['react', '/_Resources/*'],
alias: extensibilityMap
})
.context(defaultOptions)
.then(ctx => ctx.watch())
.catch(() => process.exit(1));
} else {
esbuild
.build({
entryPoints: {
BackendModal: './BackendModal/src/index.js',
main: './main.ts',
styles: './main.scss'
},
sourceRoot: './BackendModal/src',
target: ['esnext'],
supported: { 'inset-property': false },
bundle: true,
sourcemap: false,
plugins: [sassPlugin()],
outdir: '../Public/',
loader: {
'.js': 'jsx',
'.json': 'json'
},
minify: false,
external: ['react', '/_Resources/*'],
alias: extensibilityMap
...defaultOptions,
minify: true,
})
.catch(() => process.exit(1));
}
144 changes: 2 additions & 142 deletions Resources/Public/BackendModal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 2 additions & 15 deletions Resources/Public/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 2 additions & 48 deletions Resources/Public/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.