Commit Graph

306 Commits

Author SHA1 Message Date
Steve Howell 338d2dc29a node tests: Localize overrides for compose test. 2021-05-19 15:55:03 -04:00
Tim Abbott 8e7761e15b compose: Move closed-compose functions to closed_compose_ui.js.
This improves the organization of our codebase a bit.
2021-05-11 23:57:57 -07:00
Tim Abbott 9239de408a compose: Remove now unused nonexistent_stream_reply_error.
This was a holdover from the legacy "reply" button behavior; with the
new wide button model, it just becomes a normal "compose" button.
2021-05-11 23:57:57 -07:00
sahil839 51e40dd668 settings: Add moderators option for wildcard_mention_policy in frontend. 2021-05-03 12:12:01 -07:00
sahil839 f5f6617476 streams: Add frontend code for moderators only stream post policy. 2021-05-01 08:21:50 -07:00
Aman Agrawal 2a1bcd4b59 giphy: Fix incorrectly working show/hide behaviour.
There were some changes that were lost/added by mistake
during a rebase of #17707 after #18154 was merged.

Fixes the GIF icon being hidden / displayed incorrectly
with respect to the settings.

These changes were originally part of
67527a2517 but
were lost during the rebase.
2021-04-29 09:02:25 -07:00
sahil839 0452d8e175 settings_data: Add 'user_can_subscribe_other_users' helper.
This commit adds 'user_can_subscribe_other_users' helper in
settings_data.js amd this helper will replaced all the
instances of page_params.can_subscribe_other_users.

We also remove the incorrect code in server_events_dispatch.js
where we were updating page_params.can_invite_to_stream which
is actually not used in other parts of code and instead of it
page_params.can_subscribe_other_users is used to check whether
user is allowed to subscribe others or not. This code was
added in 272ed9068.
Though this could have been done in a different commit, but as
we are adding the code to use the correct updated value in this
commit only, this has been fixed here.

There is also no need of adding that complex logic to update the
correct 'page_params.can_subscribe_other_users' field on
'realm_update' event, as we are using user_can_subscribe_other_users
helper and thus we always use the updated values to check whether
the user is allowed to subscribe others or not.
2021-04-28 15:37:00 -07:00
Aman Agrawal 4f3cae7d65 compose_control_buttons: Rename giphy_api_available to giphy_enabled. 2021-04-27 10:06:25 -07:00
Aman Agrawal 84a7f08acc compose: Use `class` to find `markdown_preview` related elements.
We convert the following elements to use a class instead of
id for accessing them across the codebase:

* markdown_preview
* undo_markdown_preview
* markdown_preview_spinner
* message_edit_content
* preview_content

Converted them together since changes to one impacted the other in
some modules like click_handlers.

Also, added a function in rows to get `message_row`.
2021-04-27 10:06:25 -07:00
Aman Agrawal 8ebced2791 compose: Use `compose_upload_file` class for upload file icon.
We use `.compose_upload_file` across compose and message_edit_form
for file upload icon. This will help us share common code between
`compose` and `message_edit_form`.
2021-04-27 10:06:25 -07:00
Aman Agrawal 7ae04a6ba8 compose: Use `file_input` class for file input element.
In both compose and `message_edit_form` we use `file_input`
class to identify the file `input` element. This will help
to more easily share common elements between compose and message_edit.
2021-04-27 10:06:25 -07:00
Tim Abbott a8106a641b compose: Fix broken test.
We seem to have accidentally merged a bit of logic from renaming
file_upload_enabled to allow_file_upload.
2021-04-19 17:34:08 -07:00
Aman Agrawal 70d444a8eb compose: Move to `hbs` file and append it to DOM on init.
We move compose.html to compose.hbs file while keeping
`#compose` still in `home.html` as a hanger
where append rest of the elements.

