Commit Graph

109 Commits

Author SHA1 Message Date
Ganesh Pawar e7b9173ef5 default_language: Migrate modal to dialog_widget. 2021-11-16 17:02:29 -08:00
Lauryn Menard 6046f94521 settings: Fix live `update_page` behavior for user settings.
Changes `update_page` to only update the modified user setting instead
of updating all of the user settings on the page. This is modeled on
the behavior for updates to the realm user default settings.

This is a follow up on feedback in #20070.
2021-11-10 13:03:20 -08:00
Sahil Batra 4a1153b06c settings: Fix bug in "Default user settings" section.
There was no heading for "Time format" setting in the
"Default user settings" section and thus no save-discard
widget to update the setting. This commit fixes the bug
and changes the heading to be only "Time" since there is
no realm-level default of language setting.

This bug was introduced in adb612a0b4.
2021-11-09 10:03:23 -08:00
Lauryn Menard 73710e1cf0 user_settings: Add option to disable escape key navigation to default view.
Add `escape_navigates_to_default_view` as a bool setting in
UserBaseSettings model and implement it as a checkbox that toggles
the hotkey implementation of escape to the default view in the
advanced user display settings.

With /help/ documentation edits from Alya Abbott.

Fixes #20043.
2021-10-29 18:15:30 -07:00
isakhagg adb612a0b4 settings: Rearrange display settings.
This provides a cleaner organization for our display settings, to make
browsing them more intuitive for new users.

We still need to update the /help/ documentation following this migration.

Fixes #19960.
2021-10-21 15:23:19 -07:00
Sahil Batra 38cf2d07a6 settings_display: Refactor code to use a single handler.
This commit refactors the display settings code to use
a single handler similar to what we do in notification
settings. We still keep default language and emojiset
setting as they are handled differently and they do
not call 'change_display_setting' directly on changing
input.

We refactor the 'change_display_setting' to directly
accept status element as parameter and not class as
a string. We also add a common class to the subsection
div such that we can get status element for each of
them easily.
2021-10-08 13:46:22 -07:00
Sahil Batra 78da9d21f3 settings: Remove unnecessary check of for_realm_settings.
We do not need to check for_realm_settings variable for
left_side_userlist handler since realm-level defaults
now uses save-discard widget and we return early in
that case and thus for_realm_settings will always be
false at this point.
2021-10-08 13:46:22 -07:00
Sahil Batra 30766ec482 settings: Remove patch_url from user_settings_panel.
We remove patch_url from settings_display.user_settings_panel
since realm-level defaults section uses save-discard widget
and its code is separate from user display settings and we
can directly use "/json/settings" as url in user settings code.
2021-10-07 14:23:24 -07:00
Sahil Batra d9034dfda2 settings: Do not pass settings_panel parameter to change_display_setting.
We don't need container element and patch_url in change_display_setting
since this function is only used for user-display settings and not for
realm-level settings which now uses save-discard widget. So we do not
pass settings_panel as parameter to change_display_setting.
2021-10-07 14:23:24 -07:00
Sahil Batra 9bc2813138 settings: Remove language_modal_elem from user_settings_panel.
We added language_modal_elem to settings_display.user_settings_panel
object considering there would be realm-level default_language
setting and we would need to access the modal element using a
variable to avoid code duplication. But now we have decided that
we do not want the setting and we would instead use browser's
language to set the language for new user, so now we do not need
this variable and we can instead use id of the modal directly.
2021-10-07 14:23:24 -07:00
Sahil Batra 89be686d9e settings: Remove unnecessary if condtions checking for_realm_settings.
This commit removes unnecessary if condtions which are checking
for_realm_settings value which are basically present to handle
the code which is only for user-level settings, but since we
now return early for the realm-level defaults code we do not
need these conditions.

This is done in a separate commit just to make the original commit
adding save/discard widget easy to review.
2021-10-07 10:16:28 -07:00
Sahil Batra eed0a14ab0 settings: Use save-discard widget in realm-level defaults section.
This commit adds save-discard widget in the realm-level defaults
section. We use most of the functions used in settings_org.js
by passing for_realm_default_settings and add conditionals
according to it.

Some of the major changes wrt to the organzation settings code
are -

- We use element name attribute here to get the setting name from
element instead of id. We can add id for the elements here but
there is a problem doing so for the emojiset setting as for the
radio buttons we use four different input elements and all being
for the same setting.

- Added separate cases in discard_property_element_changes and
get_input_element_value to handle the radio buttons.

- We do not need get_complete_data_for_subsection here because
all settings are controlled by single field in DB and single
element in UI and thus we can simply get changed setting values
from populate_data_for_request.

