Commit Graph

176 Commits

Author SHA1 Message Date
Steve Howell 7e17b8a392 subject -> topic: Use util.set_message_topic() to set subject. 2019-01-01 20:49:34 -08:00
Steve Howell ca22302763 minor: Avoid ui_util.focus_on() call.
The helper is unnecessary at this point and obscures
greps for selectors.  We completely eliminate it in
the next commit.
2018-12-22 08:07:23 -08:00
onkar shedge ba7e78bc65 message_edit: Allow editing topics indefinitely.
Previously, Topic editing was offered in the UI even to message
senders and organizations admins only if the message was no more than
one day old.  This was correct for the "community topic editing" case,
but not for message senders and organization admins.

While we're at it, this also centralizes some previously haphazard
logic to always call message_edit.is_topic_editable().

Tweaked significantly by tabbott to fix the logic.

Closes #10568.
2018-12-04 17:41:21 -08:00
Shubham Dhama e908da7831 narrow: Remove some `narrow_deactivated.zulip` event handling. 2018-11-29 12:36:00 -08:00
Shayan Toqraee a4b14b8526 compose.js: Move set rtl logic to keyup event.
This fixes an issue where the ltr/rtl translation lagged one character
behind as a user typed.
2018-08-14 11:41:53 -07:00
Yashashvi Dave bbe326dd29 message edit: Add markdown shortcuts to message edit UI.
This makes the ctrl+B, ctrl+I, ctrl+shift+L shortcuts available when
doing message editing.

Fixes #9917.
2018-07-23 10:41:46 -07:00
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
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04: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
Shubham Dhama da8157d414 message: Extract function for editability of topic. 2018-04-28 13:00:29 -07:00
YJDave 6bef44a9fa org setting: Add time limits for message deleting.
Add realm setting to set time limit for message deleitng.
Set default value of message_content_delete_limit_seconds
to 600 seconds(10 min).

Thanks to Shubham Dhama for rebasing and reworking this.  Some final
edits also done by Tim Abbott.

Fixes #7344.
2018-04-27 19:22:28 -07:00
Tim Abbott 2d5d6a1fd1 message_edit: Fix buggy error string for message deletion.
The previous model resulted in an ugyl `.:` sequence.
2018-04-27 19:12:18 -07:00
Priyank f5acbcb4c8 clipboard: Update clipboard to v2.0.0 to avoid variable name conflict.
It turns out, now we have a new standard way to access clipboard by
`Clipboard` method and currently this conflict with the constructor
exported by clipboard package. The new update v2.0.0 was released to address
this issue. The new version just exports the constructor as `ClipboardJS`.

Ref: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
Ref: https://github.com/zenorocha/clipboard.js/issues/468
2018-04-05 15:09:00 -07:00
Aastha Gupta f900f955c0 message edit: show spinner on topic change.
On clicking the checkbox in topic edit form, display a spinner and
hide the cancel icon.  Also, do not display any success message.

Fixes #8793.
2018-03-23 07:21:22 -07:00
Sarah 91197fa4f1 org settings: Add logic for applying allow_community_topic_editing.
Applies the logic to allow community members to edit topics
of others' messages if this setting is True. Otherwise,
only administrators can update the topic of others' messages.

This logic includes a 24-hour time limit for community topic editing.
2018-03-22 16:13:36 -07: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
Shubham Dhama 3fb862533f upload: Fix upload under message edit mode when edited using hotkeys.
This refactors the attachment of jQuery-filedrop handler into
`message_edit.start_edit_with_content`.
2018-03-05 10:42:38 -08:00
Tommy Ip 5ee6c608c0 message edit: Allow uploading files.
Fixes: #198.
2018-03-05 10:42:38 -08:00
Weronika Grzybowska 7ac7100a1d messages: Make checking for status message consistent with backend.
Adds a check for newline that was present on backend, but missing in the
frontend markdown implementation. Updating messages uses is_me_message flag
received from server instead of its own partial test. Similarly, rendering
previews uses markdown code.

Fixes #6493.
2018-01-23 09:26:41 -05:00
Tim Abbott 9ae506ac0e compose: Enable mention syntax when editing messages.
We had been waiting on doing this for a long time to make sure the
feature actually did what it was supposed to (completed last week);
this change adds the typeahead to ensure it actually works.

While we're fixing this, we remove the split between the edit and
compose code paths for typeahead, which is good, because we'd already
accidentally added the syntax-highlighting feature in only one place.

