Commit Graph

221 Commits

Author SHA1 Message Date
Pranav 41cdf11e16 settings_account: Remove redundant call to loading.make_indicator.
Previously, a spinner was created and this spinner element passed to
do_settings_change function, which also created a spinner, making the
first spinner creation useless. This commit removes the spinner creation
logic and just passes the element where the spinner is to be rendered.
2020-04-30 16:13:49 -07:00
Jagan 8ae34eaa12 settings UI: Make the settings avatar delete/edit UI slicker.
Added UI support for uploding the new profile picture by
clicking on the avatar rather than a button.
Added new spinner for loading indication while uploading
a new avatar over the avatar area.
Fixes #10255
2020-04-15 15:15:57 -07:00
Tim Abbott 0e57975643 settings: Fix downloading zuliprc files with hidden emails.
With EMAIL_ADDRESS_VISIBILITY_NOBODY (or as a non-admin with
EMAIL_ADDRESS_VISIBILITY_HIDDEN), we were incorrectly generating
zuliprc files containing the shareable email address, which naturally
didn't work.
2020-04-09 13:24:52 -07:00
Anders Kaseorg 5ba593f124 int_dict: Replace with Map.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-25 15:37:37 -08:00
Pragati Agrawal f68e91e6e1 settings_account: Fix real-time sync of text on the "Full name" button.
The issue was the wrong selector.

Fixes: #13820.
2020-02-24 17:30:05 -08:00
Anders Kaseorg 0e3acb5ce6 settings_account: Convert all_field_template_types from object to Map.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-12 10:39:01 -08:00
Anders Kaseorg 7b0dea0351 js: Convert jQuery.each to for…of.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-10 14:08:12 -08:00
Anders Kaseorg 02511bff1c js: Automatically convert _.each to for…of.
This commit was automatically generated by the following script,
followed by lint --fix and a few small manual lint-related cleanups.

import * as babelParser from "recast/parsers/babel";
import * as recast from "recast";
import * as tsParser from "recast/parsers/typescript";
import { builders as b, namedTypes as n } from "ast-types";
import { Context } from "ast-types/lib/path-visitor";
import K from "ast-types/gen/kinds";
import { NodePath } from "ast-types/lib/node-path";
import assert from "assert";
import fs from "fs";
import path from "path";
import process from "process";

const checkExpression = (node: n.Node): node is K.ExpressionKind =>
  n.Expression.check(node);
const checkStatement = (node: n.Node): node is K.StatementKind =>
  n.Statement.check(node);

