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

Use form for admin purge user #21070

Merged
merged 5 commits into from
Sep 12, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions templates/admin/user/edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@

<div class="field">
<button class="ui green button">{{.locale.Tr "admin.users.update_profile"}}</button>
<div class="ui red button show-modal" data-modal="#delete-user-modal" data-url="{{$.Link}}/delete" data-id="{{.User.ID}}">{{.locale.Tr "admin.users.delete_account"}}</div>
<div class="ui red button show-modal" data-modal="#delete-user-modal">{{.locale.Tr "admin.users.delete_account"}}</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Two things in my mind:

  1. Here the data-id="{{.User.ID}}" is removed, is it correct? IIRC the JS code will fill some data-xxx attributes into the form fields.
  2. In Add option to purge users #18064, the button's CSS class name was changed from delete-button to show-modal, I am not sure what are the differences and concerns. Now the dialog layout is changed again, could @zeripath take a look at them?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will re-test, but you may be right about 1.
About 2, delete-button is how we link it to the generic JS version afaik.

Copy link
Contributor

Choose a reason for hiding this comment

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

show-modal is also a generic JS version .... indeed, the code for show-modal and delete-button are quite similar, that's why I am confused about they two.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I've ran some tests locally again.

The reason data-id is no longer needed is because this page has the user ID in the URL, which is what is used when deleting.

At the very least, I was able to:

  1. Attempt to delete a user and correctly get back "You can't, they still have repos", and then
  2. Select the purge option, which deleted them successfully.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, it seems to happen to work 😀

If @zeripath doesn't have more questions, I will vote L-G-T-M later.

</div>
</form>
</div>
Expand Down Expand Up @@ -206,15 +206,23 @@
</div>
<form class="ui form" method="POST" action="{{.Link}}/delete">
{{$.CsrfTokenHtml}}
<input type="hidden" name="id">
<div class="field">
<div class="ui checkbox">
<label for="purge">{{.locale.Tr "admin.users.purge"}}</label>
<input name="purge" type="checkbox">
</div>
<p class="help">{{.locale.Tr "admin.users.purge_help"}}</p>
</div>
{{template "base/delete_modal_actions" .}}
<div class="actions">
<div class="ui red basic inverted cancel button">
{{svg "octicon-x"}}
{{.locale.Tr "modal.no"}}
</div>
<button class="ui green basic inverted ok button">
{{svg "octicon-check"}}
{{.locale.Tr "modal.yes"}}
</button>
</div>
</form>
</div>
{{template "base/footer" .}}