- Added org-subsection-parent to the subsection container and
prop-element to the input and select elements so that we can
use the existing code.

- Modified get_subsection_property_elements to just return the
input element which is selected for emoji-settings subsection and
not all the input elements because we only need the selected value
of emojiset. We need other elements also when discarding the changes
but we handle it separately.
2021-10-07 10:16:27 -07:00
Sahil Batra e67b4cf499 settings: Show message to reload only for user settings.
We incorrectly show message to reload in the savings indicator
for realm-level default of left_side_userlist setting. It should
be shown only for user-level setting since no change will take
place for the user changing realm-level default.
2021-09-28 12:40:09 -07:00
Sahil Batra c233ee9935 settings: Migrate twenty_four_hour_time setting to RealmUserDefault.
This commit removes the existing default_twenty_four_hour_time field in
Realm table which was used to set the twenty_four_hour_time setting of
new user on joining and instead we now use the twenty_four_hour_time
field of RealmUserDefault table for the same.

With some tweaks by tabbott to clarify the documentation.
2021-09-23 10:44:42 -07:00
Sahil Batra e43d469e9a settings: Pass a single object to settings_display functions.
We refactor the code for user display settings and realm-level
defaults of display settings to pass a single object consisting
of container element, settings object, url and for_realm_settings
bool variable, to the functions, instead of passing them as
separate variables.
2021-09-21 14:56:27 -07:00
Sahil Batra 96d6bf28db settings: Add UI for realm-level defaults of display settings.
This commit adds a new module settings_defaults.js which calls
the functions in settings_display passing appropriate container
element and settings object as parameters.
We also add one more parameter for_realm_settings to some of the
functions in settings_dislay to differentiate between the user
and realm-level settings.
2021-09-15 09:56:32 -07:00
Sahil Batra 6bae097bf1 settings: Refactor settings_display.js code.
This commit refactors the code in settings_display.js
by modifying the functions to receive the container
element and settings object as parameter such that
we can use the same functions for realm-level
settings by passing appropriate container element
and settings object.

This change is needed as settings_display will be
used as a common module for user settings and realm
level settings.

We also rename the default_language_name variable in
settings_display to user_default_language_name as we
would add a separate variable for realm-level setting
in future.
2021-09-15 09:50:31 -07:00
Sahil Batra 0c11ced0a0 settings: Refactor settings_display.js to use settings_object variable.
This commit changes the settings_display.js code to reference the
user_setings object using settings_object variable. This will help
to easily use the same code for realm-level defaults where instead
of user_settings realm_user_settings_defaults object will be used.
2021-09-13 08:32:31 -07:00
Anders Kaseorg 1376feda93 docs: Add missing space in “emoji set”.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-09-08 15:31:28 -07:00
Sahil Batra d05730a199 settings: Rename classes for display settings elements.
We rename the class of display setting elements by prefixing
them with 'setting_' for clarity.
2021-08-20 07:51:11 -07:00
Sahil Batra 79fa7f9609 settings: Refactor change_display_setting to have url paramter.
This commit refactors change_display_setting function to accept
url as a paramter instead of directly using '/json/settings'
such that we can use the same function for realm-level settings.
2021-08-20 07:50:51 -07:00
Sahil Batra 9bd1ea229c settings_display: Refactor change_display_setting function.
This commit refactors change_display_setting function to
accept container element as a paramter and then determine
the correct status element from it. This is the prep commit
for adding realm-level default settings UI.
2021-08-20 07:50:51 -07:00
Sahil Batra c5cc4fb114 settings: Refactor default-language modal code.
We add a prefix to id of default_language_modal.hbs
such that we can use the same code for user settings
and realm-level settings.
We also add a class "default_language_modal" to the
modal div to avoid duplicate css.
2021-08-20 07:50:51 -07:00
Sahil Batra 3adf5e6383 settings: Refactor frontend code for display settings.
This is a prep commit for adding UI for realm-level
default of user settings. We refactor the code to use
classes instead of ids such that we can use the common
code for the new settings.
2021-08-20 07:40:20 -07:00
Sahil Batra 7ea3a53d49 settings: Remove unnecessary code.
We were using incorrect element as we changed the input from
select to radio buttons in 439bc2920a.
This code was originally added in 6cb03ea78e (though in a
different file) and was removed from sometime and then added
again in e7311cdf5d. But in the meantime the input was
changed to radio, which resulted in incorrect code.
2021-08-19 02:50:50 -07:00
Sahil Batra 7b74bd1428 settings: Fix incorrect elements used for emojiset loading spinner.
We were using emojiset_spinner element in destroy_indicator, but
there is no such element and emoji-settings-status element is used
in make_indicator, so destroy_indicator should also use the same
element.

