Commit Graph

289 Commits

Author SHA1 Message Date
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
Mateusz Mandera d70e1bcdb7 settings: Add FAKE_EMAIL_DOMAIN setting.
Fixes #9401.

This adds a FAKE_EMAIL_DOMAIN setting, which should be used if
EXTERNAL_HOST is not a valid domain, and something else is needed to
form bot and dummy user emails (if email visibility is turned off).
It defaults to EXTERNAL_HOST.

get_fake_email_domain() should be used to get this value. It validates
that it's correctly set - that it can be used to form valid emails.

If it's not set correctly, an exception is raised. This is the right
approach, because it's undesirable to have the server seemingly
peacefully operating with that setting misconfigured, as that could
mask some hidden sneaky bugs due to UserProfiles with invalid emails,
which would blow up the moment some code that does validate the emails
is called.
2019-08-30 14:59:00 -07:00
Mateusz Mandera 16479fa606 populate_db: Extract internal realm creation into a function. 2019-08-23 12:57:24 -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
Mateusz Mandera d3d62f99e4 tests: Adjust to new changes in populate_db. 2019-07-31 16:01:37 -07:00
Wyatt Hoodes 9b69c1f7fe Merge pull request #12833 from whoodes/clean-up-new-user-bot
bots: Replace remnants of new-user-bot with default-bot@zulip.com.
2019-07-20 14:38:05 -07:00
Yashashvi Dave 27ead227c0 custom fields: Add separate alert-save widget for create field.
Add separate alert-notification widget for create-custom-field
in admin view.

Fixes part of #12748
2019-07-11 12:52:21 -07:00
Puneeth Chaganti 7da6d5a168 narrow: Fix broken narrows for invalid email IDs.
When pm-with or group-pm-with searches had invalid email IDs, the code
to set the narrow title would break. This commit handles that
correctly.
2019-06-28 17:06:20 -07:00
Puneeth Chaganti 91b2ac27ae narrow: Extract test for non existing user narrow. 2019-06-28 16:56:58 -07:00
Puneeth Chaganti 0409db3c9d narrow: Improve window titles of is:<type> narrows.
We capitalize the type name, and add a " messages" suffix.
2019-06-26 16:06:22 -07:00
SatyendraBanjare 066c168448 narrow: Window title shows user's name, in private message narrows.
Modified heavily by punchagan to correctly handle narrowing to huddles, and
for `group-pm-with` narrows. Also, fixed broken tests in the original PR.

Closes #5876
2019-06-26 16:06:22 -07:00
Yashashvi Dave 8e269b4651 models: Rename notification to `enable_stream_audible_notifications`.
Rename notification property `enable_stream_sounds` to
`enable_stream_audible_notifications` to match with other
notification property patterns.

Fixes part of #12304
2019-06-12 16:24:51 -07:00
Thomas Ip b72f30bd06 jQuery: Replace positional selectors at the end of multiple selectors.
A selector like `$('.elem1 .elem2:first')` selects the first descendant
with class name `.elem2` under `.elem1`. This is the same as saying
`$('.elem1 .elem2').first()`. See example here:
https://jsbin.com/bohehesari/edit?html,js,output
2019-06-06 15:21:26 -07:00
David Wood 6b9a9b1e31 org settings: Extract setting for new user waiting period.
This commit separates the `waiting_period_threshold` setting from
the `create_stream_policy` setting, adding a new setting that the user
can use to select a waiting period threshold.

Both the invite to stream policy and create stream policy now have
three options: admins only, members and admins, or members after
waiting period/admins.
2019-05-21 17:36:48 -07:00
Pragati Agrawal 4df971c3c2 org settings: Add save/discard widget for realm authentication methods.
Along with this, we refactored settings_org.populate_auth_methods to use
HTML function after rendering all auth methods rows rather than appending
each row individually, which actually is a good practice.

Also in this commit, to compare `current_val` and `changed_val` in
`check_property_changed` function of the property
`realm_authentication_methods`, which are objects, and we found here
https://stackoverflow.com/a/1144249 that there is no easy way to do so. So
I followed this approach,

```js
 JSON.stringify(obj1) === JSON.stringify(obj2)
```

but before converting them to string we want the same order of keys, so we
used `sort_object_by_key` to sort `current_val` by keys and
`get_auth_method_table_data` always return `changed_val` having keys
sorted.

Since these refactor were closely related we kept them as a single commit
here.

Fixes: #11954.
2019-05-20 15:42:15 -07:00
Vaibhav d3b201337e copy_and_paste: Bind default copy handler to hotkeys.
This removes the 'copy' event listener and binds the copy handler
to `Ctrl+C` or `Cmd+C` (OSX) keys;
2019-05-13 17:58:12 -07:00
David Wood f53a8f8bb6 settings: Rename `create_stream_permission` in templates.
This commit renames the `create_stream_permission` field in the
templates to `create_stream_policy`, matching the field used in the
database model. This matches what `invite_to_stream_policy` does and
will be clearer when the `waiting_period_threshold` is split into its
own field.
2019-05-06 16:30:01 -07:00
David Wood 272ed90685 settings: Create an explicit invite_to_stream_policy setting.
This commit creates a new organization setting that determines whether
a user can invite other users to streams. Previously this was linked
to the waiting period threshold, but this was both not documented and
overly limiting.

