mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
integrations-url-modal: Add URL parameter for filtering by branches.
Use the config option "branches" to enable the UI for filtering branches. Fixes: #33736.
This commit is contained in:
@@ -180,6 +180,8 @@ IGNORED_PHRASES = [
|
||||
r"weeks",
|
||||
# Used in "Who can subscribe to this channel" label.
|
||||
r"everyone except guests can subscribe to any public channel",
|
||||
# Used in branch-filtering label in the integration-url-modal.
|
||||
r"comma-separated list",
|
||||
]
|
||||
|
||||
# Sort regexes in descending order of their lengths. As a result, the
|
||||
|
||||
@@ -5,6 +5,7 @@ import {z} from "zod";
|
||||
|
||||
import render_generate_integration_url_config_checkbox_modal from "../templates/settings/generate_integration_url_config_checkbox_modal.hbs";
|
||||
import render_generate_integration_url_config_text_modal from "../templates/settings/generate_integration_url_config_text_modal.hbs";
|
||||
import render_generate_integration_url_filter_branches_modal from "../templates/settings/generate_integration_url_filter_branches_modal.hbs";
|
||||
import render_generate_integration_url_modal from "../templates/settings/generate_integration_url_modal.hbs";
|
||||
import render_integration_events from "../templates/settings/integration_events.hbs";
|
||||
|
||||
@@ -15,6 +16,7 @@ import type {DropdownWidget, Option} from "./dropdown_widget.ts";
|
||||
import {$t_html} from "./i18n.ts";
|
||||
import {realm} from "./state_data.ts";
|
||||
import * as stream_data from "./stream_data.ts";
|
||||
import {place_caret_at_end} from "./ui_util.ts";
|
||||
import * as util from "./util.ts";
|
||||
|
||||
type ConfigOption = {
|
||||
@@ -82,7 +84,23 @@ export function show_generate_integration_url_modal(api_key: string): void {
|
||||
for (const option of validated_config) {
|
||||
let $config_element: JQuery;
|
||||
|
||||
if (option.validator === "check_bool") {
|
||||
if (option.key === "branches") {
|
||||
const filter_branches_html =
|
||||
render_generate_integration_url_filter_branches_modal();
|
||||
$config_element = $(filter_branches_html);
|
||||
$config_element.find("#integration-url-all-branches").on("change", () => {
|
||||
$("#integration-url-filter-branches").toggleClass(
|
||||
"hide",
|
||||
$("#integration-url-all-branches").prop("checked"),
|
||||
);
|
||||
$("#integration-url-branches-text").trigger("focus");
|
||||
place_caret_at_end(util.the($("#integration-url-branches-text")));
|
||||
update_url();
|
||||
});
|
||||
$config_element.find("#integration-url-branches-text").on("change", () => {
|
||||
update_url();
|
||||
});
|
||||
} else if (option.validator === "check_bool") {
|
||||
const config_html = render_generate_integration_url_config_checkbox_modal({
|
||||
key: option.key,
|
||||
label: option.label,
|
||||
@@ -203,7 +221,14 @@ export function show_generate_integration_url_modal(api_key: string): void {
|
||||
} else if (option.validator === "check_string") {
|
||||
$input_element = $(`#integration-url-${option.key}-text`);
|
||||
const value = $input_element.val();
|
||||
if (value) {
|
||||
// If the config option is "branches", ensure the checkbox is unchecked.
|
||||
if (
|
||||
value &&
|
||||
(option.key !== "branches" ||
|
||||
$<HTMLInputElement>("#integration-url-all-branches").prop(
|
||||
"checked",
|
||||
) === false)
|
||||
) {
|
||||
params.set(option.key, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<div class="input-group" id="integration-url-branches-parameter">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="integration-url-all-branches" class="integration-url-parameter" checked/>
|
||||
<span class="rendered-checkbox"></span>
|
||||
</label>
|
||||
<label class="inline" for="integration-url-all-branches">
|
||||
{{t "Send notifications for all branches"}}
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-group hide" id="integration-url-filter-branches">
|
||||
<label for="integration-url-branches-text" class="modal-label-field">
|
||||
{{t "Which branches should notifications be sent for?"}}
|
||||
(<i>{{t "comma-separated list"}}</i>)
|
||||
</label>
|
||||
<input type="text" id="integration-url-branches-text" class="modal_text_input integration-url-parameter" value="main"/>
|
||||
</div>
|
||||
Reference in New Issue
Block a user