Skip to content
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

Volto upgrade 16.20.1 #129

Merged
merged 9 commits into from
Apr 20, 2023
Merged
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
Binary file added cypress/fixtures/halfdome2022.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@mdi/svg": "7.2.96",
"html-react-parser": "3.0.15",
"material-icons": "1.13.4",
"nsw-design-system": "3.3.0",
"nsw-design-system": "3.5.1",
"react-color": "2.19.3",
"volto-form-block": "3.0.1",
"volto-google-analytics": "2.0.0",
Expand All @@ -39,7 +39,7 @@
"volto-subfooter": "2.0.0"
},
"peerDependencies": {
"@plone/volto": ">= 16.6.0 < 17.0.0"
"@plone/volto": ">= 16.20.1 < 17.0.0"
},
"devDependencies": {
"@plone/scripts": ">= 2.2.2",
Expand Down
27 changes: 1 addition & 26 deletions razzle.extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,7 @@ const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
const fileLoaderFinder = makeLoaderFinder('file-loader');

const plugins = (defaultPlugins) => {
return [
{
name: 'scss',
options: {
sass: {
dev: {
sassOptions: {
outputStyle: 'expanded',
sourceMap: true,
includePaths: ['node_modules'],
quiet: true,
},
},
prod: {
sassOptions: {
outputStyle: 'expanded',
sourceMap: true,
includePaths: ['node_modules'],
quiet: true,
},
},
},
},
},
...defaultPlugins,
];
return [...defaultPlugins];
};
const modifyWebpackConfig = (config, { target, dev }, webpack) => {
const fileLoader = config.module.rules.find(fileLoaderFinder);
Expand Down
22 changes: 8 additions & 14 deletions src/components/Components/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,14 @@ export function Card({
)}
</div>
{description ? (
<div className="nsw-card__copy">
{isValidElement(description) ? (
description
) : (
<div dangerouslySetInnerHTML={{ __html: description.data }}></div>
)}
{/* {!isEditMode ? (
description
) : isValidElement(description) ? (
<span dangerouslySetInnerHTML={{ __html: description }}></span>
) : (
description
)} */}
</div>
isValidElement(description) ? (
<div className="nsw-card__copy">{description}</div>
) : (
<div
className="nsw-card__copy"
dangerouslySetInnerHTML={{ __html: description.data }}
></div>
)
) : null}

{icon ? icon : <DefaultIcon />}
Expand Down
1 change: 0 additions & 1 deletion src/components/Components/Hero.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { UniversalLink } from '@plone/volto/components';
import cx from 'classnames';
import './Hero.less';

const widthClassnameMapping = {
wide: 'nsw-hero-banner--wide',
Expand Down
14 changes: 0 additions & 14 deletions src/components/Components/Hero.less

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Components/InPageAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export function InPageAlert({
{isValidElement(content) ? (
content
) : (
// TODO: Headings in the alert should have an `nsw-h5` class on them ass of 3.5.1
<div
className="nsw-in-page-alert__content"
dangerouslySetInnerHTML={{ __html: content }}
Expand Down
13 changes: 13 additions & 0 deletions src/customizations/@root/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Don't use the full Pastanaga theme
import '@plone/volto/../theme/themes/pastanaga-cms-ui/extras/cms-ui.semantic.less';
import '@plone/volto/../theme/themes/pastanaga/extras/extras.less';

// Custom fonts
import '@fontsource/public-sans/400-italic.css';
import '@fontsource/public-sans/400.css';
import '@fontsource/public-sans/700-italic.css';
import '@fontsource/public-sans/700.css';
import 'material-icons/iconfont/material-icons.css';

// Rest of the theme. Includes the NSW Design System import
import 'nsw-design-system-plone6/theme/theme.scss';
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const messages = defineMessages({
id: 'Browse the site, drop an image, or type an URL',
defaultMessage: 'Browse the site, drop an image, or type an URL',
},
uploadingImage: {
id: 'Uploading image',
defaultMessage: 'Uploading image',
},
});

/**
Expand Down Expand Up @@ -266,7 +270,11 @@ class Edit extends Component {
{this.state.dragging && <Dimmer active></Dimmer>}
{this.state.uploading && (
<Dimmer active>
<Loader indeterminate>Uploading image</Loader>
<Loader indeterminate>
{this.props.intl.formatMessage(
messages.uploadingImage,
)}
</Loader>
</Dimmer>
)}
<div className="no-image-wrapper">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Not implemented: NoResults component is not implemented (https://github.com/plone/volto/pull/3602)

import { Pagination } from '@plone/volto/components';
import withQuerystringResults from '@plone/volto/components/manage/Blocks/Listing/withQuerystringResults';
import config from '@plone/volto/registry';
import { createRef } from 'react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { Dimmer, Loader } from 'semantic-ui-react';
import cx from 'classnames';

const NoResults = ({ hasLoaded, customMessage }) => {
if (customMessage && customMessage !== '<p></p>') {
Expand Down Expand Up @@ -58,44 +61,59 @@ const ListingBody = withQuerystringResults((props) => {
}

const listingRef = createRef();
const HeadlineTag = data.headlineTag || 'h2';

const customMessage = data.noResultsMessage?.data;

return listingItems?.length > 0 ? (
<div ref={listingRef}>
<ListingBodyTemplate
items={listingItems}
isEditMode={isEditMode}
{...data}
{...variation}
/>
{totalPages > 1 && (
<div className="pagination-wrapper">
<Pagination
current={currentPage}
total={totalPages}
onChangePage={(e, { activePage }) => {
!isEditMode &&
listingRef.current.scrollIntoView({ behavior: 'smooth' });
onPaginationChange(e, { activePage });
}}
return (
<>
{data.headline && (
<HeadlineTag
className={cx('headline', {
emptyListing: !listingItems?.length > 0,
})}
>
{data.headline}
</HeadlineTag>
)}
{listingItems?.length > 0 ? (
<div ref={listingRef}>
<ListingBodyTemplate
items={listingItems}
isEditMode={isEditMode}
{...data}
{...variation}
/>
{totalPages > 1 && (
<div className="pagination-wrapper">
<Pagination
current={currentPage}
total={totalPages}
onChangePage={(e, { activePage }) => {
!isEditMode &&
listingRef.current.scrollIntoView({ behavior: 'smooth' });
onPaginationChange(e, { activePage });
}}
/>
</div>
)}
</div>
) : isEditMode ? (
<div className="listing message" ref={listingRef}>
{isFolderContentsListing && (
<FormattedMessage
id="No items found in this container."
defaultMessage="No items found in this container."
/>
)}
<NoResults hasLoaded={hasLoaded} customMessage={customMessage} />
</div>
) : (
<div>
<NoResults hasLoaded={hasLoaded} customMessage={customMessage} />
</div>
)}
</div>
) : isEditMode ? (
<div className="listing message" ref={listingRef}>
{isFolderContentsListing && (
<FormattedMessage
id="No items found in this container."
defaultMessage="No items found in this container."
/>
)}
<NoResults hasLoaded={hasLoaded} customMessage={customMessage} />
</div>
) : (
<div>
<NoResults hasLoaded={hasLoaded} customMessage={customMessage} />
</div>
</>
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const FilterList = (props) => {
facets[facet].map((value) => {
return (
<button
key={value}
onClick={() => {
removeFilter({ facet: facet, value: value });
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,19 @@ function normalizeState({
block: id,
};

// TODO: need to check if SearchableText facet is not already in the query
// Ideally the searchtext functionality should be restructured as being just
// another facet
params.query = params.query.reduce(
// Remove SearchableText from query
(acc, kvp) => (kvp.i === 'SearchableText' ? acc : [...acc, kvp]),
[],
);
// Note Ideally the searchtext functionality should be restructured as being just
// another facet. But right now it's the same. This means that if a searchText
// is provided, it will override the SearchableText facet.
// If there is no searchText, the SearchableText in the query remains in effect.
// TODO eventually the searchText should be a distinct facet from SearchableText, and
// the two conditions could be combined, in comparison to the current state, when
// one overrides the other.
if (searchText) {
params.query = params.query.reduce(
// Remove SearchableText from query
(acc, kvp) => (kvp.i === 'SearchableText' ? acc : [...acc, kvp]),
[],
);
params.query.push({
i: 'SearchableText',
o: 'plone.app.querystring.operation.string.contains',
Expand Down Expand Up @@ -278,16 +282,22 @@ const withSearch = (options) => (WrappedComponent) => {
const timeoutRef = React.useRef();
const facetSettings = data?.facets;

const deepQuery = JSON.stringify(data.query);
const onTriggerSearch = React.useCallback(
(toSearchText, toSearchFacets, toSortOn, toSortOrder) => {
(
toSearchText = undefined,
toSearchFacets = undefined,
toSortOn = undefined,
toSortOrder = undefined,
) => {
if (timeoutRef.current) clearTimeout(timeoutRef.current);
timeoutRef.current = setTimeout(
() => {
const searchData = normalizeState({
id,
query: data.query || {},
facets: toSearchFacets || facets,
searchText: toSearchText,
searchText: toSearchText || searchText,
sortOn: toSortOn ?? sortOn,
sortOrder: toSortOrder ?? sortOrder,
facetSettings,
Expand All @@ -310,11 +320,15 @@ const withSearch = (options) => (WrappedComponent) => {
toSearchFacets ? inputDelay / 3 : inputDelay,
);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[
// Use deep comparison of data.query
deepQuery,
data.query,
facets,
id,
setLocationSearchData,
searchText,
sortOn,
sortOrder,
facetSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function Footer() {
siteSettings && siteSettings[fieldname] && !!siteSettings[fieldname],
);
const acknowledgementOfCountry =
siteSettings?.acknowledgement_of_country ??
siteSettings?.acknowledgement_of_country ||
intl.formatMessage(messages.acknowledgementOfCountry);

return (
Expand Down
22 changes: 1 addition & 21 deletions src/customizations/volto/components/theme/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,7 @@ const SearchStartButton = ({ searchInputElement }) => {
</button>
) : (
// Below styling is only for buttons in the NSW Design System code unfortunately.
<UniversalLink
href="/search"
style={{
fontSize: 'var(--nsw-font-size-xxs-mobile)',
lineHeight: 'var(--nsw-line-height-xxs-mobile)',
fontWeight: 'var(--nsw-font-bold)',
borderRadius: 'var(--nsw-border-radius)',
textAlign: 'center',
color: 'var(--nsw-brand-dark)',
width: '3rem',
height: '3rem',
background: '0 0',
border: '0',
padding: '0',
position: 'relative',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
}}
>
<UniversalLink href="/search">
<Icon
name={SearchSVG}
className="material-icons nsw-material-icons"
Expand Down
4 changes: 1 addition & 3 deletions src/customizations/volto/components/theme/View/EventView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import { EventDetails } from '@plone/volto/components';
const EventTextfieldView = ({ content }) => (
<React.Fragment>
{content.title && <h1 className="documentFirstHeading">{content.title}</h1>}
{content.description && (
<p className="nsw-intro">{content.description}</p>
)}
{content.description && <p className="nsw-intro">{content.description}</p>}
{content.image && (
<Image
className="document-image"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
*/
const NewsItemView = ({ content }) => {
return (
<div id="page-document" className="view-wrapper event-view nsw-container">
<div
id="page-document"
className="view-wrapper newsitem-view nsw-container"
>
<div className="nsw-layout">
<div className="nsw-layout__main">
{hasBlocksData(content) ? (
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import applyAddonConfig from './config';
import './theme.js';

const applyConfig = (config) => {
applyAddonConfig(config);
Expand Down
Loading