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

Palette should be aware of apostrophe-workflow's workflowMode and hide the menu #8

Open
stuartromanek opened this issue Sep 7, 2018 · 7 comments

Comments

@stuartromanek
Copy link
Member

In a project level example of this we extended apostrophe-palette-widget's self.load method and attached req.session.workflowMode to the widget object.

@boutell
Copy link
Member

boutell commented Sep 7, 2018 via email

@ToshKoevoets
Copy link

ToshKoevoets commented Jul 6, 2020

Hi @boutell and @stuartromanek,

Not really sure how to implement stuart's solutions.

For now I've overwritten apostrophe's workflow admin bar implementation, but a cleaner, smaller solution is preferable imo. Maybe a notSafelist that can be overwritten. You guys have an idea for a better solution?


module.exports = {
  improve: 'apostrophe-admin-bar',
  construct: function(self, options) {
    // Hide most admin bar buttons in draft mode, specifically
    // those that manage pieces; you must be in draft mode to
    // do most things. Later perhaps we'll introduce a manage modal
    // for live mode that lets you preview things
    var superItemIsVisible = self.itemIsVisible;
    self.itemIsVisible = function(req, item) {
      var result = superItemIsVisible(req, item);

      if (!result) {
        return result;
      }

      if (req.locale && req.locale.match(/-draft$/)) {
        return result;
      }

      var notSafeLiveList = [ 'apostrophe-pages', 'apostrophe-tags', 'apostrophe-workflow-manage-modal', 'apostrophe-palette' ];
      if (_.contains(notSafeLiveList, item.name)) {
        return false;
      }

      // In addition, pieces manage buttons are not safe live
      // if the type is included in workflow; look
      // for subclasses
      var manager = self.apos.modules[item.name];
      if (!manager) {
        return result;
      }

      if (!(self.apos.synth.instanceOf(manager, 'apostrophe-pieces'))) {
        return result;
      }

      var workflow = self.apos.modules['apostrophe-workflow'];
      if (!workflow.includeType(manager.name)) {
        return result;
      }
      
      return false;
    };
  }
};

@boutell
Copy link
Member

boutell commented Jul 6, 2020

I'm not sure we're talking about the same thing. I think this ticket is just about hiding the palette UI when the workflowMode is not draft, as long as apostrophe-global is subject to workflow.

@stuartromanek
Copy link
Member Author

Not sure of @ToshKoevoets 's path on this, however there should be a pattern around achieving this, yes @boutell ? Normal piece menus in the admin bar respect this mode without alteration.

@boutell
Copy link
Member

boutell commented Jul 8, 2020 via email

@stuartromanek
Copy link
Member Author

@ToshKoevoets
Reviewing and working out how to make notSafeLiveList flexible, follow along at
apostrophecms/apostrophe-workflow#323
#26

@ToshKoevoets
Copy link

ToshKoevoets commented Jul 10, 2020

Hi @boutell and @stuartromanek,

Probably didn't fully understand this ticket, I assumed it was referring to the the fact that palette was displaying in main menu in Live /preview mode, but it seems I misunderstood.

@stuartromanek I saw the review and proposed changes. Thanks looks a lot better then my way!

Gr. Tosh

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

No branches or pull requests

3 participants