Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: allow plugins to disable their edit modal#7989

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

fsbraun
Copy link
Member

@fsbraunfsbraun commentedSep 8, 2024
edited by sourcery-aibot
Loading

Description

As discussed in#7982, some plugins' configuration might not be edited. Examples are:

  • Column plugins (in many cases)
  • Slot-like plugins which do not have their own configuration

This PR allows plugins to mark themselves asnon-editable by setting

  • edit_disabled class property of the plugin class, or by setting
  • edit_disabled instance property on the plugin instance (potentially dynamically)

If either is set, the structure board will not offer the edit button, and double-clicking the plugin on the page or in the structure view will not open the edit modal.

Finally, if the plugin instance has aadd_structureboard_classes property, those classes will be added to the drag item in the structure board. This can be used to style plugins in the structure board dynamically. Styles would need to be added in a customcms_toolbar.py.

Example

This PR doesnot include the grey text color. I included this to show which plugins donot have edit modals:

  • No pencil button
  • Double-click does not do anything

image

Related resources

Checklist

  • I have opened this pull request againstdevelop-4
  • I have added or modified the tests when changing logic
  • I have followedthe conventional commits guidelines to add meaningful information into the changelog
  • I have read thecontribution guidelines and I have joined the channel #pr-reviews on ourDiscord Server to find a “pr review buddy” who is going to review my pull request.

Summary by Sourcery

Allow plugins to disable their edit modal by setting theedit_disabled property on the plugin class or instance. Add the ability to style plugins in the structure board dynamically by adding classes to theadd_structureboard_classes property.

New Features:

  • Allow plugins to disable their edit modal.
  • Allow plugins to add custom classes to the drag item in the structure board.

marksweb reacted with thumbs up emoji
@fsbraunfsbraun marked this pull request as draftSeptember 8, 2024 15:12
@fsbraunfsbraun added the 5.0 labelSep 8, 2024
@macolo
Copy link
Contributor

macolo commentedSep 10, 2024
edited
Loading

@fsbraun nice! I thought a bit about this and have two use cases:

  1. would dragging aedit_disabled plugin outside the controlling parent still be possible, e.g. can an editor (accidentally?) destroy a parent-child complex designed by a developer so that it becomes unusable, especially as the controlling parent plugin template (probably?) counts on the existence of specific child plugins in a specific order?

  2. dragging aedit_disabled plugin inside the controlling parent, e.g. changing the order of its child plugins. This might cause a similar issue, the controlling parent's template might expect the controlled children to be in a specific order?

In summary, would it make sense to also disallow direct drag & drop foredit_disabled plugins?

Of course, dragging them via a parent plugin should always be possible, as the whole complex can be dragged to another position in the placeholder, can be cut or copied and pasted elsewhere.

@fsbraun
Copy link
MemberAuthor

fsbraun commentedSep 10, 2024
edited
Loading

@macolo Draging is still fully controlled byallowed_parents andallowed_children. This means I could change the order of columns or move a column to a different row. But I should not be able to drag a column into something else than a row.

Indeed, the parent plugin cannot rely on the existence or order of child plugins. Any management code must be flexible and say recreate a missing child if needed, or might want to merge if there are several children, say, for a single slot. Disabling dragging alone would not solve this issue: There is also pasting or adding plugins.

PS: The custom component construct does ignore the order of the child plugins.

@fsbraun
Copy link
MemberAuthor

fsbraun commentedSep 19, 2024
edited
Loading

@macolo I have now implemented drag-disabling in principle (CSS and JS side). Shall we go for another plugin option that disables drag for child plugins? It would also need to disable add and paste. Something likechild_edit_disabled...

@fsbraunfsbraun marked this pull request as ready for reviewFebruary 2, 2025 20:00
@sourcery-aiSourcery AI
Copy link
Contributor

Reviewer's Guide by Sourcery

This pull request introduces the ability to disable the edit modal for plugins. This is achieved by adding an 'edit_disabled' property to the plugin class or instance. Additionally, it allows adding custom classes to the drag item in the structure board via the 'add_structureboard_classes' property.

Sequence diagram for plugin edit interaction with disabled editing

sequenceDiagram    actor User    participant UI    participant Plugin    participant Editor    User->>UI: Double clicks plugin    UI->>Plugin: Check edit_disabled status    alt edit_disabled is true        Plugin-->>UI: Editing disabled        UI-->>User: No action    else edit_disabled is false        Plugin-->>UI: Editing allowed        UI->>Editor: Open edit modal        Editor-->>User: Show edit interface    end
Loading

Class diagram showing plugin edit configuration changes

classDiagram    class Plugin {        +edit_disabled: bool        +add_structureboard_classes: string        +allow_children: bool        +disable_child_plugins: bool        +get_plugin_class()    }    class PluginInstance {        +edit_disabled: bool        +add_structureboard_classes: string    }    Plugin <|-- PluginInstance    note for Plugin "New properties added:edit_disabled andadd_structureboard_classes"    note for PluginInstance "Can override class-leveledit_disabled setting"
Loading

State diagram for plugin edit states

stateDiagram-v2    [*] --> Normal    Normal --> EditDisabled: edit_disabled=true    Normal --> Editable: edit_disabled=false    state Editable {        [*] --> Ready        Ready --> EditModal: Double click        EditModal --> Ready: Close modal    }    state EditDisabled {        [*] --> NoEdit        NoEdit --> NoEdit: Double click (no effect)    }
Loading

File-Level Changes

ChangeDetailsFiles
Added the ability to disable the edit modal for plugins.
  • Added 'edit_disabled' property to the plugin class or instance to disable the edit modal.
  • Modified the drag item template to not render the edit button if the plugin is not editable.
  • Modified the plugin javascript to prevent opening the edit modal on double click if the plugin is not editable.
  • Modified the plugin rendering to add a class to the plugin container if the plugin is not editable.
  • Modified the structure board javascript to not allow dragging of disabled plugins.
  • Modified the structure board styles to not show the drag handle for disabled plugins.
cms/templates/cms/toolbar/dragitem.html
cms/static/cms/js/modules/cms.plugins.js
cms/plugin_rendering.py
cms/static/cms/js/modules/cms.structureboard.js
cms/static/cms/sass/components/_structureboard.scss
cms/templates/cms/toolbar/toolbar_with_structure.html
Added the ability to add custom classes to the drag item in the structure board.
  • Added 'add_structureboard_classes' property to the plugin instance to add custom classes to the drag item.
cms/templates/cms/toolbar/dragitem.html

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment@sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with@sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write@sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write@sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment@sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment@sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment@sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment@sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment@sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access yourdashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-aisourcery-aibot left a comment

Choose a reason for hiding this comment

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

Hey@fsbraun - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please add tests to verify both the frontend and backend behavior of the edit disabling functionality
Here's what I looked at during the review
  • 🟡General issues: 1 issue found
  • 🟢Security: all looks good
  • 🟢Testing: all looks good
  • 🟢Complexity: all looks good
  • 🟢Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

sourcery-ai[bot] reacted with thumbs up emojisourcery-ai[bot] reacted with thumbs down emoji
@fsbraunfsbraun marked this pull request as draftFebruary 2, 2025 20:54
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sourcery-aisourcery-ai[bot]sourcery-ai[bot] left review comments

Assignees
No one assigned
Labels
Projects
Status: Done
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@fsbraun@macolo

[8]ページ先頭

©2009-2025 Movatter.jp