for (const file of process.argv.slice(2)) {
  console.log("Parsing", file);
  const ast = recast.parse(fs.readFileSync(file, { encoding: "utf8" }), {
    parser: path.extname(file) === ".ts" ? tsParser : babelParser,
  });
  let changed = false;
  let inLoop = false;
  let replaceReturn = false;

  const visitLoop = (...args: string[]) =>
    function(this: Context, path: NodePath) {
      for (const arg of args) {
        this.visit(path.get(arg));
      }
      const old = { inLoop };
      inLoop = true;
      this.visit(path.get("body"));
      inLoop = old.inLoop;
      return false;
    };

  recast.visit(ast, {
    visitDoWhileStatement: visitLoop("test"),

    visitExpressionStatement(path) {
      const { expression, comments } = path.node;
      let valueOnly;
      if (
        n.CallExpression.check(expression) &&
        n.MemberExpression.check(expression.callee) &&
        !expression.callee.computed &&
        n.Identifier.check(expression.callee.object) &&
        expression.callee.object.name === "_" &&
        n.Identifier.check(expression.callee.property) &&
        ["each", "forEach"].includes(expression.callee.property.name) &&
        [2, 3].includes(expression.arguments.length) &&
        checkExpression(expression.arguments[0]) &&
        (n.FunctionExpression.check(expression.arguments[1]) ||
          n.ArrowFunctionExpression.check(expression.arguments[1])) &&
        [1, 2].includes(expression.arguments[1].params.length) &&
        n.Identifier.check(expression.arguments[1].params[0]) &&
        ((valueOnly = expression.arguments[1].params[1] === undefined) ||
          n.Identifier.check(expression.arguments[1].params[1])) &&
        (expression.arguments[2] === undefined ||
          n.ThisExpression.check(expression.arguments[2]))
      ) {
        const old = { inLoop, replaceReturn };
        inLoop = false;
        replaceReturn = true;
        this.visit(
          path
            .get("expression")
            .get("arguments")
            .get(1)
            .get("body")
        );
        inLoop = old.inLoop;
        replaceReturn = old.replaceReturn;

        const [right, { body, params }] = expression.arguments;
        const loop = b.forOfStatement(
          b.variableDeclaration("let", [
            b.variableDeclarator(
              valueOnly ? params[0] : b.arrayPattern([params[1], params[0]])
            ),
          ]),
          valueOnly
            ? right
            : b.callExpression(
                b.memberExpression(right, b.identifier("entries")),
                []
              ),
          checkStatement(body) ? body : b.expressionStatement(body)
        );
        loop.comments = comments;
        path.replace(loop);
        changed = true;
      }
      this.traverse(path);
    },

    visitForStatement: visitLoop("init", "test", "update"),

    visitForInStatement: visitLoop("left", "right"),

    visitForOfStatement: visitLoop("left", "right"),

    visitFunction(path) {
      this.visit(path.get("params"));
      const old = { replaceReturn };
      replaceReturn = false;
      this.visit(path.get("body"));
      replaceReturn = old.replaceReturn;
      return false;
    },

    visitReturnStatement(path) {
      if (replaceReturn) {
        assert(!inLoop); // could use labeled continue if this ever fires
        const { argument, comments } = path.node;
        if (argument === null) {
          const s = b.continueStatement();
          s.comments = comments;
          path.replace(s);
        } else {
          const s = b.expressionStatement(argument);
          s.comments = comments;
          path.replace(s, b.continueStatement());
        }
        return false;
      }
      this.traverse(path);
    },

    visitWhileStatement: visitLoop("test"),
  });

  if (changed) {
    console.log("Writing", file);
    fs.writeFileSync(file, recast.print(ast).code, { encoding: "utf8" });
  }
}

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-07 14:09:47 -08:00
Steve Howell b8f01f9cda people: Rename method to get_by_user_id().
This name is consistent with:

    get_by_email()
    get_by_name()
2020-02-05 12:04:56 -08:00
Tim Abbott df6b90db3c settings: Fix copy-from-clipboard behavior for bot tokens.
We do this by cleaning up the API for generate_zuliprc_content,
allowing us to deduplicate the previously incorrect code.
2020-01-31 15:11:20 -08:00
Anders Kaseorg e6178f2abd settings_account: Return IntDict from initialize_custom_user_type_fields.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-01-16 13:23:47 -08:00
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00
Anders Kaseorg d17b577d0c js: Purge useless IIFEs.
With webpack, variables declared in each file are already file-local
(Global variables need to be explicitly exported), so these IIFEs are
no longer needed.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-25 13:51:21 -07:00
YashRE42 248fbadfb6 account_settings: Refactor avatar settings hbs.
This refactor removes some slightly complex conditional logic for
displaying avatar controls from the handlebar template to js.
2019-09-30 11:10:56 -07:00
Thomas Ip cbae51db63 settings: Move API key form into its own modal.
The modal is rendered dynamically to avoid password managers
inserting passwords into the input field too aggressively.

Fixes #12523.
2019-08-14 10:50:45 -07:00
Thomas Ip 75db8fecf8 refactor: Remove redundant dataType option to channel.post(). 2019-08-14 10:50:45 -07:00
Yashashvi Dave 865a7204f9 custom fields: Set generic click handler on remove_date buttons.
This commit adds click handler on date type custom profile
fields on field initialization itself.
This commit also fixes the bug in date type fields in user
profile in org settings.
2019-07-29 15:06:35 -07:00
Yashashvi Dave b93ca2fc50 custom fields: Hide remove_date button for none value date fields.
This commit adds a click handler on datepicker custom profile
fields, which hides the `remove_date` button if the field value
is not set.

