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

🎬 Detail actions #302

Merged
merged 17 commits into from
Oct 7, 2023
Merged

🎬 Detail actions #302

merged 17 commits into from
Oct 7, 2023

Conversation

mrharpo
Copy link
Contributor

@mrharpo mrharpo commented Sep 20, 2023

Actions: Detail page

Adds custom action buttons to detail page.

  • Adds BaseView properties:
    • exclude_actions_from_detail = [] exclude an action from that view's detail page
    • exclude_actions_from_list = [] exclude an action from that view's list page

Examples

Currently working from our app's feature branch: WGBH-MLA/chowda#158

List page

Screen Shot 2023-10-04 at 14 22 28
Optional icons

Screen Shot 2023-10-04 at 14 21 29

Detail page

Screen Shot 2023-09-20 at 15 48 23
☝️ Here, "Combine" is excluded from this detail view.

actions.py

Added:

  • action_btn_class: action button class (default: btn-outline)
  • icon_class: icon class for icon next to button (default: fa-solid fa-plus)

Templates

  • Refactors out action.html from list page
    • Reused in both list and detail for consistent style

JS

  • Adds actions.js with custom js to apply to #modal-action
    • Copied from list.js, with minor changes
  • Refactors out alerts.js from list.js

Closes #301

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (6a83469) 100.00% compared to head (d97faeb) 100.00%.
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #302   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           68        68           
  Lines         4963      4997   +34     
=========================================
+ Hits          4963      4997   +34     
Files Coverage Δ
starlette_admin/actions.py 100.00% <ø> (ø)
starlette_admin/base.py 100.00% <ø> (ø)
starlette_admin/views.py 100.00% <100.00%> (ø)
tests/test_custom_actions.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

starlette_admin/actions.py Outdated Show resolved Hide resolved
@mrharpo mrharpo requested a review from jowilf September 22, 2023 23:26
Copy link
Owner

@jowilf jowilf left a comment

Choose a reason for hiding this comment

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

Hello @mrharpo,

Thank you for making the changes; everything looks great!

During testing on my local machine, I noticed one issue. The detail page does not reload after executing an action. As a result, there are inconsistencies between the data in the database and the data displayed in the view. I have some ideas on how to fix this and will do my best to assist you.

@mrharpo mrharpo requested a review from jowilf September 29, 2023 21:27
starlette_admin/views.py Outdated Show resolved Hide resolved
mrharpo and others added 3 commits October 4, 2023 11:29
Co-authored-by: Jocelin Hounon <hounonj@gmail.com>
Fixes get_all_actions bug: change check order to remove forbidden action from detail page
@mrharpo mrharpo requested a review from jowilf October 4, 2023 21:20
Copy link
Owner

@jowilf jowilf left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution🎉.

There is a weird error on Python 3.8 in the CI that I need to investigate and resolve before merging this.

@mrharpo
Copy link
Contributor Author

mrharpo commented Oct 5, 2023

The python3.8 tests all passed, but it failed with Segmentation fault (core dumped).

It might be a transient runner error. Try re-running the job.

@jowilf jowilf merged commit 30ee510 into jowilf:main Oct 7, 2023
7 of 8 checks passed
@jowilf jowilf added this to the 0.12.0 milestone Oct 10, 2023
mrharpo added a commit to WGBH-MLA/starlette-admin that referenced this pull request Oct 10, 2023
* main:
  Update sqlalchemy-file requirement from <0.6.0,>=0.5.0 to >=0.5.0,<0.7.0 (jowilf#326)
  🎬 Detail actions (jowilf#302)
  [pre-commit.ci] pre-commit autoupdate (jowilf#293)
  Bump fasteners from 0.18 to 0.19 (jowilf#322)
  Update httpx requirement from <0.25.0,>=0.23.3 to >=0.23.3,<0.26.0 (jowilf#314)
  Skip odmantic Test Suite on Python 3.8 Due to Segment Fault and Lack of Maintenance (jowilf#325)
  Bump ruff from 0.0.286 to 0.0.292 (jowilf#323)
  Update mkdocstrings[python] requirement (jowilf#315)
  Update arrow requirement from <1.3.0,>=1.2.3 to >=1.2.3,<1.4.0 (jowilf#316)
  Bump black from 23.7.0 to 23.9.1 (jowilf#317)
  Bump actions/checkout from 3 to 4 (jowilf#318)
  🏓 Datatables options (jowilf#308)
@jowilf jowilf mentioned this pull request Oct 21, 2023
3 tasks
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 this pull request may close these issues.

Enhancement: Custom actions on detail page
2 participants