Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
giphy: Fix incorrectly working show/hide behaviour.
Aman Agrawal2a1bcd4b594b
diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.jsindex 8ca75177b72..3f59545491c 100644--- a/frontend_tests/node_tests/compose.js+++ b/frontend_tests/node_tests/compose.js@@ -63,6 +63,9 @@ const ui_util = mock_esm("../../static/js/ui_util");mock_esm("../../static/js/drafts", {delete_draft_after_send: noop,});+mock_esm("../../static/js/giphy", {+ is_giphy_enabled: () => true,+});mock_esm("../../static/js/notifications", {notify_above_composebox: noop,clear_compose_notifications: noop,diff --git a/frontend_tests/node_tests/compose_video.js b/frontend_tests/node_tests/compose_video.jsindex 9c302c7544f..fc67f53236e 100644--- a/frontend_tests/node_tests/compose_video.js+++ b/frontend_tests/node_tests/compose_video.js@@ -13,6 +13,9 @@ const events = require("./lib/events");mock_cjs("jquery", $);const channel = mock_esm("../../static/js/channel");const upload = mock_esm("../../static/js/upload");+mock_esm("../../static/js/giphy", {+ is_giphy_enabled: () => true,+});mock_esm("../../static/js/resize", {watch_manual_resize() {},});@@ -27,7 +30,6 @@ set_global("document", {const server_events_dispatch = zrequire("server_events_dispatch");const compose_ui = zrequire("compose_ui");const compose = zrequire("compose");-function stub_out_video_calls() {const elem = $("#below-compose-content .video_link");elem.toggle = (show) => {diff --git a/static/js/compose.js b/static/js/compose.jsindex abfde23816a..48700f80461 100644--- a/static/js/compose.js+++ b/static/js/compose.js@@ -18,6 +18,7 @@ import * as compose_state from "./compose_state";import * as compose_ui from "./compose_ui";import * as drafts from "./drafts";import * as echo from "./echo";+import * as giphy from "./giphy";import {$t, $t_html} from "./i18n";import * as loading from "./loading";import * as markdown from "./markdown";@@ -1106,7 +1107,7 @@ export function initialize() {render_compose({embedded: $compose.attr("data-embedded") === "",file_upload_enabled: page_params.max_file_upload_size_mib > 0,- giphy_enabled: page_params.giphy_api_key !== "",+ giphy_enabled: giphy.is_giphy_enabled(),}),);diff --git a/static/js/giphy.js b/static/js/giphy.jsindex e02b88b7b93..326a8911433 100644--- a/static/js/giphy.js+++ b/static/js/giphy.js@@ -31,10 +31,10 @@ export function focus_current_edit_message() {}export function is_giphy_enabled() {- if (page_params.giphy_api_key === "") {- return false;- }- return page_params.realm_giphy_rating !== page_params.giphy_rating_options.disabled.id;+ return (+ page_params.giphy_api_key !== "" &&+ page_params.realm_giphy_rating !== page_params.giphy_rating_options.disabled.id+ );}// Approximate width and height ofdiff --git a/static/js/message_edit.js b/static/js/message_edit.jsindex d0333a46926..c2361150165 100644--- a/static/js/message_edit.js+++ b/static/js/message_edit.js@@ -356,7 +356,7 @@ function edit_message(row, raw_content) {stream_name: message.stream,notify_new_thread: notify_new_thread_default,notify_old_thread: notify_old_thread_default,- giphy_api_available: giphy.is_giphy_enabled(),+ giphy_enabled: giphy.is_giphy_enabled(),hide_drafts_link: true,}),);diff --git a/static/styles/compose.css b/static/styles/compose.cssindex 3d0367c27a8..31f04b48cc0 100644--- a/static/styles/compose.css+++ b/static/styles/compose.css@@ -425,7 +425,11 @@ a.compose_control_button {}}-a.message-control-button.hide {+/* This is used to override the+ * properties of `a.compose_control_button`+ * without using `!important`.+ */+a.compose_control_button.hide {display: none;}diff --git a/static/templates/compose_control_buttons.hbs b/static/templates/compose_control_buttons.hbsindex d60247ccd6a..651b6cfec1f 100644--- a/static/templates/compose_control_buttons.hbs+++ b/static/templates/compose_control_buttons.hbs@@ -1,4 +1,3 @@-{{! This file assumes message_id is only preset in message_edit_form and message_id cannot be 0.}}<input type="file" class="file_input notvisible pull-left" multiple />{{#if file_upload_enabled }}<a role="button" class="compose_control_button compose_upload_file fa fa-paperclip notdisplayed" aria-label="{{t 'Upload files' }}" tabindex=0 title="{{t 'Upload files' }}"></a>@@ -7,7 +6,7 @@<a role="button" class="undo_markdown_preview compose_control_button fa fa-edit" aria-label="{{t 'Write' }}" tabindex=0 style="display:none;" title="{{t 'Write' }}"></a><a role="button" class="compose_control_button fa fa-video-camera video_link" aria-label="{{t 'Add video call' }}" tabindex=0 title="{{t 'Add video call' }}"></a><a role="button" class="compose_control_button fa fa-smile-o emoji_map" aria-label="{{t 'Add emoji' }}" tabindex=0 title="{{t 'Add emoji' }}"></a>-<a role="button" class="compose_control_button compose_giphy_link {{#unless giphy_api_available }} hide {{/unless}}" aria-label="{{t 'Add GIF' }}" title="{{t 'Add GIF' }}">+<a role="button" class="compose_control_button compose_giphy_link {{#unless giphy_enabled }} hide {{/unless}}" aria-label="{{t 'Add GIF' }}" title="{{t 'Add GIF' }}"><img class="compose_giphy_logo" tabindex=0 src="/static/assets/icons/gif.svg" /></a>{{#unless hide_drafts_link}}