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

Add options to override listing blocks "no results". Add a default noResultsComponents, and another for the imageGallery variation #3602

Merged
merged 40 commits into from Feb 27, 2023

Conversation

ionlizarazu
Copy link
Contributor

@ionlizarazu ionlizarazu commented Sep 1, 2022

@netlify
Copy link

netlify bot commented Sep 1, 2022

Deploy Preview for volto ready!

Name Link
🔨 Latest commit f8f740f
🔍 Latest deploy log https://app.netlify.com/sites/volto/deploys/63fc7457d2dc2b0008b8f2de
😎 Deploy Preview https://deploy-preview-3602--volto.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@cypress
Copy link

cypress bot commented Sep 1, 2022

Passing run #4094 ↗︎

0 459 20 0 Flakiness 0

Details:

Update docs/source/blocks/index.md
Project: Volto Commit: f8f740f22c
Status: Passed Duration: 14:53 💡
Started: Feb 27, 2023 9:17 AM Ended: Feb 27, 2023 9:32 AM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@erral
Copy link
Sponsor Member

erral commented Sep 1, 2022

IMHO to include a component in the variation to show the No results component does not work. It difficults reusing variations.

Say I want to prepare a variation to use it both in News listing and Event listings, and in one I want to put "no future events" and in the other "there are no news".

Using a single component to add this message would mean to add a new variation just to change the "No results".

My 2 cents.

@ionlizarazu
Copy link
Contributor Author

I've added some data to the NoResults component, so now we can enhance the schema for the variation and use the values in the NoResults component.

For @erral example:

  • You extend the schema for the variation with a field (no_results_text)
  • Create your own NoResultsComponent showing the no_results_text data
  • Configure your NoResultsComponent for your extended variation

Copy link
Member

@sneridagh sneridagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems ok to me, but shouldn't this is a good use case for the component registry? Even for the variations.

config.registerComponent({
    name: 'NoResults',
    component: NoResultsComponentForVariation1,
    dependencies: ['Listing', 'Variation1'],
  });

What do you think? Anyways is fine as it is for me, just wanted to pull out use cases for the component registry.

@ionlizarazu
Copy link
Contributor Author

It makes sense, do you have any example in other component to see how to do it? @sneridagh

@sneridagh
Copy link
Member

sneridagh commented Sep 8, 2022

@ionlizarazu

Not yet a lot of examples but:

const src = item.image_field
? flattenToAppURL(`${item['@id']}/@@images/${item.image_field}/${size}`)
: config.getComponent({
name: 'DefaultImage',
dependencies: ['listing', 'summary'],
}).component || DefaultImageSVG;

We are using it a lot lately:

Select which teaser template you should use based on the content type:

  const hasType = data.href?.[0]?.['@type'];

  const BodyComponent =
    (config.getComponent &&
      hasType &&
      config.getComponent({ name: 'Teaser', dependencies: [hasType] })
        .component) ||
    variation?.template ||
    DefaultBody;

and the registration:

  config.registerComponent({
    name: 'Teaser',
    component: NewsItem,
    dependencies: 'News Item',
  });

hope this helps!

@ionlizarazu
Copy link
Contributor Author

so, shoud I register the component using registerComponent function or just writing down here: https://github.com/plone/volto/blob/master/src/config/Components.jsx

@sneridagh
Copy link
Member

@ionlizarazu better the register component... think of it as the API to do the registrations. Like ZCA. ;)

Could be that to avoid confusion we change the registration of PreviewImage in there.

Copy link
Contributor

@tiberiuichim tiberiuichim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get this approved, we'll need some documentation

@erral
Copy link
Sponsor Member

erral commented Oct 11, 2022

I have added documentation on how to use this feature

@tiberiuichim
Copy link
Contributor

@sneridagh let's merge this, it makes sense to have it

@erral
Copy link
Sponsor Member

erral commented Feb 21, 2023

@ksuess and what about adding an option in the schema to hide the heading or the listing when there are no results? That's easier from the CMS user perspective: just hide the title and it's done. No need to add CSS code to achieve it.

@ksuess
Copy link
Member

ksuess commented Feb 22, 2023

@ksuess and what about adding an option in the schema to hide the heading or the listing when there are no results? That's easier from the CMS user perspective: just hide the title and it's done. No need to add CSS code to achieve it.

My request that I have to solve is: "Hide a listing if there is no result".
This is easy with a
.emptyListing { display: none;)
Instead it is a pain for an editor to visit all 1017 listings and check the "hide if there are no results".
Do you see may point now?

@erral
Copy link
Sponsor Member

erral commented Feb 22, 2023

I see 😅

@erral
Copy link
Sponsor Member

erral commented Feb 22, 2023

@sneridagh then we can merge this one and then @ksuess' PR