Fixes #195.
2017-10-12 18:08:32 -07:00
Tim Abbott 82b708b721 eslint: Add and enforce space-in-parens lint rule. 2017-10-06 12:36:59 -07:00
Tim Abbott a1885c6ffb message_edit: Add debug logging for missing messages.
This is an attempt to more easily debug a traceback we've seen a few
times.  The issue likely has to do with local echo, which would be
confirmed if this reports a local-echo-style message ID.
2017-08-27 16:11:42 -07:00
Brock Whittaker aa645eb72b eslint: Remove `no-new` rule.
This removes the `no-new` rule which is relatively detrimental to
code cleanliness in our codebase because third-party libraries may
utilize data structures that don't fly well with our linting rules.

This also fixes abstractions that were created due to the limitations
and impositions of this lint rule.
2017-07-27 11:31:33 -07:00
Steve Howell 0e25055c1d Add explicit message field for locally_echoed.
We now set locally_echoed to true for messages that are
locally echoed, and we change some of our code to look
for this flag.
2017-07-21 11:38:25 -07:00
Steve Howell fca158e387 local echo: Remove pencil icon on failed messages.
Our code to edit messages that were echoed locally but failed
by the server was broken.  We just disable it for now.

We have opened #5841 to try to restore this functionality.
2017-07-21 11:38:25 -07:00
Steve Howell 7134bbfbe3 message edit: Prevent editing any failed messages.
Our logic for editing failed messages is broken in various ways,
so we are removing the codepath for editing for now.  We will
try to restore these features as part of #5841.
2017-07-21 11:38:25 -07:00
Steve Howell 8de28ec66d hotkeys: Fix glitch related to closing message edits.
If you use the escape key to close a message edit, we need
to blur out the text fields.  Otherwise, hotkeys.js thinks
we are still editing the text.  This bug would disable the
use of things like arrow keys until the user subsequently
focused another field.

We probably eventually want hotkeys.js to be smarter about
ignoring hidden fields that still have the focus, but there's
also no reason not to blur the fields here, and this is a more
local, less risky fix.
2017-07-19 10:10:35 -07:00
Akhil 6adf241d7e message_edit: Avoid always fetching raw content.
Altered message_edit.start to check for message.raw_content before
retrieving the same from the backend.

With tweaks by tabbott to update, rather than delete, on repeated
edits.

Fixes: #4404.
2017-06-06 22:41:27 -07:00
Jack Zhang 84e5fe733c message-editing: Show date lines between edits from different days.
Added show_date_row field to each item of content_edit_history.
We use date lines to separate events that happened on different days.

Fixes #4638.
2017-06-06 11:04:30 -07:00
Jack Zhang 0534a4c42d message-editing: Optimize timestamp format to display only hours & minutes 2017-06-06 11:03:37 -07:00
K.Kanakhin 2434f2d96c messages: Add support for admins deleting messages.
This makes it possible for Zulip administrators to delete messages.
This is primarily intended for use in deleting early test messages,
but it can solve other problems as well.

Later we'll want to play with the permissions model for this, but for
now, the goal is just to integrate the feature.

Note that it saves the deleted messages for some time using the same
approach as Zulip's message retention policy feature.

Fixes #135.
2017-05-29 21:59:38 -07:00
Steve Howell d415d4cf11 Add error handling in watch_manual_resize().
We now explicitly complain if a caller passes in a bad
selector to this function and return undefined.
2017-05-11 15:45:47 -07:00
Cory Lynch 3d0cf35f49 message_edit.js: Fix bug with ctrl+enter hotkey not working.
This was a regression introduced in ba7b7a9. The ID of the
edit boxes were changed in that commit, but this event
listener was not updated to reflect that.
2017-05-04 19:46:10 -07:00
Tim Abbott f4262e0169 message_edit: Fix exception closing "view source".
This fixes a regression introduced in
81a575e4d5.
2017-05-01 15:08:01 -07:00
Cory Lynch ba7b7a9a36 Change edit_message_content to have unique IDs for different messages.
Fixes bugs of when multiple messages are being edited simultaneously.
Specifically, typeahead is no longer broken, copying messages to clipboard
is less buggy, and resizing is no longer
broken when multiple messages are being edited.
2017-04-28 12:15:34 -07:00
Cory Lynch 81a575e4d5 Add cleanup for resize listeners on message editing.
I changed the watch_manual_resize function to return the listener
functions it creates, and then these are used to remove the event
listeners before the edit box is hidden.
2017-04-28 12:15:34 -07:00
Cory Lynch f9d1bff167 Fix textarea resize for editing messages.
Reusing code from the main compose_message component so that resizing now
behaves correctly. This means that when the user tries to resize vertically,
the autoresize code is disabled, and the textbox reverts to manual resizing.
Fixes #4573
2017-04-28 12:15:34 -07:00
Raghav Jajodia 2bb632824e message_edit: Modify css for hover over 'Copy' button.
Replace background-image of copy button with an image
and change color on hover.
2017-04-14 14:01:57 -07:00
Raghav Jajodia fd5ad3658d message_edit: Only show "Copy" button for View Source/Topic-edit-only.
The "Copy" button will only be shown for "View Source"
or "Topic editing only". Also replaced "Copy to clipboard"
with "Copy and close" to make autoclose less surprising.

