From ee70cd8af31f3dfdadaf5da967a30f4b192e00fa Mon Sep 17 00:00:00 2001 From: opmkumar Date: Wed, 2 Oct 2024 21:04:43 +0530 Subject: [PATCH] saved_snippet: Prepopulate new saved snippet content. Fixes #31827. --- web/src/saved_snippets_ui.ts | 5 ++++- web/templates/add_saved_snippet_modal.hbs | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/saved_snippets_ui.ts b/web/src/saved_snippets_ui.ts index 57845f706f..6d89255846 100644 --- a/web/src/saved_snippets_ui.ts +++ b/web/src/saved_snippets_ui.ts @@ -6,6 +6,7 @@ import render_add_saved_snippet_modal from "../templates/add_saved_snippet_modal import render_confirm_delete_saved_snippet from "../templates/confirm_dialog/confirm_delete_saved_snippet.hbs"; import * as channel from "./channel"; +import * as compose_state from "./compose_state"; import * as compose_ui from "./compose_ui"; import * as confirm_dialog from "./confirm_dialog"; import * as dialog_widget from "./dialog_widget"; @@ -91,7 +92,9 @@ function item_click_callback( if (current_value === saved_snippets.ADD_SAVED_SNIPPET_OPTION_ID) { dialog_widget.launch({ html_heading: $t_html({defaultMessage: "Add a new saved snippet"}), - html_body: render_add_saved_snippet_modal(), + html_body: render_add_saved_snippet_modal({ + prepopulated_content: compose_state.message_content(), + }), html_submit_button: $t_html({defaultMessage: "Save"}), id: "add-new-saved-snippet-modal", form_id: "add-new-saved-snippet-form", diff --git a/web/templates/add_saved_snippet_modal.hbs b/web/templates/add_saved_snippet_modal.hbs index 75e73ef0b5..a5936c6f5f 100644 --- a/web/templates/add_saved_snippet_modal.hbs +++ b/web/templates/add_saved_snippet_modal.hbs @@ -3,6 +3,8 @@
{{t "Content" }}
- +