This was added originally in 6cb03ea78e (though in a different
file) and was removed for sometime and then readded in e7311cdf5d.
But between these two commits, the setting was changed to be a
radio element and thus the spinner elements were also changed.
2021-08-19 02:50:50 -07:00
Sahil Batra 998d710275 frontend: Add new user_settings module for user's settings.
We add a new user_settings module similar to page_params
module in frontend and use it to access user's personal
settings instead of page_params.
2021-08-01 15:30:17 -07:00
sahil839 bbee0fdf6f settings: Use '/settings' endpoint for changing display settings.
We have merged the '/settings/display' and 'settings/notifications'
endpoints to '/settings' in backend. This commit updates the
frontend code to '/settings' endpoint for updating display settings
instead of '/settings/display' endpoint.
2021-07-19 21:14:33 -07:00
sahil839 b94d6c1a20 settings: Move timezone setting from display settings to profile.
The user timezone is only used for user's profile, so we can
move this setting to the Profile panel of settings and this
will also help us in covering some space when there are no
custom profile fields for the organization.
2021-06-30 16:56:03 -07:00
Tim Abbott 0a1eaf0384 i18n: Reorganize language_list logic.
This reorganization follows our modern coding conventions for avoid
leaving data in page_params that should be owned by a single module.
2021-06-17 17:22:10 -07:00
Gaurav Pandey 56d85fb833 settings: Remove default_language_name from page_params.
default_language_name was a part of page_params which is actually
redundant considering that we already have language_list and
default_language available to frontend which can be used to
get the default_language_name and hence prevents the backend
from sending an additional parameter.

Fixes part of #18673.
2021-06-17 16:56:21 -07:00
Gaurav Pandey 9abe1cafbe api: Fix encoding of strings in display settings endpoint.
* Remove unnecessary json validator for string validator.
* Update frontend to pass right validator.
* Update zulip.yaml to pass right parameter for curl request
  in openapi.
* Update python_examples to pass right paramater.

Fixes part of #18035.
2021-05-10 10:03:32 -07:00
Gaurav Pandey 36ad9b7d0e api: Fix encoding of strings in user settings endpoints.
* Remove unnecessary json_validator for string parameters.
* Remove unnecessary JSON encoding in frontend calls.  Structurally,
  JavaScript does correct encoding without explicit JSON encoding.

Fixes part of #18035.
2021-05-07 14:10:45 -07:00
Anders Kaseorg a397d51670 ui_report: Convert messages to FormatJS.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-13 17:41:10 -07:00
Anders Kaseorg 38ffd47b90 js: Convert static/js/page_params.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg bb1b2048bd js: Convert static/js/i18n.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg ea9ca6b7d0 js: Use jQuery as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:08:25 -08:00
Aman Agrawal e587c029f6 display_settings: Allow user to set default_view.
TextField is used to allow users to set long stream + topic narrow
names in the urls.

We currently restrict users to only set "all_messages" and
"recent_topics" as narrows.

This commit achieves 3 things:
* Removes recent topics as the default view which loads when
  hash is empty.
* Loads default_view when hash is empty.
* Loads default_view on pressing escape key when it is unhandled by
  other present UI elements.

NOTE: After this commit loading zulip with an empty hash will
automatically set hash to default_view.  Ideally, we'd just display
the default view without a hash, but that involves extra complexity.

One exception is when user is trying to load an overlay directly,
i.e. zulip is loaded with an overlay hash. In this case,
we render recent topics is background irrespective of default_view.

We consider this last detail to be a bug not important enough to block
adding this setting.
2021-03-11 18:09:08 -08:00
Anders Kaseorg 4d738ebe15 js: Convert static/js/settings_display.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 45b8e0244e js: Convert static/js/overlays.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 26710a4370 js: Convert static/js/ui_report.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 09920af211 js: Convert static/js/channel.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 3faae49dc0 js: Convert static/js/loading.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg e16687af83 js: Convert static/js/settings_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 10:27:14 -08:00
Anders Kaseorg aa650a4c88 js: Escape strings interpolated into CSS selectors with CSS.escape.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-04 11:00:06 -08:00
Anders Kaseorg 279e4b819e js: Elide .js and .ts extensions from imports and requires.
This will be required for TypeScript.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-01 16:43:02 -07:00
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00
Anders Kaseorg 96dcc0ce6e js: Use ES6 object literal shorthand syntax.
Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-21 12:42:22 -07:00
Anders Kaseorg 4e42137bd9 js: Replace deprecated jQuery event handler shorthand.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-21 12:01:26 -07:00
Anders Kaseorg b65d2e063d js: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:25 -07:00