Fixes #4238.
2017-04-14 14:01:57 -07:00
Steve Howell 6314f60edc Keep compose open if left arrow does not cause message edit.
If somebody hits the left arrow to edit a message, but there are
no messages available to edit, then leave them in the compose box.
2017-03-27 10:15:05 -07:00
Steve Howell 293c89ba94 message edit: Only enable left-arrow-editing for content.
We no longer let the left arrow put you into the message edit
UI for a message where you can only edit topics, since that is
just confusing to most users.

This change also improves error handling a bit, and it removes
an unnecessary call to rows.id().

Finally, it moves some logic out of message_list.js, so that we
don't have a circular dependency for this codepath.

Fixes #4259
2017-03-27 10:02:19 -07:00
Raghav Jajodia 9707c74f33 message_edit: Added copy to clipboard button.
A copy-to-clipboard button is added over message-edit textarea.
Closes #3239.
2017-03-22 11:00:18 -07:00
Steve Howell d026344b37 Extract js/ui_util.js. 2017-03-19 11:05:45 -07:00
Steve Howell b98cd55ddb Add ui_report shim. 2017-03-19 11:05:44 -07:00
Philip Skomorokhov 8c52a94692 edit: Remove More/Collapse when in message edit/view source mode.
This entails displaying it when the editing mode ends.

Fixes #3871.
2017-03-16 11:30:49 -07:00
Philip Skomorokhov e3fa42f833 edit: Hide emoji reactions when in message edit or view source mode.
This also entails displaying them when the editing mode ends.

Fixes #3870.
2017-03-14 14:55:16 -07:00
Tim Abbott 5e39ccd642 js: Rename viewport.js to message_viewport.js.
This fixes the mobile web experience for Chrome on iOS.

Apparently, Chrome-on-iOS silently has a `viewport` module that
overrides and user-defined module by that name, causing all of our
code that accesses the viewport module to not work on that platform.
We fix this by renaming it.
2017-03-10 14:59:59 -08:00
Tim Abbott 7fb406b889 lint: Expand lint check for use of .text() without i18n.
Fixes #3705.
2017-02-28 20:37:52 -08:00
Philip Skomorokhov 7a75ed9c4a message_edit: Fix timer text not decrementing.
This fixes a regression introduced in e6369fc, where we simply lost the `--` part.

Fixes #3720.
2017-02-20 21:41:07 -08:00
Kartik Maji 1a697b6e02 Add frontend to show message edit history.
Fixes #268.

Modified significantly by tabbott to:
* improve code cleanliness / repetition
* add missing translation tags
* move code into message_edit.js
* correspond with the new backend.
* not display the option for messages only topic-edited
2017-02-19 17:41:06 -08:00
Igor Tokarev 55cffa1e69 Added keyboard shortcut to edit the last message.
Tweaked significantly by tabbott to update Casper tests, document the
new feature, and fix hotkeys.

Fixes #1147.
2017-02-12 00:29:28 -08:00
Tim Abbott 998dff9e50 lint: Add dangling commas in JavaScript objects. 2017-01-11 15:23:42 -08:00
Rishi Gupta 83392bf974 message edit: Change the empty topic placeholder to be the original topic.
If a user removes the topic in the message edit form, we use the original
topic, not the empty topic.
2017-01-04 22:51:36 -08:00
Rishi Gupta 386e22c564 Add node tests for message_edit.get_editability. 2016-12-30 16:51:00 -08:00
Arpith Siromoney 5639f21188 Add missing exports to js modules 2016-12-29 06:01:33 -08:00
Juanvulcano 2fd1316d70 Removed json/update_message
Update test_alert_words.py

Update test_messages.py

