zcommand: Replace "mode" with "theme" in the returned message.

This commit replaces "dark mode" and "light mode" with "dark theme"
and "light theme" in the message returned and shown in a little
popup in the UI, when color scheme settings are changed through
slash commands.
This commit is contained in:
Sahil Batra 2021-11-22 23:56:13 +05:30 committed by Tim Abbott
parent 1cdc7306c6
commit eef9dd963b
2 changed files with 10 additions and 10 deletions

View File

@ -9,12 +9,12 @@ from zerver.models import UserProfile
def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]:
def change_mode_setting(
command: str, switch_command: str, setting: str, setting_value: int
setting_name: str, switch_command: str, setting: str, setting_value: int
) -> str:
msg = (
"Changed to {command} mode! To revert "
"{command} mode, type `/{switch_command}`.".format(
command=command,
"Changed to {setting_name}! To revert "
"{setting_name}, type `/{switch_command}`.".format(
setting_name=setting_name,
switch_command=switch_command,
)
)
@ -37,7 +37,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
return dict(msg="You are still in dark theme.")
return dict(
msg=change_mode_setting(
command="dark",
setting_name="dark theme",
switch_command="light",
setting="color_scheme",
setting_value=UserProfile.COLOR_SCHEME_NIGHT,
@ -48,7 +48,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
return dict(msg="You are still in light theme.")
return dict(
msg=change_mode_setting(
command="light",
setting_name="light theme",
switch_command="dark",
setting="color_scheme",
setting_value=UserProfile.COLOR_SCHEME_LIGHT,
@ -59,7 +59,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
return dict(msg="You are still in fluid width mode.")
return dict(
msg=change_mode_setting(
command=command,
setting_name="fluid-width mode",
switch_command="fixed-width",
setting="fluid_layout_width",
setting_value=True,
@ -70,7 +70,7 @@ def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]
return dict(msg="You are still in fixed width mode.")
return dict(
msg=change_mode_setting(
command=command,
setting_name="fixed-width mode",
switch_command="fluid-width",
setting="fluid_layout_width",
setting_value=False,

View File

@ -30,7 +30,7 @@ class ZcommandTest(ZulipTestCase):
payload = dict(command="/night")
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)
self.assertIn("Changed to dark mode", result.json()["msg"])
self.assertIn("Changed to dark theme", result.json()["msg"])
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)
@ -45,7 +45,7 @@ class ZcommandTest(ZulipTestCase):
payload = dict(command="/day")
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)
self.assertIn("Changed to light mode", result.json()["msg"])
self.assertIn("Changed to light theme", result.json()["msg"])
result = self.client_post("/json/zcommand", payload)
self.assert_json_success(result)