Skip to content

Commit

Permalink
change closed property to rigid to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Aug 14, 2023
1 parent bdd075f commit 7a17994
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions web/shared/src/poll_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class PollData {
comma_separated_names,
report_error_function,
anonymous,
closed,
rigid,
}) {
this.message_sender_id = message_sender_id;
this.me = current_user_id;
Expand All @@ -30,7 +30,7 @@ export class PollData {
this.comma_separated_names = comma_separated_names;
this.report_error_function = report_error_function;
this.anonymous = anonymous;
this.closed = closed;
this.rigid = rigid;

if (question) {
this.set_question(question);
Expand Down Expand Up @@ -85,7 +85,7 @@ export class PollData {
options,
question: this.poll_question,
anonymous: this.anonymous,
closed: this.closed,
rigid: this.rigid,
};

return widget_data;
Expand Down
4 changes: 2 additions & 2 deletions web/shared/src/poll_data.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ declare export class PollData {
comma_separated_names: (user_ids: number[]) => string,
report_error_function: (msg: string) => void,
anonymous: boolean,
closed: boolean,
rigid: boolean,
}): void;

set_question(question: string): void;
Expand All @@ -43,7 +43,7 @@ declare export class PollData {
current_user_vote: boolean,
}>,
anonymous: boolean,
closed: boolean,
rigid: boolean,
};

handle_event(sender_id: number, data: PollEvent): void;
Expand Down
8 changes: 4 additions & 4 deletions web/src/composebox_typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ export const slash_commands = [
placeholder: $t({defaultMessage: "Question"}),
},
{
text: $t({defaultMessage: "/poll-closed (No create option)"}),
name: "poll-closed",
text: $t({defaultMessage: "/poll-rigid (No new options)"}),
name: "poll-rigid",
aliases: "",
placeholder: $t({defaultMessage: "Question"}),
},
Expand All @@ -425,8 +425,8 @@ export const slash_commands = [
placeholder: $t({defaultMessage: "Question"}),
},
{
text: $t({defaultMessage: "/poll-anon-closed (Anonymous, no create option)"}),
name: "poll-anon-closed",
text: $t({defaultMessage: "/poll-anon-rigid (Anonymous, no new options)"}),
name: "poll-anon-rigid",
aliases: "",
placeholder: $t({defaultMessage: "Question"}),
},
Expand Down
4 changes: 2 additions & 2 deletions web/src/poll_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as people from "./people";
export function activate({
$elem,
callback,
extra_data: {question = "", options = [], anonymous = false, closed = false} = {},
extra_data: {question = "", options = [], anonymous = false, rigid = false} = {},
message,
}) {
const is_my_poll = people.is_my_user_id(message.sender_id);
Expand All @@ -25,7 +25,7 @@ export function activate({
comma_separated_names: people.get_full_names_for_poll_option,
report_error_function: blueslip.warn,
anonymous,
closed
rigid
});

function update_edit_controls() {
Expand Down
4 changes: 2 additions & 2 deletions web/src/widgetize.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import * as zform from "./zform";

const widgets = new Map([
["poll-anon", poll_widget],
["poll-closed", poll_widget],
["poll-anon-closed", poll_widget],
["poll-rigid", poll_widget],
["poll-anon-rigid", poll_widget],
["poll", poll_widget],
["todo", todo_widget],
["zform", zform],
Expand Down
2 changes: 1 addition & 1 deletion web/templates/widgets/poll_widget.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</div>
<ul class="poll-widget">
</ul>
{{#unless closed}}
{{#unless rigid}}
<div class="poll-option-bar">
<input type="text" class="poll-option" placeholder="{{t 'New option'}}" />
<button class="poll-option">{{t "Add option" }}</button>
Expand Down
8 changes: 4 additions & 4 deletions zerver/lib/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def get_widget_data(content: str) -> Tuple[Optional[str], Optional[str]]:
valid_widget_types = ["poll", "poll-anon", "poll-closed", "poll-anon-closed", "todo"]
valid_widget_types = ["poll", "poll-anon", "poll-rigid", "poll-anon-rigid", "todo"]
tokens = content.split(" ")

# tokens[0] will always exist
Expand All @@ -22,8 +22,8 @@ def get_widget_data(content: str) -> Tuple[Optional[str], Optional[str]]:


def get_extra_data_from_widget_type(content: str, widget_type: Optional[str]) -> Any:
if widget_type in ["poll", "poll-anon", "poll-closed", "poll-anon-closed"]:
closed = widget_type.endswith("-closed")
if widget_type in ["poll", "poll-anon", "poll-rigid", "poll-anon-rigid"]:
rigid = widget_type.endswith("-rigid")
anonymous = widget_type.startswith("poll-anon")
# This is used to extract the question from the poll command.
# The command '/poll question' will pre-set the question in the poll
Expand All @@ -42,7 +42,7 @@ def get_extra_data_from_widget_type(content: str, widget_type: Optional[str]) ->
"question": question,
"options": options,
"anonymous": anonymous,
"closed": closed,
"rigid": rigid,
}
return extra_data
return None
Expand Down

0 comments on commit 7a17994

Please sign in to comment.