@ksuess ksuess changed the title add a default noResultsComponents, and another for the imageGallery variation Add options to override listing blocks "no results". Add a default noResultsComponents, and another for the imageGallery variation Feb 24, 2023
Copy link
Member

@sneridagh sneridagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment

"property=og:description": "Volto features the Pastanaga Editor Engine, allowing you to visually compose a page using blocks."
"property=og:title": "Blocks"
"keywords": "Volto, Plone, frontend, React, blocks"
'description': 'Volto features the Pastanaga Editor Engine, allowing you to visually compose a page using blocks.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erral @ksuess @stevepiercy uh I realised we are using different types of quotes here, also in next one...

Is there any accepted styling for md meta?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double quotes " is what is created initially by a Python script, and can be copy-pasted from other .md files. This is consistent with Black and other Python style guides for Plone. If single quotes are being used, we need to change them.

Also I should review this documentation before merge. Please give me until tonight to do that. Thank you!

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really good stuff!

I have only a few minor changes: primarily, revert a few changes in CHANGELOG.md, and use one sentence per line.

Also be aware of your editor's defaults. If you see a lot of changes for a file that you did not deliberately edit, then you need to adapt your editor to this repo's defaults. Thank you!

CHANGELOG.md Outdated Show resolved Hide resolved
docs/source/blocks/index.md Outdated Show resolved Hide resolved
docs/source/blocks/listing-block.md Outdated Show resolved Hide resolved
docs/source/blocks/listing-block.md Outdated Show resolved Hide resolved
docs/source/blocks/listing-block.md Outdated Show resolved Hide resolved
docs/source/blocks/listing-block.md Outdated Show resolved Hide resolved
docs/source/blocks/listing-block.md Outdated Show resolved Hide resolved
docs/source/blocks/listing-block.md Outdated Show resolved Hide resolved
erral and others added 8 commits February 27, 2023 07:53
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
@erral
Copy link
Sponsor Member

erral commented Feb 27, 2023

Thanks @stevepiercy for the review. I have reverted all those quotation changes.

I really don't know why my editor does this kind of stuff... I am wondering if our .estlintrc configuration may have some influence on that... I will check it.

locales/de/LC_MESSAGES/volto.po Outdated Show resolved Hide resolved
Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one typo, then the docs are good. Thank you!

docs/source/blocks/index.md Outdated Show resolved Hide resolved
sneridagh and others added 2 commits February 27, 2023 10:13
Co-authored-by: Katja Süss <k.suess@rohberg.ch>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
@sneridagh sneridagh merged commit cd8b640 into master Feb 27, 2023
Polished Volto automation moved this from To do to Done Feb 27, 2023
@sneridagh sneridagh deleted the listing-no-results-component branch February 27, 2023 09:49
sneridagh added a commit that referenced this pull request Mar 2, 2023
…ResultsComponents, and another for the imageGallery variation (#3602)

Co-authored-by: Mikel Larreategi <mlarreategi@codesyntax.com>
Co-authored-by: Tiberiu Ichim <tiberiuichim@users.noreply.github.com>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Co-authored-by: Víctor Fernández de Alba <sneridagh@gmail.com>
Co-authored-by: Katja Süss <k.suess@rohberg.ch>
sneridagh added a commit that referenced this pull request Mar 3, 2023
* master: (23 commits)
  Teaser block in core (#3706)
  Release 16.13.0 (#4457)
  Release generate-volto 6.2.5
  Amend inconsistencies in generator package after release :/
  Use latest plone/server breed images (#4454)
  Export App and its connectorAppComponent as standalone (#4413)
  Release generate-volto 6.2.4
  Fix generator adding the jest config for @plone/volto-slate (#4453)
  Amend Towncrier news item (2)
  Amend Towncrier news item
  Add towncrier checker (#4450)
  Release 16.12.0 (#4445)
  Update link to Yarn 3 Workspaces to avoid redirect to Yarn Classic 1.x. (#4444)
  Remove link to yarnclasic
  Add options to override listing blocks "no results". Add a default noResultsComponents, and another for the imageGallery variation (#3602)
  Tidy up backend/index.md (#4431)
  On error pages, don't switch to default site language (#4425)
  Provide disable props to all widget and pass disable props in babel view (#4398)
  fix : Restrictive propTypes for widgets (#4354)
  Change the width of overlay (#4372)
  ...
erral added a commit that referenced this pull request Mar 18, 2023
…ResultsComponents, and another for the imageGallery variation (#3602)

Co-authored-by: Mikel Larreategi <mlarreategi@codesyntax.com>
Co-authored-by: Tiberiu Ichim <tiberiuichim@users.noreply.github.com>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Co-authored-by: Víctor Fernández de Alba <sneridagh@gmail.com>
Co-authored-by: Katja Süss <k.suess@rohberg.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Change the "no results found" message of ListingBlock to something customizable
6 participants