Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
fallback for window.env
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Dec 9, 2021
1 parent 51659e4 commit f9ddb2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
24 changes: 17 additions & 7 deletions src/customizations/volto/components/theme/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import { compose } from 'redux';
import { connect } from 'react-redux';
import config from '@plone/volto/registry';
import { setCurrentVersion } from '@eeacms/volto-forests-theme/actions';
import {
RAZZLE_FRONTEND_VERSION,
RAZZLE_FRONTEND_VERSION_URL,
RAZZLE_FRONTEND_PUBLISHED_AT,
} from '@eeacms/volto-forests-theme/constants/runtime';

/**
* Component to display the footer.
Expand All @@ -36,23 +41,28 @@ const Footer = ({
navItems,
}) => {
const { settings } = config;
let env = React.useRef(__CLIENT__ && window.env);

const dtf = new Intl.DateTimeFormat('en', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
});

const published_at = dtf.format(
new Date(
settings.frontendMeta?.published_at || currentVersion.published_at,
settings.frontendMeta?.published_at ||
env?.current.RAZZLE_FRONTEND_PUBLISHED_AT ||
RAZZLE_FRONTEND_PUBLISHED_AT, //needed for cypress
),
);
const version_url = settings.frontendMeta.version_url
? settings.frontendMeta.version_url
: currentVersion.version_url;
const version_url =
settings.frontendMeta.version_url ??
(env?.current.RAZZLE_FRONTEND_VERSION_URL || RAZZLE_FRONTEND_VERSION_URL);

const version = settings.frontendMeta.version
? settings.frontendMeta.version
: currentVersion.version;
const version =
settings.frontendMeta.version ??
(env?.current.RAZZLE_FRONTEND_VERSION || RAZZLE_FRONTEND_VERSION);
if (
settings.frontendMeta.published_at &&
settings.frontendMeta.version_url &&
Expand Down
14 changes: 3 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import { applyConfig as installFiseFrontend } from './localconfig';

import ObjectListInlineWidget from './components/manage/Widgets/ObjectListInlineWidget';
import reducers from '@eeacms/volto-forests-theme/reducers';
import {
RAZZLE_FRONTEND_VERSION,
RAZZLE_FRONTEND_VERSION_URL,
RAZZLE_FRONTEND_PUBLISHED_AT,
} from './constants/runtime';

import './slate-styles.css';

Expand All @@ -24,12 +19,9 @@ export default function applyConfig(config) {
config.settings = {
...config.settings,
frontendMeta: {
version: process.env.RAZZLE_FRONTEND_VERSION ?? RAZZLE_FRONTEND_VERSION,
version_url:
process.env.RAZZLE_FRONTEND_VERSION_URL ?? RAZZLE_FRONTEND_VERSION_URL,
published_at:
process.env.RAZZLE_FRONTEND_PUBLISHED_AT ??
RAZZLE_FRONTEND_PUBLISHED_AT,
version: process.env.RAZZLE_FRONTEND_VERSION,
version_url: process.env.RAZZLE_FRONTEND_VERSION_URL,
published_at: process.env.RAZZLE_FRONTEND_PUBLISHED_AT,
},
timezone: 'CET',
pathsWithFullobjects: ['/news', '/events'],
Expand Down

0 comments on commit f9ddb2d

Please sign in to comment.