Skip to content

Conversation

hmpf
Copy link
Contributor

@hmpf hmpf commented Apr 7, 2025

Scope and purpose

Fixes #1352

This is an attempt at making a component. The goal is that the same template works everywhere and that any dialog-specific changes are in python.

Currently this adds a log out button in addition to the link, since we need to figure out what things should look like.

Should the button be moved up to be next to the username? Should it look like a button?
image

How to fix the dialog so that it has no scroll bar and is centered?
image

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff and djLint, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See our how-to
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this results in changes to the database model: Updated the ER diagram

@hmpf hmpf added help wanted Extra attention is needed frontend Affects frontend ddn Design decision needed labels Apr 7, 2025
@hmpf hmpf self-assigned this Apr 7, 2025
@hmpf hmpf moved this from 📋 Backlog to ❓ Ready for review in Argus development, public Apr 7, 2025
Copy link

github-actions bot commented Apr 7, 2025

Test results

   11 files  1 320 suites   49m 57s ⏱️
  583 tests   582 ✅  1 💤 0 ❌
6 413 runs  6 402 ✅ 11 💤 0 ❌

Results for commit d149c12.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link

codecov-commenter commented Apr 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.78%. Comparing base (f4d0e1e) to head (d149c12).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1361      +/-   ##
==========================================
+ Coverage   78.74%   78.78%   +0.03%     
==========================================
  Files         142      143       +1     
  Lines        5801     5811      +10     
==========================================
+ Hits         4568     4578      +10     
  Misses       1233     1233              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@elfjes elfjes left a comment

Choose a reason for hiding this comment

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

Interesting. I don't have any big gripes with this other then maybe I like the current styling of the login "button". It would be nice if we could reuse the style of the current opener

perhaps something like this?

class Modal:
    opener: str = "_base_form_modal_button.html"
    ...

@@ -1,3 +1,4 @@
{% include logout_modal.template_name with modal=logout_modal %}
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks weird. would be much better if it was possible to just write {{ logout_modal }}

Copy link
Contributor Author

@hmpf hmpf Apr 8, 2025

Choose a reason for hiding this comment

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

That's my ultimate goal but I've been struggling to make the csrf token/context outside of the modal itself available to the template. Therefore I'm working to finish everything else while doing the occasional web search for clues.

Copy link
Contributor

Choose a reason for hiding this comment

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

How does django forms do this?

Copy link
Contributor Author

@hmpf hmpf Apr 8, 2025

Choose a reason for hiding this comment

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

The form way is what I've been doing so far, which is why I inherit from RenderableMixin. Just doing that doesn't make csrf_token available...

Comment on lines +39 to 40
"argus.htmx.user.context_processors.logout_context",
],
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I like how the context processor is automatically added through appconfig

Comment on lines +1 to +8
"""
How to use:
Append the "context_processors" list for the TEMPLATES-backend
``django.template.backends.django.DjangoTemplates`` with the full dotted path.
See django settings for ``TEMPLATES``.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need something to indicate that if you're using appconfig.py, the context processors are already added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm.. this is copypasted from another context processor so there would be more places to change. Separate PR I think.

@github-project-automation github-project-automation bot moved this from ❓ Ready for review to ♻ Changes requested in Argus development, public Apr 8, 2025
@hmpf hmpf force-pushed the modal-logout branch 2 times, most recently from 83e9ee0 to 3f0f310 Compare April 8, 2025 07:35
Copy link

sonarqubecloud bot commented Apr 8, 2025

Copy link
Contributor

@podliashanyk podliashanyk left a comment

Choose a reason for hiding this comment

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

I don't like the idea to show a modal on logout. I get that it is definitely useful in something like games or Word-document with unsaved changes etc, but in cases like here where there is no data to lose on logout it is just plain annoying

@johannaengland
Copy link
Contributor

I agree with @podliashanyk. Logging back into Argus is not that difficult, so even if one accidentally would log out, it's fixed very easily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddn Design decision needed frontend Affects frontend help wanted Extra attention is needed

Projects

Status: Changes requested

Development

Successfully merging this pull request may close these issues.

Logging out should be a modal action, to prevent accidental log out

5 participants