2023-09-04 18:36:48 +00:00
|
|
|
import configs
|
|
|
|
from gui.components.base_popup import BasePopup
|
2024-07-11 10:51:56 +00:00
|
|
|
from gui.components.community.new_permission_popup import NewPermissionPopup
|
2023-09-04 18:36:48 +00:00
|
|
|
from gui.components.emoji_popup import EmojiPopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
2024-07-11 10:51:56 +00:00
|
|
|
from gui.elements.check_box import CheckBox
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.text_edit import TextEdit
|
2024-02-13 09:04:24 +00:00
|
|
|
from gui.objects_map import names
|
2024-11-06 18:49:46 +00:00
|
|
|
from gui.screens.community_settings import PermissionsSettingsView
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ChannelPopup(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(ChannelPopup, self).__init__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._name_text_edit = TextEdit(names.createOrEditCommunityChannelNameInput_TextEdit)
|
|
|
|
self._description_text_edit = TextEdit(names.createOrEditCommunityChannelDescriptionInput_TextEdit)
|
2024-11-06 11:05:25 +00:00
|
|
|
self.save_create_button = Button(names.createOrEditCommunityChannelBtn_StatusButton)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._emoji_button = Button(names.createOrEditCommunityChannel_EmojiButton)
|
2024-07-11 10:51:56 +00:00
|
|
|
self._add_permission_button = Button(names.add_permission_StatusButton)
|
|
|
|
self._hide_channel_checkbox = CheckBox(names.hide_channel_checkbox)
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
|
|
|
|
self._name_text_edit.wait_until_appears(timeout_msec)
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
class NewChannelPopup(ChannelPopup):
|
|
|
|
|
|
|
|
def create(self, name: str, description: str, emoji: str = None):
|
|
|
|
self._name_text_edit.text = name
|
|
|
|
self._description_text_edit.text = description
|
|
|
|
if emoji is not None:
|
|
|
|
self._emoji_button.click()
|
|
|
|
EmojiPopup().wait_until_appears().select(emoji)
|
2024-07-11 10:51:56 +00:00
|
|
|
return self
|
|
|
|
|
|
|
|
def add_permission(self):
|
|
|
|
self._add_permission_button.click()
|
|
|
|
return NewPermissionPopup().wait_until_appears()
|
|
|
|
|
|
|
|
def hide_permission(self, value: bool, attempt: int = 2):
|
|
|
|
try:
|
|
|
|
return self._hide_channel_checkbox.set(value)
|
|
|
|
except AssertionError as err:
|
|
|
|
if attempt:
|
|
|
|
self.hide_permission(True, attempt - 1)
|
|
|
|
else:
|
|
|
|
raise err
|
|
|
|
|
2023-09-04 18:36:48 +00:00
|
|
|
|
|
|
|
class EditChannelPopup(ChannelPopup):
|
|
|
|
|
|
|
|
def edit(self, name: str, description: str = None, emoji: str = None):
|
|
|
|
self._name_text_edit.text = name
|
|
|
|
if description is not None:
|
|
|
|
self._description_text_edit.text = description
|
|
|
|
if emoji is not None:
|
|
|
|
self._emoji_button.click()
|
|
|
|
EmojiPopup().wait_until_appears().select(emoji)
|
2024-11-06 11:05:25 +00:00
|
|
|
self.save_create_button.click()
|
2023-09-04 18:36:48 +00:00
|
|
|
self.wait_until_hidden()
|