Fixes part of #11453
2019-07-29 15:06:35 -07:00
Yashashvi Dave 2e8cf6984e user settings: Fix click handler errors on datepicker profile field.
On change value click handlers on user profile fields in user settings
were also initialized on profile fields in org settings -> users
section. In org settings -> users, we do not need on change value
click handlers.
This commit fixes above issue by setting up handlers only on
user settings page.
2019-07-29 15:06:35 -07:00
Yashashvi Dave 4860904284 user setting: Update user display message for setting change-email. 2019-07-25 13:33:44 -07:00
Yashashvi Dave 5506b16fa8 user settings: Add separate alert-save widget for profile custom fields.
Fixes part of #12748
2019-07-25 13:33:44 -07:00
Tim Abbott d2f1c84001 settings: Rewrite logic for whether users can change name.
This moves this somewhat complicated, duplicated logic into a single
JavaScript function.
2019-07-16 11:43:57 -07:00
Anders Kaseorg db0b33842c templates: Replace templates.render with require calls.
This removes an unnecessary layer of indirection and allows webpack to
catch filename mistakes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:14 -07:00
Anders Kaseorg 3c3471b720 templates: Rename *.handlebars ↦ *.hbs and - ↦ _.
Tweaked by tabbott to avoid accidentally disabling the linter for
handlebars templates.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:03 -07:00
Yashashvi Dave ff75c77f7a account settings: Replace logic with existing functions.
Replace settings api calls with existing function
`settings_ui.do_settings_change()`. This commit also
adds a ui element for save alert notificaiton.
2019-07-11 13:29:08 -07:00
Yashashvi Dave e2e7d288a5 user settings: Fix garbage full name in change-full-name modal.
We should set full name evertime we open the modal. Otherwise
it will show garbage value which user has entered before but
did not save.
2019-07-11 13:17:59 -07:00
Yashashvi Dave 5be2207bf8 user settings: Fix custom URL field style in profile form.
Type of input element in profile form was not defined for
URL type custom fields. Because type was not passed to
template.
2019-07-09 17:21:54 -07:00
Yashashvi Dave d7ee2aced1 models: Add `external_account` in custom profile field types.
Add new custom profile field type, External account.
External account field links user's social media
profile with account. e.g. GitHub, Twitter, etc.

Fixes part of #12302
2019-07-09 17:21:54 -07:00
Tim Abbott 6a50460749 templates: Fix path to settings/dev_env_email_access.
This was broken in our migration to a nicer path system for our
handlebars templates.
2019-07-09 11:31:18 -07:00
Anders Kaseorg b0be0d5285 settings_account: Use webpack asynchronous require to load zxcvbn.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-02 16:50:03 -07:00
Thomas Ip f6aaf43029 refactor: Use explicit path when referencing handlebars templates. 2019-07-02 16:23:30 -07:00
Anders Kaseorg 12e6189970 signup, settings: Update password strength meter on input events.
Pasting a generated password into the password box triggers neither a
change event (until the password box is unfocused) nor a keyup event.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-06-27 14:51:19 -07:00
Anders Kaseorg 02d19d48fc tooling: Remove static/node_modules symlink.
It appears not to have been useful and makes it marginally harder to
reason about how module resolution works.  Paths to static content in
node_modules should be resolved through Webpack instead.

(This node_modules symlink was originally created in the pre-webpack world
where all of our static asset paths were based in static/.)

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-06-27 14:42:16 -07:00
Yashashvi Dave 1fef813914 static/js/settings_account: Clean function `append_custom_profile_fields`. 2019-06-06 22:36:16 -07:00
Tim Abbott 3b502fa235 settings: Fix getting API key when using social auth.
Long-term, we want this flow to do a full re-authentication, but this
makes the frontend consistent with the backend and fixes a confusing
bug where submitting the form ended up adding a weird `?password=`
thing to the URL, in addition to not working.