This will provide us with two benefits:
* We could share common elements between message_edit_form and
compose.
* We can insert compose directly in any element. We may decide to
do it for recent topics.
2021-04-19 16:53:30 -07:00
Anders Kaseorg 2004a85fb1 i18n: Automatically convert remaining JavaScript messages to FormatJS.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-13 17:41:10 -07:00
Anders Kaseorg a70061d91f compose: Convert show_preview messages to FormatJS.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-13 17:41:10 -07:00
Anders Kaseorg d761077dac compose: Convert compose_error messages to FormatJS.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-13 17:41:10 -07:00
Steve Howell 36fd76dc20 refactor: Extract can_view_subscribers().
We also remove some needless uses of the calculated
field in the node tests.
2021-04-05 09:52:19 -07:00
Steve Howell 58d5778368 node tests: Explicitly set page_params values. 2021-04-03 15:03:00 -04:00
Steve Howell e72f208fde refactor: Move insert_message to echo.
This change does not impact the overall complexity
of our dependency graph (at least in terms of the
number of edges that we would need to remove to get
a tree), but it does clarify the picture a bit.
2021-03-28 15:55:55 -07:00
Anders Kaseorg a05899f1b5 js: Convert static/js/csrf.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -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 3ef6f6e2e2 js: Convert static/js/blueslip.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-17 08:47:15 -04: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
Anders Kaseorg 876806eb4d zjsunit: Lift restriction against mocking third party modules.
Use fully resolvable request paths because we need to be able to refer
to third party modules, and to increase uniformity and explicitness.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:06:30 -08:00
Steve Howell 9c8fa3930f node tests: Eliminate many __Rewire__ calls.
For most functions that we were using __Rewire__ for,
it's better to just use the override helper, which
use __Rewire__ under the hood, but also resets
the reference at the end of run_tests.

Another nice thing about override() is that it reports
when you never actually needed the mock, and this
commit fixes the instances found here.

I didn't replace every call to __Rewire__. The
remaining ones fall under these categories:

    * I looked for ") =>" in my code sweep,
      so I missed stuff like "noop" helpers.

    * Sometimes we directly update something
      in a module that's not a function. This
      is generally evil, and we should use setters.

    * Some tests have setup() helpers or similar
      that complicated this code sweep, so I
      simply punted.

    * Somes modules rely on intra-test leaks. We
      should fix those, but I just punted for the
      main code sweep.
2021-03-07 11:19:33 -05:00
Steve Howell eea78df688 node tests: Clean up mock_module calls.
This is a deceptively ugly diff.  It makes
the actual code way more tidy.

I basically inlined some calls to mock_module
and put some statements in lexical order.
2021-03-07 09:35:58 -05:00
Steve Howell f54f7cfc33 node tests: Introduce mock_module helper. 2021-03-06 13:15:04 -05:00
Steve Howell 167fda142c node tests: Remove __esModule cruft.
We just set __esModule in our rewiremock helper.
2021-03-06 12:36:07 -05:00
Steve Howell 30c7108955 zjsunit: Remove rewiremock dependency.
We now just use a module._load hook to inject
stubs into our code.

For conversion purposes I temporarily maintain
the API of rewiremock, apart from the enable/disable
pieces, but I will make a better wrapper in an
upcoming commit.

We can detect when rewiremock is called after
zrequire now, and I fix all the violations in
this commit, mostly by using override.

We can also detect when a mock is needlessly
created, and I fix all the violations in this
commit.

The one minor nuisance that this commit introduces
is that you can only stub out modules in the Zulip
source tree, which is now static/js.  This should
not really be a problem--there are usually better
techniques to deal with third party depenencies.
In the prior commit I show a typical workaround,
which is to create a one-line wrapper in your
test code.  It's often the case that you can simply
use override(), as well.

In passing I kill off `reset_modules`, and I
eliminated the second argument to zrequire,
which dates back to pre-es6 days.
2021-03-06 11:10:57 -05:00
Steve Howell 5b2d48aedb node test: Extract compose_video tests. 2021-03-05 18:33:01 -05:00
Anders Kaseorg 8dbaf2d680 js: Convert static/js/subs.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 0e90f3be6d js: Convert static/js/compose_actions.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7ec3fc38fa js: Convert static/js/input_pill.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 1ec97070e8 node_tests: Move more set_global mocks before zrequire calls.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg dc95f06b62 js: Convert static/js/compose_ui.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 542a77f5d5 js: Convert static/js/reminder.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 19bb5fa7ad js: Convert static/js/server_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9d318f054f js: Convert static/js/notifications.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f59133db42 js: Convert static/js/ui_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 9f881ebe34 js: Convert static/js/resize.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 031fab7661 js: Convert static/js/stream_edit.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 6f660793e7 js: Convert static/js/upload.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5d3baec4ef js: Convert static/js/compose.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 35afd078f3 js: Convert static/js/transmit.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 1547494e25 js: Convert static/js/compose_state.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg f499c4a858 js: Convert static/js/sent_messages.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 32288d245c js: Convert static/js/local_message.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 10a4d2bcbd js: Convert static/js/markdown.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg ea01e6da5e js: Convert static/js/compose_fade.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00