With significant tweaks by tabbott to change the database model to not
involve two threshhold fields, edit the tests, etc.

This requires follow-up work to make the create stream policy setting
work how this code implies it should.

Fixes #12042.
2019-04-29 17:11:28 -07:00
Shubham Dhama 7ab0c26bda settings_users: Refactor some code for deactivate button. 2019-03-20 22:34:57 -07:00
Steve Howell 9986e41999 top left: Simplify markup for main links.
The following elements in the top left corner
are major components of our app:

    All messages
    Private messages
    Starred messages
    Mentions

We can now find them directly:

    $('.top_left_all_messages')
    $('.top_left_private_messages')
    $('.top_left_starred_messages')
    $('.top_left_mentions')

Before this, we had to build up complicated selectors
like below:

    exports.get_global_filter_li = function (filter_name) {
        var selector = "#global_filters li[data-name='"
            + filter_name + "']";
        return $(selector);
    };

I don't think any newbie would know to grep for "global_filter",
and I've seen a PR where somebody added specific markup here
to "Private messages" because they couldn't grok the old scheme.

Another thing to note is that we still have a "home-link"
class for "All messages", which overlapped with portico
code that had the same name.  (There were some inaccurate
comments in the code relating to the tab bar, but we don't
actually have a way to click to the home view in the tab
bar any more.)  I'll eliminate that cruft in another commit.

For this commit the four elements still have the
"global-filter" class, since there's some benefit to being
able to style them all as a group, although we should give
it a nicer name in a subsequent commit.

Most of this PR is basic search/replace, but I did add a
two-line helper: `top_left_corner.update_starred_count`
2019-01-30 13:53:20 -08:00
Mohit Gupta 42d886a6d5 messages: Add loading spinner for deleting messages.
User was able to click delete button multiple time which could cause
multiple delete requests. This commit disables and hides the delete
message button after the first click and shows a spinner until http
the delete request responds.

Also adds a casperjs test to ensure that spinner becomes visible and
delete button becomes invisible after clicking on delete button for
first time and hides spinner and show delete buttton when message is
deleted.

Fixes: #11219.
2019-01-25 11:07:02 -08:00
Tim Abbott bdb3da4504 eslint: Add key-spacing linter rule.
Apparently, we didn't have one of these, and thus had a moderate
number of generally very old violations in the codebase.  Fix this and
clear the ones that exist..
2018-12-18 10:41:06 -08:00
Tim Abbott d84d3777fd casper: Fix admin tests failing.
This was broken with the recent realm filters commits.
2018-12-17 13:43:13 -08:00
Tim Abbott 354109e5e9 casper: Fix test broken by recent signup refactor. 2018-12-10 16:55:07 -08:00
Steve Howell d7c2577ffb subject -> topic: Rename compose fields.
The stream/topic edit areas now have these ids:

        #stream_message_recipient_stream
        #stream_message_recipient_topic

They are pretty verbose, but being able to grep
for these without noise does have some value.
2018-12-09 21:28:45 -08:00
Marco Burstein ba46dc83c6 notifications: Add a setting for changing the notification sound.
Also, add a new notification sound, "ding". It comes from
https://freesound.org, where the original Zulip notification sound comes
from as well. In the future, new sounds can be added by adding audio
files to the `static/audio/notification_sounds` directory.

Tweaked significantly by tabbott:
* Avoided removing static/audio/zulip.ogg, because that file is
  checked for by old versions of the desktop app.
* Added a views check for the sound being valid + tests.
* Added additional tests.
* Restructured the test_events test to be cleaner.
* Removed check_bool_or_string.
* Increased max length of notification_sound.
* Provide available_notification_sounds in events data set if global
  notifications settings are requested.

Fixes #8051.
2018-12-09 21:25:30 -08:00
Tim Abbott b2939cdf19 lint: Fix comma spacing in node tests.
I apparently failed to check the tests codebase before merging the
last linter commit.  Oops.
2018-12-07 13:14:28 -08:00
Steve Howell 78e20c82a8 settings: Handle back button within settings/orgs panels.
The Casper code that I eliminated here seems to be
bogus, in that I don't think it really waited for
all the clicks.

I **think** the intent of the test was to verify that
when you leave settings and go back into it, it remembers
the panel.  I was able to verify this manually.
2018-12-07 11:45:25 -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
Steve Howell b79d63e9c3 copy/paste: Try to fix Casper flake and add comments.
I think this will fix a Casper flake where there was a race
window with multiple temp DOM elements holding copied text.

I also add a comment to the code I think causes this race
for the tests.
2018-11-27 21:42:16 -08:00
Steve Howell 3aa490edbe Add current user back to the buddy list.
For many years we have been excluding the current user
from the buddy list, since their presence is kind
of implicit, and it saves a line of real estate.