Fixes #12200.
2019-06-06 17:05:34 -07:00
Shubham Padia 884c19c3bc settings: NAME_CHANGES_DISABLED disables the name change button.
Fixes #12251.

Previously when disabling name changes in server settings, instead
of realm settings, the name edit button did not get disabled.
Changing name resulted in a message stating `no changes made`.
2019-05-03 12:58:51 -07:00
Shubham Padia 8c01f396db settings: Add AVATAR_CHANGES_DISABLED server setting.
Fixes #12132.
Realm setting to disable avatar changes is already present.
The `AVATAR_CHANGES_DISABLED` setting now follows the same
2-setting model as `NAME_CHANGES_DISABLED`.
2019-05-03 12:58:51 -07:00
Shubham Padia 4994a6c2c9 realm: Add setting to disable avatar changes.
This is useful when syncing avatars from an integrated LDAP/active
directory.

The upload avatar and delete avatar buttons are hidden if avatar
changes are disabled and the user is a non-admin.
If the user has a gravatar set, then the user will not be able to
upload an image as their avatar if avatar changes are disabled.

Part of #12132.
2019-05-03 12:52:43 -07:00
Hemanth V. Alluri 34db469700 org_settings: Fix error with undefined profile_field in bot settings.
This is a small patch to fix the error message an admin would receive if
they tried to change bot info and owner from the "bots" setting of the
organization settings panel.
2019-04-25 15:56:44 -07:00
Hemanth V. Alluri c192327a37 settings_account: Fix small typo in initialize_custom_user_type_fields. 2019-04-25 15:56:44 -07:00
Tim Abbott 6e8e7feffc settings: Fix webapp password change UI.
Apparently, this has been broken since
dee4e3fb89, due to the beforeSend code
here overriding the default beforeSend function that sets the CSRF
token.  The correct fix was actually to just run the relevant code
directly before the channel.patch call.

Fixes #11938.
2019-03-18 22:14:04 -07:00
Ben Muschol 243be91a9b settings: use i18n.t on profile picture upload message.
This fixes a small bug where the text previously was not being looked
up for translation.
2019-03-15 13:30:18 -07:00
Ben Muschol d526ff00f2 settings: Rename "user avatar" to "profile picture"
This renames references to user avatars, bot avatars, or organization
icons to profile pictures. The string in the UI are updated,
in addition to the help files, comments, and documentation. Actual
variable/function names, changelog entries, routes, and s3 buckets are
left as-is in order to avoid introducing bugs.

Fixes #11824.
2019-03-15 13:29:56 -07:00
Shubham Dhama dee4e3fb89 ajax: Fix wrong ajax setting name from beforeSubmit to beforeSend.
The beforeSubmit function was a feature of the jquery-form plugin that
we removed months ago; the appropriate similar feature of jQuery's
built-in AJAX library is beforeSend.
2019-02-02 23:05:10 -08:00
Yashashvi Dave 54d92446db user settings: Re-open settings after closing profile preview.
Users can preview their profile from user settings. If user
open preview profile modal from user settings, then closing
preview profile modal should redirect them to settings modal
again (since probably they want to keep editing).

This commit fixes above issue.
2019-01-15 15:42:26 -08:00
Harshit Bansal 4d68abd54f settings_account: Show error on failed avatar upload. 2019-01-13 08:17:31 +00:00
Hemanth V. Alluri e3aed0f7bc custom profile fields: Markdown rendering for custom profile field values.
This makes it possible it include our standard markdown formatting in
one's custom profile fields, allowing for links, emphasis, emoji, etc.

