2022-07-11 12:23:59 +02:00
|
|
|
<div id="bot-edit-form" data-user-id="{{user_id}}" data-email="{{email}}">
|
2023-01-10 16:04:43 +01:00
|
|
|
<form class="new-style edit_bot_form name-setting">
|
2023-07-20 13:50:04 +02:00
|
|
|
<div class="alert" id="bot-edit-form-error"></div>
|
2022-03-31 09:04:36 +02:00
|
|
|
<div class="input-group name_change_container">
|
2023-05-29 16:31:37 +02:00
|
|
|
<label for="edit_bot_full_name">{{t "Name" }}</label>
|
2023-03-27 10:24:27 +02:00
|
|
|
<input type="text" autocomplete="off" name="full_name" id="edit_bot_full_name" class="modal_text_input" value="{{ full_name }}" />
|
2022-03-31 09:04:36 +02:00
|
|
|
</div>
|
2021-06-09 08:54:30 +02:00
|
|
|
<input type="hidden" name="is_full_name" value="true" />
|
2022-03-31 09:04:36 +02:00
|
|
|
<div class="input-group email_change_container">
|
|
|
|
<label for="email">{{t "Email" }}</label>
|
2023-03-27 10:24:27 +02:00
|
|
|
<input type="text" autocomplete="off" name="email" class="modal_text_input" value="{{ email }}" readonly/>
|
2022-03-31 09:04:36 +02:00
|
|
|
</div>
|
|
|
|
<div class="input-group user_id_container">
|
|
|
|
<label for="user_id">{{t "User ID" }}</label>
|
2023-03-27 10:24:27 +02:00
|
|
|
<input type="text" autocomplete="off" name="user_id" class="modal_text_input" value="{{ user_id }}" readonly/>
|
2022-03-31 09:04:36 +02:00
|
|
|
</div>
|
2022-03-31 09:09:12 +02:00
|
|
|
<div class="input-group">
|
|
|
|
<label class="input-label" for="bot-role-select">{{t 'Role' }}
|
|
|
|
{{> ../help_link_widget link="/help/roles-and-permissions" }}
|
|
|
|
</label>
|
2023-02-16 15:47:42 +01:00
|
|
|
<select name="bot-role-select" id="bot-role-select" class="modal_select bootstrap-focus-style" data-setting-widget-type="number" {{#if disable_role_dropdown}}disabled{{/if}}>
|
2022-03-31 09:09:12 +02:00
|
|
|
{{> dropdown_options_widget option_values=user_role_values}}
|
|
|
|
</select>
|
|
|
|
</div>
|
2023-07-19 16:09:53 +02:00
|
|
|
{{> ../dropdown_widget_with_label
|
|
|
|
widget_name="edit_bot_owner"
|
|
|
|
label=(t 'Owner')}}
|
|
|
|
|
2022-07-14 19:13:31 +02:00
|
|
|
<div id="service_data">
|
2022-07-08 18:45:17 +02:00
|
|
|
</div>
|
2022-07-06 16:48:35 +02:00
|
|
|
<div class="input-group edit-avatar-section">
|
|
|
|
<label>Avatar</label>
|
2023-01-02 19:19:52 +01:00
|
|
|
{{!-- Shows the current avatar --}}
|
|
|
|
<img src="{{bot_avatar_url}}" id="current_bot_avatar_image" />
|
2022-07-06 16:48:35 +02:00
|
|
|
<input type="file" name="bot_avatar_file_input" class="notvisible edit_bot_avatar_file_input" value="{{t 'Upload profile picture' }}" />
|
|
|
|
<div class="edit_bot_avatar_file"></div>
|
2023-01-02 19:19:52 +01:00
|
|
|
<div class="edit_bot_avatar_preview_text">
|
|
|
|
<img class="edit_bot_avatar_preview_image" />
|
|
|
|
</div>
|
|
|
|
<button type="button" class="button white rounded edit_bot_avatar_upload_button">{{t "Change avatar" }}</button>
|
2022-07-06 16:48:35 +02:00
|
|
|
<button type="button" class="button white rounded edit_bot_avatar_clear_button" style="display: none;">{{t "Clear profile picture" }}</button>
|
|
|
|
<div><label for="edit_bot_avatar_file" generated="true" class="edit_bot_avatar_error text-error"></label></div>
|
|
|
|
</div>
|
2021-06-09 08:54:30 +02:00
|
|
|
</form>
|
2023-06-27 11:14:31 +02:00
|
|
|
{{#if is_incoming_webhook_bot}}
|
|
|
|
<div class="input-group new-style">
|
|
|
|
<button class="button rounded generate_url_for_integration">
|
|
|
|
{{t 'Generate URL for an integration' }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
2022-09-15 12:00:09 +02:00
|
|
|
<div class="input-group new-style">
|
|
|
|
<button class="button rounded btn-danger deactivate_bot_button">
|
|
|
|
{{t 'Deactivate bot' }}
|
|
|
|
</button>
|
|
|
|
</div>
|
user settings: Separate code for bot form.
When editing a bot, there are only two fields
that are similar to humans--full name and
email--which are trivial.
Before this commit we used a single codepath
to build the human form and the bot form.
Now we have two simple codepaths.
The tricky nature of the code had already led
to ugly things for the bot codepath that
fortunately weren't user facing, but which
were distracting:
- For bots we would needlessly set things
like is_admin, is_guest in the template
data.
- For bots we would needlessly try to update
custom profile fields.
The code that differs between bots and humans
is nontrivial, and the code was both hard to read
and hard to improve:
- Humans don't have bot owners.
- Bots don't have custom profile fields.
The bot-owner code is nontrivial for performance
reasons. In a big realm there are tens of thousands
of potential bot owners. We avoid the most egregious
performance problems (i.e we don't have multiple
copies of the dropdown), but we may still want
to refine that (at least adding a spinner).
The custom-profile-fields code is nontrivial due
to the dynamic nature of custom profile fields,
which can bring in specialized widgets like
pill fields.
Now each form corresponds to a single endpoint:
* human -> /json/users
* bot -> /json/bots
Before we had a lot of conditional logic in
the template, the code to build to views, and
the code to submit the data. Now everything is
much flatter.
The human code is still a bit messy (more work
coming on that), but the bot code is fairly
pristine. All three components of the bot code
fit on a page, and there are no conditionals:
- admin_bot_form.hbs
- open_bot_form
- handle_bot_form
We may want to grow out the bot code a bit
to allow admins to do more things, such as
adding services, and this will be easier now.
It would also be easier for us now to share
widgets with the per-user bot settings.
Note that the form for editing human data will
continue to be invoked from two panels:
- Users
- Deactivated users
There are some minor differences between
users and deactivated users, but the shape of
the data is the same for both, so that's still
all one codepath.
We eliminate `reset_edit_user` here, since
it was never used.
One nice thing about these forms was that they
had very little custom CSS attached to them
(at form-level specificity), and it turned out
all the custom CSS was for the human-specific
form.
2020-05-09 12:13:03 +02:00
|
|
|
</div>
|