This commit removes various user-is-me checks
and puts the user back for the following reasons:

    * explicit is better
    * newbies will be less confused when they
      can see they're actually online
    * even long-time users like myself will
      feel more comfortable if it's just there
    * having yourself in the buddy list facilitates
      things like checking your presence or sending
      yourself a message
    * showing "me" reinforces the meaning of the
      green circle (if my circle is green and I'm
      active, then others with green circles must
      be active too)
    * If you're literally the first user in the
      realm, you can now see what the buddy list
      looks like and try out the chevron menu.

The biggest tradeoff here is the opportunity cost.
For an org with more people than fit on the screen,
we put the Nth person below the fold to show "me".
I think that's fine--users can still scroll or
search.

This commit doesn't do anything special with the
current user in terms of sorting them higher in the
list or giving specific styling.

Fixes #10476
2018-11-27 14:52:19 -08:00
Steve Howell e978158519 casper test: Add helpers for buddy list checks. 2018-11-27 14:52:19 -08:00
Tim Abbott 27f0a30768 casper: Remove overly-specific test for whether body is well-formed.
This test started failing recently; the apparent cause is that
sometimes, zerver/lib/generate_test_data.py generates messages
containing bulleted lists, and those don't end with a `</p>` tag since
they end with `</ul>` instead; the result is that this test failed
nondeterministically in CI.

There isn't really a useful version of this check to do that would
cover that case (as well as the entire message body being a bulleted
list), so we just remove the check; I don't think it's ever caught any
actual bugs.
2018-10-31 10:46:26 -07:00
Vishnu Ks 62b93d551a signup: Fix broken resend email link in realm creation flow.
Also use name for selecting form in casper tests
as form with action=new is present in both /new
and /accounts/new/send_confirm/ which breaks
test in CircleCI as
waitWhileVisible('form[action^="/new/"]) never stops
waiting.
2018-08-26 22:54:05 -07:00
Vishnu Ks d2e4417a72 urls: Separate endpoint for signup and new realm email confirm.
This is preparation for the next commit.
2018-08-26 22:53:57 -07:00
Marco Burstein 6f14f4f047 compose: Update the `New topic` button to `New stream message` in PMs.
If a user is narrowed by `is:private`, `pm-with`, or `group-pm-with`,
change the `New topic` button to say `New stream message` instead for
added clarity.

Also, add to the Casper and Node tests for this behavior.

Fix #9072.
2018-08-09 08:55:01 -07:00
Rohitt Vashishtha c41c82aae0 settings_emoji: Use display_name in handlebars.
This commit fixes two issues with the previous implementation:

1. JavaScript's replace replaces only the first instance,
   thus we need to use a regex.
2. Handlebars was setting the id of the HTML elements with
   spaces in between which broke the delete button; now a
   new variable display_name is passed to the template.

This also makes changes to the casper tests to have an emoji
name with multiple spaces in it to ensure this bug doesn't
appear again.
2018-08-07 10:22:08 -07:00
Shubham Padia 069a4f1626 search: Disable tab_bar due to addition of search pills.
tab_bar.js becomes redundant after implementation of search pills.
This commit adds a comment to tab_bar.initiliaze, so the event
listeners related to it do not get initiated. This does not remove
any code related to tab_bar.js.
Also adds left and right border around the search icon.
2018-07-23 11:29:10 -07:00
Aditya Bansal 66096e9509 single_message.handlebars: Upgrade to font-awesome 4.7 icon prefixes. 2018-07-11 20:31:17 +05:30
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04:00
Shubham Dhama f148ed5bbf org settings: Improve error handling status elements.
With styling work by @maxnuss.

Fixes: #9188.
2018-06-06 09:00:35 -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 5d9a8cf64f bots: Add token to outgoing webhook zuliprc.
We want the Botserver to not only work with the
botserverrc, but also with a zuliprc of an outgoing
webhook. Because the Botserver uses the outgoing
webhook token for authentication, we need to include
it in the zuliprc for outgoing webhooks.
2018-06-04 08:39:24 -07:00
Robert Hönig 647c63050f botserver: Add outgoing webhook tokens to botserverrc.
The tokens will be used to authorize the server when sending
messages to the Botserver.
2018-05-30 10:00:19 -04: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
Robert Hönig 04d68d2570 code: Rename flaskbotrc to botserverrc. 2018-05-29 10:19:17 +02:00
Robert Hönig 53891a9bed bots: Don't name section headers in flaskbotrc.
The Botserver uses section headers in the flaskbotrc to
determine which bot to run. Silently setting the section
headers to a bot's username is confusing and makes it
harder for Botserver users to figure out how to get the
Botserver to run the bots they want. This commit empties
all flaskbotrc section headers and thus makes the assignment
of bots explicit and mandatory.
2018-05-25 10:33:40 -07:00
Shubham Dhama a001424a4b org settings: Use do_settings_change for auth method checkboxes.
Fixes: #9224.
2018-05-22 14:03:20 -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 716a4a967d js: Fix indentation issues in casper tests.
Our casper tests now pass eslint cleanly.
2018-05-06 19:35:18 -07:00