Fixes #10131.
2019-01-01 21:06:21 -08:00
Hemanth V. Alluri 28d344b4b5 custom profile fields: Pass value as part of a dictionary.
While we're at it, we remove the JSON parsing that was part of the
user field code path, since this function isn't responsible for
rendering user fields.
2019-01-01 21:05:28 -08:00
Tim Abbott bdaeccbca1 custom profile fields: Remove unnecessary JSON parsing step.
Apparently, our custom profile fields feature was parsing the "user
list" field type in multiple places, and ignoring the results in one
of them.  That code had been causing some confusion; the correct
solution is to just delete it, since the template rendering process
ignores that value for this field type.
2019-01-01 21:04:23 -08:00
Aditya Jain 8f0ccdf1c9 user settings: Fix active background links when a modal is visible.
A bug caused background links to open even when a modal in the user
settings overlay was active in the foreground. This commit fixes this
by disabling mouse events for the background when the modal is active,
and restoring them as soon as the modal starts closing.

Fixes #10654.
2018-12-09 22:32:53 -08:00
Tim Abbott 838dd6d273 lint: Add eslint enforcement for comma-spacing.
We've been enforcing this manually for a long time, and hadn't
realized it was missing from our eslint configuration.
2018-12-07 12:22:24 -08:00
Anders Kaseorg 9ba860b4f2 Avoid double redirects to /login and then to /login/.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2018-12-04 16:12:58 -08:00
Tim Abbott 02f09e2473 settings: Fix linter errors with user profiles. 2018-11-28 19:29:33 -08:00
Tim Abbott e39ebb7358 settings: Fix "Preview profile" button.
This was apparently broken in the refactoring in
a394778cde.
2018-11-28 16:46:15 -08:00
Yashashvi Dave 20b6d08ef7 static/js/settings_account.js: Extract `append_custom_profile_fields`. 2018-11-28 16:22:35 -08:00
Yashashvi Dave b2aeffd947 static/js/settings_account.js: Extract `intialize_custom_user_type_fields`. 2018-11-28 16:22:35 -08:00
Yashashvi Dave cd8f4dfac0 statis/js/settings_account.js: Extract `initialize_custom_date_type_fields`. 2018-11-28 16:22:35 -08:00
Rishi Gupta dd0126ff1b settings: Improve error message when deactivating the last user.
This PR was originally started by Rishi Gupta (see #10383).
2018-11-27 12:49:43 -08:00
Yashashvi Dave cc810f8951 settings: Fix width not maximum while uploading user avatar.
New user avatar width is not maximum when user upload
new image. Because wrong html element is accessed for
setting value of image src attribute.
This commit removes these code from success of ajax call,
cause we already handle this in event `user_events - avatar_url`.
2018-10-19 12:36:18 -07:00
Yashashvi Dave 9a09513b4d user settings: Add link to user profile popover.
Add button to view current user's profile popover
from user settings page.
2018-08-27 17:26:07 -07:00
Yashashvi Dave b5fb110166 static/js/settings_account.js: Handle null custom fields values. 2018-08-22 22:45:08 -07:00
Yashashvi Dave d5153bd136 events: Convert custom user field value to json object on update event.
In user type custom field, field value is list of user ids. We weren't
converting list to json object in update event payload. This throws
error in frontend, cause we store stringify representation of custom
field value. Therefore, after update event is recieved field-value-
type gets updated to array from string which throws json parsing error.
2018-08-22 22:45:08 -07:00
Yashashvi Dave 6e65235a6d zerver/lib/events.py: Add FIELD_TYPE_CHOICES_DICT to page_params.
This commit add FIELD_TYPE_CHOICES_DICT to page_params and replace
FIELD_TYPE_CHOICES.

FIELD_TYPE_CHOICES_DICT includes all field types with keyword, id
and display name. Using this field-type-dict, we can access field
type information by it's keyword, and remove all static use of
field-type'a name or id in frontend.
This commit also modifies functions in js where this page_params
field-types is used.
2018-08-21 11:37:51 -07:00
Tim Abbott 0132816471 profile fields: Fix fragile JavaScript for deleting date fields.
The JavaScript click handler for this feature was fragile in a way
that would break with upcoming changes to how we display the X
element.  We clean this up with a replacement implementation that
should be much less fragile.
2018-07-11 19:16:24 +05:30
Armaan Ahluwalia 6d255efe4c app: Prepare JS files for consumption by webpack.
This commit prepares the frontend code to be consumed by webpack.

It is a hack: In theory, modules should be declaring and importing the
modules they depend on and the globals they expose directly.

However, that requires significant per-module work, which we don't
really want to block moving our toolchain to webpack on.

So we expose the modules by setting window.varName = varName; as
needed in the js files.
2018-07-05 10:53:36 +02:00
Yashashvi Dave 554a0773dc custom fields: Add icon to delete value of date-type-custom-field. 2018-07-01 02:05:00 -07:00
Yashashvi Dave a6c03a4738 custom fields: Fix custom fields header not rendering properly.
Even when admin removes all custom fields from org, custom
fields header "Profile" doesn't get removed.
Render header "Profile" whenever custom fields data get changed.
2018-07-01 02:03:56 -07:00
Yashashvi Dave 8909cb1d15 custom fields: Allow list of users in user type of custom fields.
Allow user to add more than one user-value in user type of custom
fields.

Tweaked by tabbott to improve the models.py code and type annotations.
2018-06-16 09:37:49 -07:00
Yashashvi Dave 40590bb6b9 custom fields: Fix exception in rendering custom profile field template.
The function `settings_account.add_custom_profile_fields_to_settings`
called twice, which resulted in two templates objects being
rendered.

The function also didn't check whether settings overlay was open or
not when processing new events, and thus would throw an "undefined"
error if a custom profile field was editing while the overlay was not
open.

Fixes #9668.
2018-06-10 13:50:38 -07:00
Yashashvi Dave f7f039e772 custom fields: Add endpoint to delete value of custom profile data.
Add delete endpoint at `users/me/profile_data` to delete value of
custom profile data.

Fixes #9669
2018-06-07 08:35:04 -07:00
Shubham Dhama cc03f9fb8f eslint: Enable space-infix-ops rule.
More about rule at  https://eslint.org/docs/rules/space-infix-ops
2018-06-05 00:47:35 +05:30
Robert Hönig 7e7583e9cd frontend: bots: Extract encode_zuliprc_as_uri.
This is preparation for an upcoming refactoring where we pass a bot
ID, not the email/api_key, into the zuliprc generation functions in
the bots code path.
2018-06-04 08:38:14 -07:00
Yashashvi Dave 3654d4f92d jquery-form: Remove jquery-form use from get-API-key form in user settings. 2018-05-30 03:14:39 +05:30
Yashashvi Dave a68ff22aed custom fields: Improve date picker popover for date type fields. 2018-05-27 23:01:22 -07:00
Yashashvi Dave b5cf73ae0c custom fields: Add UI for user type of custom fields. 2018-05-27 23:01:22 -07:00
Yashashvi Dave e82c879b85 custom fields: Add user type of custom fields.
Fixes #8878
2018-05-27 23:01:21 -07:00
Yashashvi Dave ba72780678 js/settings_account.js: Add generic func to update custom profile fields. 2018-05-27 22:57:05 -07:00
Harshit Bansal 6ee32ee512 minor: Add a comment explaining the need of `stopPropagation()`. 2018-05-23 14:07:30 -07:00
Yashashvi Dave ffe986886f custom fields: Fix field value not saved on change, just after created.
Whenever custom fields templates get rendered within user account
settings, on-change event listener wasn't get created. Cause
event listener wasn't set properly.
2018-05-15 12:08:29 -07:00
Yago González 6837fc5d56 i18n: Add missing strings for custom profile fields and fix capitalization.
The "Short/Long Text" option for custom profile fields wasn't properly
capitalized (i.e. "Text" should have been all lowercase), and also
wasn't properly tagged for translation.

For the sake of consistency, the change to proper capitalization has
also been applied to the models and any tests involving this feature.

Due to a bug in Django, it complained about the models having changed
and thus not being consistent with the migrations. That isn't actually
true (since the database stores the numeric values for each key), but
the migrations have been modified to avoid this error. This does not
affect the migrations' behaviour in any way.
2018-05-06 19:44:36 -07:00
Tim Abbott 7ab8a8e820 js: Fix a bunch of indentation issues found by eslint.
This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
2018-05-06 16:25:02 -07:00
Tim Abbott 384a8f2e9f custom fields: Clean up template logic for field ID.
This makes a few important cleanup changes:
* Using the more standard data-field-id name for the ID value.
* Using $(e.target).closest() rather than `.parent`, which is more
  robust to future changes in markup.
2018-05-05 15:40:16 -07:00
Yashashvi Dave 06e63af4b4 custom fields: Add UI for choice type custom fields. 2018-05-05 11:59:08 -07:00
Yashashvi Dave 512ab5dbaf js/settings_account.js: Remove hard-coded field no, clean template context. 2018-05-05 11:59:08 -07:00
Yashashvi Dave 0d7d94d0db custom fields: Add support for custom URL field type. 2018-04-30 10:53:23 -07:00
Yashashvi Dave d2128105dd custom fields: Fix bug in real time sync for user settings.
Currently when admin add/remove/update custom fields, changes
are not reflected in user settings page, if settings tab
is already open. This might be rare case, but it looks like
an error when admin go to user settings page just after
updating custom fields in org settings.

Fix this by re-rendering custom fields in user settings
on custom_profile_fields event.
2018-04-30 23:04:25 +05:30
Yashashvi Dave 4033f210af custom fields: Add support for custom date field type. 2018-04-30 23:04:25 +05:30
Yashashvi Dave 5e63e6061b custom fields: Add UI for custom field hint.
Fixes #8876
2018-04-30 10:14:50 -07:00
Umair Khan cf2f6b38dd profile: Add choice field.
Fixes part of #8878
2018-04-26 00:35:51 -07:00
YJDave aeef925b93 custom fields: Fix error in rendering long textual custom fields.
Currently, long textual fields are rendered as short textual fields
in UI, this bug was introduced because of our recent changes in
custom fields type.
2018-04-04 10:46:18 -07:00
YJDave 8bc181882a custom fields: Remove unused code for custom fields.
It removes code related to custom profile field's placeholder styling
and related to numeric custom fields, as recently we removed support
for numeric custom fields.
2018-04-04 10:46:18 -07:00
Tim Abbott b58cd46e48 profile: Fix field types on the frontend. 2018-04-02 10:25:37 -07:00
YJDave 82c8d43209 custom profile data: Enable user to edit custom field's value in settings.
This will enable user to edit the value of custom fields from
user settings.
2018-03-21 16:08:12 -07:00
YJDave b404d0e156 custom profile data: Set custom field's values in user setting page on load.
Set realm custom field's values for current user in user setting page
when page gets load.
2018-03-21 16:08:12 -07:00
YJDave 3b8c2e45be user settings: Fix user avatar not updated in settings page.
On uploading new avatar, user avatar in settings page doesn't
get updated. Cause we have set `src` attribute of wrong html
element instead of image element in user settings page.

Fixes #8680.
2018-03-13 10:57:36 -07:00
Rhea Parekh 416f11030f user settings: Display avatar source.
This makes it easier for users to tell how Zulip ended up with an
avatar for them without them uploading one: through the Gravatar
service used across many Wordpress blogs.

Fixes #8225.
2018-03-05 09:12:59 -08:00
Tim Abbott 92ba40b0c7 settings: Use .attr() properly for disabling name/email change.
It turns out the consistent `.prop()` approach I switched to a few
commits back didn't actually work.  Instead, we establish consistency
by always using `.attr`, which does.

Usually, I'd go back and fix the older commits, but in this case it
feels not worth it.
2018-03-02 12:49:46 -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
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 2f99e6b7b2 settings: Add loading indicator for account deactivation.
Fixes #8175.
2018-02-23 08:20:45 -08:00
YJDave 32ede6a355 settings: Restrict opening full name and email change overlay modal.
Set condition before opening full name and email change overlay modal,
to check whether changing full name or email is allowed in realm.
2018-02-02 17:50:37 -08:00
Tim Abbott ef42bb2e73 settings: Fix real-time sync for account settings.
This restores the property that changing one's name in on browser's
"account settings" also changes the user's name in other browser windows'
"account settings" pages.
2018-02-01 16:38:26 -08:00
YJDave 7e8da54209 settings: Move full name setting UI into modal.
This makes this UI widget more consistent with its neighbors.

tabbott: This introduces a bug with how the `full_name_field` HTML is
managed; it should be done via the `server_events.js` handler.
2018-02-01 16:08:07 -08:00
YJDave 8582e757cd settings: Improve email change modal in user setting.
- On error, do not close the modal and show the error in the modal.
- Change the order of the `Cancel` and `Change` buttons.
2018-02-01 16:08:07 -08:00
YJDave 21cbdfdb79 settings: Improve password change modal UI.
- When password fields are cleared, update password strength bar.
- On data dismiss, clear password fields.
- Exclude forgot-password div from focus.
- On enter key, modal should be submitted not dismissed.
- Change password btn text from "Change password" to "*****"
2018-02-01 16:08:07 -08:00
YJDave 2ca0fb4128 user setting: Move password change flow in UI into modal.
Thanks to @brokwhittaker for his significant chagnes in
password modal design.
2018-01-23 14:40:47 -05:00
Brock Whittaker ffe3a6c127 settings: Remove password confirmation in modal.
This removes the requirement to confirm your new password.
It isn't necessary and can be fixed easily with an email
reset if messed up.
2018-01-23 14:38:59 -05:00
Steve Howell 567da076ad i18n: Translate strings in settings_account.js. 2017-11-07 09:52:20 -08:00
Vishnu Ks 94cb5b854f frontend: Show info on /emails only in dev env. 2017-10-04 14:45:08 -07:00
Vishnu Ks 80fc9cda3a settings: Mention about /emails after sending change email mail. 2017-10-04 08:20:29 -07:00
Cynthia Lin f697e6bb0e modals: Implement new modal methods. 2017-09-06 09:35:16 -07:00
Brock Whittaker 41f395caf1 your-account: Change "no changes made" error to success.
This changes the alert error "Error changing settings: No new data
supplied" to "No changes made" as a success bar.
2017-08-09 19:46:43 -07:00
Tim Abbott 1e5aee054b settings: Migrate main settings-change code to API.
This was one of the few major remaining endpoints that were still on
the old-style legacy API.
2017-07-31 13:08:06 -07:00
Vishnu Ks 9067890120 urls: Use POST for zerver.views.user_settings.set_avatar_backend.
The set_avatar_backend is changed from PUT to POST becuase this
is not idempotent.
2017-07-07 10:31:43 -07:00
Brock Whittaker 1b616d761e settings: Fix email input whitespace issue.
This fixes the issue where the email has whitespace potentially in the
input due to the HTML formatting.
2017-07-05 17:45:30 -07:00
Harshit Bansal 6615f2f2e8 common.js: Migrate `common.js` module to use IIFE module style.
This module was exposing its functions as globals. This PR fixes
it use the IIFE module style that we use in our other modules.
2017-06-22 19:06:32 -04:00
vaibhav d9bc3932ec settings: Move "download personal API key" from "your-bots" to "your account"
Fixes: #5355.
2017-06-20 15:46:23 -04:00
Tim Abbott 72720fcf2e settings: Remove obsolete message_viewport.scrollTop() calls.
These date from long before the settings UI was restructured as an
overlay.  Now, instead of ensuring that error messages are visible,
they just scroll the message feed incorrectly.

Fixes #4810.
2017-05-16 20:33:52 -07:00
fionabunny b7c6d46bf9 home.py: move password_auth_enabled as realm_password_auth_enabled.
Part of #3853.
2017-04-28 21:23:48 -07:00
fionabunny 635a05fe80 home.py: move name_changes_disabled as realm_name_changes_disabled.
This appears to have been partially completed prior.  Part of #3853.
2017-04-28 21:12:23 -07:00
Steve Howell 47bdecdc4f Extract settings_account.js.
This code handles the settings pane for "Your account," which
has email/name/password/avatar/etc.
2017-04-06 11:28:36 -07:00