Update messages.py
2016-12-24 10:08:22 -08:00
Rafid Aslam bfe84a10f0 API: Migrate POST `json/fetch_raw_message` to GET `json/messages/<id>` 2016-12-21 13:08:40 -08:00
Shubham Singh bade6f496b Fix autocompleting stream names inside message editing.
Fixes #2577.
2016-12-21 11:09:42 -08:00
Rafid Aslam 45f39be37f lint: Fix many no-unused-vars eslint rule violations.
These have been carefully audited by tabbott to ensure they are
unlikely to cause regressions.
2016-12-14 21:34:51 -08:00
lonerz dc6849952b eslint: change space-before-function-paren from warning to error.
Also fix violations.
2016-12-05 09:50:37 -08:00
AZtheAsian 5e9918135b eslint: change quote-props from off to error and fix violations. 2016-12-02 18:35:53 -08:00
AZtheAsian ed0bc831be eslint: change one-var from warning to error and fix violations 2016-12-02 11:25:16 -07:00
kevv87 e6369fc29b eslint: change no-plusplus from warning to 2 and fix violations. 2016-12-01 14:27:17 -08:00
Rishi Gupta eeca06ea08 message_edit: Fix message editing for messages that threw a backend error.
Changes editibility type from NONE to FULL, and makes Save and Cancel
buttons work. Exposes a new bug, which is that changing the topic changes
the topic for the recipient row, rather than the message. See #2278.
2016-11-10 16:45:18 -08:00
Rishi Gupta a2b6793174 message_edit.js: Put cursor at end of input on initial focus. 2016-11-02 20:54:54 -07:00
Rishi Gupta 5251460eda message_edit.js: Remove edit_row from edit_message.
I believe row.find(..) and edit_row.find(..) are the same in all these
cases.
2016-11-02 20:54:54 -07:00
Rishi Gupta 8104485c41 message_edit.js: Refactor how edit_message accesses elements.
Currently, message_edit.edit_message accesses elements of
message_edit_form.handlebars by a number of different means, and in a number
of different places. This commit is the first of two that standardizes it.
2016-11-02 20:54:54 -07:00
Rishi Gupta 9ed45eb4a1 message_edit.js: Change disabled fields to readonly to allow copying text.
Previously we disabled fields in message_edit_form.handlebars that you
couldn't edit. This meant you could see the content of the field, but not
copy it. This commit marks those fields as readonly instead.
2016-11-02 17:49:04 -07:00
deekshaarul 6624d4e56e message_edit.js: Fix message editing behavior around empty topics.
Previously,
* We displayed "(no topic)" in .message_edit_topic when there was no
  topic;this commit changes that to a placeholder.

* We showed the .message_edit_topic_propagate dropdown when the user
  cleared .message_edit_topic, despite the fact that one cannot save
  or propagate an empty topic. This commit fixes the behavior.

Fixes #1273.
2016-11-02 17:45:23 -07:00
Tim Abbott 7ebfa25f5a message_edit: Make .save() automatically call .end() if no changes.
Previously, all of the callers of message_edit.save() would check if
it returned true, and if so, call message_edit.end().  This resulted
in various bugs in the past, so we switch to the much cleaner model of
just calling .end() inside .save().
2016-10-25 16:34:57 -07:00
Tim Abbott 05a2e57b14 message_edit: Make enter save when editing topics.
Fixes #1272.
2016-10-25 16:34:57 -07:00
Tim Abbott ff575aed99 message_edit: Fix error handling if user has re-narrowed. 2016-10-25 16:34:57 -07:00
Tim Abbott 985b4072c0 message_edit: Show a success message briefly. 2016-10-25 16:34:56 -07:00
Rishi Gupta d14f276322 topic_edit_form: Rename message_edit_topic to inline_topic_edit.
message_edit_form.handlebars already has a message_edit_topic that
refers to the topic edit section of message editing, and this made
things very confusing.
2016-10-25 16:33:20 -07:00
Rishi Gupta 7c227d8bb2 message_edit: Set focus to cancel button in topic-edit-only case.
Because the user was most likely intending to use the "View Source"
functionality, this makes exiting more convenient.
2016-10-25 15:11:39 -07:00
Rishi Gupta 49b23ea84a frontend: Allow users to see the source of messages they can't edit.
Previously we showed an "Edit" item in the actions popover menu when a user
could edit the content or topic of a message, and nothing otherwise. We now
show "Edit", "Edit Topic", or "View Source" in the popover menu for every
message, depending on the editability of the message, and present an
appropriate version of message_edit_form when the menu item is clicked.

