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

Specify custom "Success" messages per list #677

Closed
jesstelford opened this issue Feb 9, 2019 · 3 comments · Fixed by #2817
Closed

Specify custom "Success" messages per list #677

jesstelford opened this issue Feb 9, 2019 · 3 comments · Fixed by #2817

Comments

@jesstelford
Copy link
Contributor

jesstelford commented Feb 9, 2019

What

Imagine this flow:

  • I run a blog site where people can submit their own posts.
  • I receive an email telling me I got a new post.
  • I click the link to load up Keystone on that post.
  • I now have to change the status to Approved
  • I click Save
  • An email is sent to the author, and the post is now live on the site
  • I see:
    screen shot 2019-02-09 at 2 18 40 pm

That success message " Saved Successfully" is not very informative of what actually happened.

Ideally, I'd be able to specify a custom message to better describe what happened (an email was sent, and the post is live at <url>). Something like:

screen shot 2019-02-09 at 2 38 20 pm

How

One possible solutions is as part of the afterChange() hook (which currently expects undefined as the return type);

keystone.createList('Post', {
  fields: {
    approved: { type: Checkbox },
    /* ... */
  },
  hooks: {
    afterChange({ updatedItem, existingItem }) {
      if (updatedItem.approved && !existingItem.approved) {
        sendApprovalEmail(updatedItem);
        return {
          message: `
**${updatedItem.title}**

✅ Changes saved successfully.<br />
✉️ ${updatedItem.author.name} has been notified of approval.<br />
🔗 <a href="${updatedItem.url}">View the post online here</a>
          `,
        },
      }
    },
  },
});
@MadeByMike
Copy link
Contributor

Relates to #1452

@stale stale bot removed the needs-review label Oct 21, 2019
@keystonejs keystonejs deleted a comment from stale bot Oct 21, 2019
@gautamsi
Copy link
Member

I think this is more than custom actions

@stale
Copy link

stale bot commented Feb 18, 2020

It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants