Commit Graph

86 Commits

Author SHA1 Message Date
Tim Abbott 5c1dd162be settings: Eliminate remaining NEW_USER_BOT code.
I somehow missed this when removing the rest of the custom
NEW_USER_BOT logic.

This may fix a Casper test that has been failing.
2018-03-30 09:16:22 -07:00
Tim Abbott 9f2a3c2921 settings_org: Fix spelling in set_create_stream_permission_dropdwon. 2018-03-29 08:02:19 -07:00
Shubham Dhama 35cfb86723 org settings: Fix real-time sync for realm_waiting_period_threshold.
This fixes a minor bug in which the value of `input` element of
`realm_waiting_period_threshold` don't get updated because in
`set_create_stream_permission_dropdwon` we don't change the
value of the input.
So, this minor refactor handles this more carefully.
2018-03-29 08:00:58 -07:00
Shubham Dhama 7eea186306 org settings: Make sync_realm_settings to be available at load time.
This moves `sync_realm_settings` function out of `_setup` so that
we can call `settings_org.sync_realm_settings` without opening
settings page at least once.

This also fixes a minor bug in which if we have two tabs opened and
in one we haven't opened settings page at least once and in
another we change an org setting, then we get an exception in
the former tab because of the event as `sync_realm_settings`
isn't defined yet.
2018-03-29 08:00:50 -07:00
Shubham Dhama 29f57d54a0 org settings: Move discard_property_element_changes out of `_setup`. 2018-03-29 17:44:39 +05:30
Shubham Dhama e53c6f5639 org settings: Move independent functions out of `_setup` function.
This commit moves some functions out of `_setup` function which are
independent of each other and any function inside `_setup` function.
2018-03-29 17:44:39 +05:30
Shubham Dhama 4472f5b230 org settings: Prefer `val` over `attr` to change value of dropdown.
Changing the selected value of dropdown by `val` has more advantage
over `attr` especially in the case when dropdown value is chnaged
multiple times like due to events and discarding changes.

Though it is applicable to other elements but in this commit it is just
used for `id_realm_create_stream_permission` dropdown.

There are many question about this at stackoverflow:
https://stackoverflow.com/a/22093618/7418550
https://stackoverflow.com/a/4837162/7418550
2018-03-29 17:44:38 +05:30
Shubham Dhama 6ec5c28e97 org settings: Move property types out of `_setup` function.
Since we don't have any string needed to be translated in
property_types we can move it outside `_setup` function to
get to the safe side if they needed to get accessed before
`_setup` is called.
2018-03-29 17:44:27 +05:30
Shubham Dhama 33b6e19e31 org settings: Remove obsolete property_types's status messages.
Since now we use buttons as a method to show saving status,
we don't need anymore `msg`, `checked_msg` etc.
2018-03-27 16:48:29 -07:00
Shubham Dhama 2f496ffe1f org profile: Use new org setting changes saving framework.
With this we have the same way to save changes done in org profile
subsection, i.e. show "Save" button beside header of subsection,
add "Discard changes" button for org profile subsection and
show "Save" and "Discard" button only when needed.

Also, there is so much code which become obsolete which is removed
in this commit.
2018-03-27 16:48:28 -07:00
Shubham Dhama 3e47a9fe22 org settings: Add real-time syncing for property changes. 2018-03-25 08:30:47 -07:00
Shubham Dhama 315058498b org settings: Handle dependent sub settings manually.
This replaces the previous logic of triggering change() event.
(Also, when we trigger the change() event whole path for detecting
changes in a subsection are triggered which isn't good.)
2018-03-25 08:30:04 -07:00
Shubham Dhama 84a5786b2e org settings: Refactor the discard changes function.
This extract the logic of resetting the value of a single property element
at a time so that we can reuse this for real-time-syncing.
2018-03-25 08:30:04 -07:00
Shubham Dhama a779fc6095 org settings: Use disable_sub_setting_onchange for dependent checkbox.
This makes use of `settings_ui.disable_sub_setting_onchange` for
handling dependent `id_realm_disallow_disposable_email_addresses`
checkbox when `id_realm_restricted_to_domain` is changed.
2018-03-25 08:30:04 -07:00
Shubham Dhama f17fa3305b org settings: Fix discard changes for realm_create_stream_permission.
On discarding changes made for `realm_create_stream_permission` always
"by_admin_user_with_custom_time" get selected because
`create_stream_by_admins_only` isn't a valid page_param.
2018-03-25 08:30:04 -07:00
Steve Howell aac76c14bd settings: Avoid duplicate form handlers.
For forms that are built early in setting up the settings panel,
we don't want to attach multiple submit handlers every time we
go into the gear menu, so we use "off" to clear any old handlers.

We also attach handlers directly to the form, instead of
using delegation up to the container div.
2018-03-25 08:28:04 -07:00
Tarun Kumar 5ac767149c user-groups: Update UI to mention only members can edit a user group.
Also, we remove unnecessary tips regarding modification settings.

Remove 'Only organization administrators can edit these settings'.
Remove 'Anyone in this organization can add user groups'.
2018-03-23 14:44:47 -07:00
Shubham Dhama c50117418e org settings: Fix unexpected saving of input-text fields on "Enter".
Before this commit when we press enter in the text-input field the
first subsection get saved because a click event is triggered for
the first save button (of first subsection) irrespective of the
location of text input field in the whole form which is expected
as a default behavior of the forms.

The simple fix is to make the button of type "button" and override
action of "enter" in an input field.

More info at https://stackoverflow.com/a/12914700/7418550 and
https://stackoverflow.com/a/7060762/7418550
2018-03-23 07:28:46 -07:00
Shubham Dhama 8304c37dfb org settings: Make each subsection of org-permissions independent.
This makes each subsection of org-permissions independent from the
perspective of saving changes.
All the behavior we have for org-settings are also ultimately
reflected here as well like individual "Save" button for each
subsection, "Discard" button for discarding changes done in a
subsection and appearance of this button only when required.
2018-03-23 07:28:46 -07:00
Shubham Dhama 3b7f045da5 org settings: Extract function to discard changes done in a subsection.
In the new function, property values are handled more carefully i.e.
we first check whether property_name refers to a property values
which we can't get from the value of input elements like we have in org
permissions section for properties like realm_add_emoji_by_admins_only
where we have used dropdown and hence we get a string value but we
expect a true/false (check/uncheck) value.

Also, it is better to trigger a `change` event after changing a value
because we have properties which are dependent on the values of another
settings. Previously we trigger `click` event for checkboxes but
there exist some settings other than checkboxes like dropdown
for realm_create_stream_permission where realm_waiting_period_threshold
only appears after selecting custom values for threshold value from
dropdown.
2018-03-23 07:28:46 -07:00
Shubham Dhama f97cff54aa org settings: Fix casper failing due to check_property_changed. 2018-03-22 12:51:09 -07:00
Shubham Dhama 6cdbcfd80c org settings: Refactor check_property_changed.
In this refactor property values are handled more carefully i.e.
we first check whether property_name refers to a property values
which we can't get from the input elements like we do have in org
permissions section for properties like realm_add_emoji_by_admins_only.

Small refactor in property_value_element_refers is to prevent many
return statements on further addition of property names.
2018-03-22 11:44:58 -07:00
Shubham Dhama 42ee40d1bc org settings: Refactor failed status element to use class.
This changes failed status element to use class
`.admin-realm-failed-change-status` rather than id so that we can use
the same code in `save_organization_settings()` in future to refer to
failed-status element of that section.
2018-03-22 23:17:13 +05:30
Shubham Dhama 22ab571b8f org permissions: Extract logic to complete request data for subsection.
To keep click handler for "save" button clean, we extracted the
the `if` statements where we complete request data for certain fields
which aren't mentioned in `property_types`.
2018-03-22 23:17:13 +05:30
Shubham Dhama 9ca335bcb2 org settings: Add discard button to discard changes for a subsection.
This will reset the changes done in a subsection to the current ones
in page_params.

It will only appear when there are some user-provided changes to be reset.
2018-03-20 14:48:59 -07:00
Shubham Dhama 62f646816d org settings: Show "save" button only when setting is changed.
With this "Save" button is only shown when there are changes in a
subsection. This means if we changed a setting and reverted it back to
original ones, then, "Save" button will get disappear. Hence, we're shown
"Save" when there are some property changes to send to the server.
2018-03-20 14:48:12 -07:00
Shubham Dhama be0298314a org settings: Make each subsection independent for saving changes.
This makes each subsection(like "Message feed") independent of changes
done in any other subsection and the save button of each subsection
saves the changes done in that subsection only.
2018-03-20 14:48:10 -07:00
Shubham Dhama c4fda0e19e org settings: Extend populate_data_for_request for selected property types.
To populate data for requests limited to only selected input elements,
we have to extend `populate_data_for_request` for objects other
than `property_types`, e.g. now we can collect data only for user identity
by passing org_permissions.user_identity as changing_property_types.
2018-03-15 17:06:45 -07:00
Shubham Dhama c4d0fb602c org settings: Split `property_types` according to sections.
This splits property types according to sections in
"Organization settings" viz. Organization settings, Organization
permissions, and Organization profile. Where org. settings and
org. permissions are further categorized according to the
subsections.
These changes are made to save changes for each subsection independently.
2018-03-15 17:06:45 -07:00
Vishnu Ks 3da2a1e18d admin: Add a realm setting to disallow signups using disposable emails.
Fixes #2955
2018-03-11 22:05:58 -07:00
Shubham Dhama 777b6de689 org settings: Add setting to prevent users from adding bots.
Fixes: #7908.
2018-03-09 13:21:55 -08:00
YJDave eb67c46928 message editing: Move update msg-topic-edit-icon func to `message_edit.js`.
Move function `update_message_topic_editing_pencil` to file
`message_edit.js` from `settings_org.js`.
2018-03-06 07:17:28 -08:00
YJDave a4366d9a6d message editing: Clean update msg-topic-edit-icon function.
`update_message_topic_editing_pencil` function update edit
icon for message topic in message row header.

- Remove erroneous `meta.loaded` check.
- Add proper check of message editing permission in realm
  before updating message-topic-edit-icon in function.
- Update `always-visible-topic-edit` element in function
  simultaneously.
2018-03-06 07:17:28 -08:00
YJDave d360a70523 static/js/settings_org.js: Rename func which updates msg-topic-edit-pencil.
Rename `toggle_allow_message_editing_pencil` to
`update_message_topic_editing_pencil` in `settings_org.js`.
As this function update the pencil icon for updating message
topic in message row header.
2018-03-06 07:17:28 -08:00
YJDave 59cf67062f settings: Add generic func to disable settings elements in UI.
We have some settings which are inter-dependent. If one setting
is checked or unchecked, it's dependent-sub-setting get disabled
or enabled. i.e. If user unchecked setting allow-message-editing
then message-editing-time-limit setting should get disabled in UI.

Add generic function to change disable attribute of sub settings
on checked or unchecked event of main setting in `settings_ui.js`.
2018-03-03 08:38:54 -08:00
Tim Abbott 72a31150f7 settings: Move name/email change display commits to correct file.
These most properly belong in settings_account.js, since they are
updating the UI widgets on that page.
2018-03-02 12:49:36 -08:00
Tim Abbott 9fe0f81f4a settings: Simplify is_admin logic for name changes.
This now also should correctly handle when a user's state as to
whether they are an admin changes.
2018-03-02 12:49:36 -08:00
Tim Abbott 4e32b5df00 settings: Rename functions for updating email/name change UI.
These functions no longer do a toggle.
2018-03-02 12:49:36 -08:00
Tim Abbott 63db3e0b3d settings: Fix erroneous meta.loaded check for name/email change.
That check is for the settings_org.js page, which is of course not
actually the page that these fields are on.
2018-03-02 12:49:36 -08:00
Tim Abbott 9b8c541a74 settings: Set state of name/email change fields from data.
Rather than having a toggle function that just flips the state, it's
more correct to have the state just be set to what it should be.

Also, we clean up the use of .attr() for a thing better accessed via
.prop().

We should probably rename the function at this point, but we save that
for a future commit.
2018-03-02 12:49:32 -08:00
YJDave ce46cd914a settings: Allow admin to change email/name even if it is disabled in realm.
Allow realm admin users to change their email or name even,
changing name or email is disabled in realm.
2018-03-02 12:17:00 -08:00
Aastha Gupta d124597f4b org-settings: Add setting to turn off welcome emails.
This adds an organization-level setting to provide an option to turn
off the welcome emails.

Fixes #8000.
2018-02-28 12:39:01 -08:00
Shubham Dhama 9feae472f8 org settings: Add button to deactivate organization.
This adds button under "Organization profile" settings, which
deactivates the organization and sends an "event" to all the
active user and log out them.

Fixes: #8212.
2018-02-18 10:20:38 -08:00
ihsavru 4103996a22 org-settings: Fix styling of Allowed Domains modal.
Fixes: #7628.

Cleaned up by Brock Whittaker and Node tests fixed by Steve Howell.
2018-02-16 16:00:21 -08:00
ihsavru 0f443c89f2 settings: Allow selecting 'restrict to domain' even if no domains selected.
Fixes #7626
2018-02-05 13:34:36 -08:00
YJDave 15dd94035c org settings: Handle NEW_USER_BOT not being set.
If NEW_USER_BOT is not configured in organization, then disable setting
for selecting stream for new user notification.
2018-01-23 15:23:25 -05:00
YJDave 8a1fb5bae5 org settings: Change add emoji permission to be dropdown. 2018-01-23 14:26:40 -05:00
YJDave 676d543d86 org settings: Change create stream permission to be dropdown.
Organization permission setting allow-user-to-create-stream is
change to dropdown, from checkbox.
2018-01-23 14:26:40 -05:00
Steve Howell 8530ed0b5e org settings: Make button-clicking code more clear.
On the "Organization settings" page, we had two Save buttons
for admins that had identical markup.  This was confusing for
people reading the code.  Now the two buttons have different
markup and individual, targeted click handlers (albeit still
calling the same function to do most of the work).

The context of this fix is that I was debugging a
Casper flake where our Casper tests were essentially clicking
on the same button twice.  Depending on the timing,
the second button click could cause a "No changes saved!"
behavior that confused the Casper test.  It is unclear whether
Casper was clicking both buttons here (in which case this fix
is necessary) or the same button twice (in which case this fix
just removes a nasty red herring for debugging).

The code still has the flaw that both buttons basically submit
the same data to the server, despite the appearance on the page
that there are two forms.  The best fix for that is probably
just to move the Language/Notifications stuff to another
panel.  I wanted to avoid touching this code altogether, but
the minor modifications here were necessary to improve the
Capser testing situation.
2018-01-16 13:25:19 -05:00
YJDave 2d52131554 user settings: Fix live updates in email change setting.
To toggle email change display, replace display = None
to disabled = true.
Email field shouldn't be removed from settings, it should only
disabled if email changes are disabled in realm.
2018-01-08 14:35:03 -05:00