Finishes #1604 and #1761.
2016-10-22 18:53:59 -07:00
Rishi Gupta 879f2a1e2e message editing: Refactor editability computation to use editability_types.
We compute the editability of messages in several places around the
frontend; standardize the definitions and store in
message_edit.get_editability. This commit should not change app behavior.
2016-10-22 18:52:49 -07:00
Rishi Gupta c2c389e949 message_edit.js: Refactor edit_message.
Cleanup and re-organize edit_message in preparation for the view source
changes. There are no behavior or logic changes in this commit.
2016-10-22 18:52:49 -07:00
Tim Abbott bd416c0425 message_edit: Cleanup unnecessary 2-layer nesting. 2016-10-22 18:52:49 -07:00
Tim Abbott 5b3caa4d18 message_edit: Fix tooltip with multiple messages being edited.
This fixes an issue where if there were multiple messages being
edited, all of them would have the same tooltip content.
2016-10-22 18:52:49 -07:00
Tim Abbott 5b656db303 message_edit: Clean up tooltip creation code.
This contains no functional changes.
2016-10-22 18:52:49 -07:00
Tim Abbott 0ccf8b162e message_edit: Move topic-editing-only warning.
This makes no functional change, because
`page_params.realm_message_content_edit_limit_seconds === 0` means
can_edit_content is always true.
2016-10-22 18:52:49 -07:00
Tim Abbott d5c3ad8eb5 message_edit: Only initialize composebox_typeahead if needed. 2016-10-22 18:52:49 -07:00
Tim Abbott 76d49300b3 message_edit: Move original_topic variable to a better spot. 2016-10-22 18:52:49 -07:00
Tim Abbott 0acfcbe247 message_edit: Update currently_editing_messages in clearer place. 2016-10-22 18:52:49 -07:00
Tim Abbott d2501396cf message_edit: Reindent form definition. 2016-10-22 18:52:45 -07:00
Tim Abbott 2b58fa0a19 message_edit: Move some setup code closer to where it's used.
This has no functional changes.
2016-10-22 18:40:44 -07:00
Rishi Gupta ebc8bfa6ca javascript: Change all message.is_stream to (message.type === "stream").
We need message.is_stream for some handlebars template code, but
message.is_stream should be thought of as a private variable for that
template.
2016-10-22 18:11:08 -07:00
Rishi Gupta ff4d059595 Message editing: add explanation when past message edit deadline.
Adds "Topic editing only" along with the tooltip explanation to lower right
of message editing box when it's past the message content editing deadline.
2016-10-05 22:42:56 -07:00
Steve Howell 51f35f2ff7 subject/topic: Rename empty_subject_placeholder. 2016-08-26 20:26:24 -07:00
Rishi Gupta d529a94e4d Add realm setting to time-limit editing of message content.
This is controlled through the admin tab and a new field in the Realms table.
Notes:
* The admin tab setting takes a value in minutes, whereas the backend stores it
  in seconds.
* This setting is unused when allow_message_editing is false.
* There is some generosity in how the limit is enforced. For instance, if the
  user sees the hovering edit button, we ensure they have at least 5 seconds to
  click it, and if the user gets to the message edit form, we ensure they have
  at least 10 seconds to make the edit, by relaxing the limit.
* This commit also includes a countdown timer in the message edit form.

Resolves #903.
2016-07-15 13:55:49 -07:00
Tomasz Kolek e6861636c8 Fix editing messages by adding or removing leading /me.
Previously, this did not correctly rerender the message to be (or not
to be) rendered as a /me style message.

Fixes: #835.
2016-06-24 11:18:29 -07:00
Tim Abbott eba0d6339f lint: Require space after // in JS comments. 2016-06-09 13:44:24 -07:00
Tomasz Kolek 29ec2a328b Fix save in topic edit also saving message content edit box.
Fixes #932.
2016-06-07 12:55:58 -07:00
Tim Abbott 5f25974737 Fix Javascript whitespace issues with {. 2015-11-10 10:01:34 -08:00
Leo Franchi 9162ef3e0f Fix wrong logic in handling local-only message edit saves
(imported from commit a9074fbfb75884c3280807ddeba576c0fbe313b7)
2014-03-14 20:48:57 -04:00
Leo Franchi f760567b96 Fix topic edits that are initiated from the FRB.
Grab the id of the selected row, whether it's a message, recipient bar, or FRB

(imported from commit 93b9c282d4220ba9bb271733ded4d90d5c051c75)
2014-03-14 20:48:55 -04:00
Steve Howell 3889edd824 Move xhr_error_message() into channel.js
(imported from commit c68c2d475b5673a3dd5f68c75624dfcfe56728ca)
2014-03-14 20:48:53 -04:00
Leo Franchi b51ea69db0 Handle topic edits and rerender view if topics have changed
(imported from commit b59f6b532138d660e0acfb949b2eb223b5c5ed0e)
2014-02-27 20:25:33 -05:00