From 71c5b023904dd2ac05bd9976c367027a193517f3 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 12 Oct 2021 15:13:56 -0600 Subject: [PATCH] Add feature flag for polls and placeholder dialog We're anticipating development of polls soon, so for efficiency reasons we're getting the labs flag in early. If something goes wrong with the plan, this whole change will be reverted. --- res/css/views/rooms/_MessageComposer.scss | 4 +++ res/img/element-icons/room/composer/poll.svg | 5 +++ .../views/rooms/MessageComposer.tsx | 32 +++++++++++++++++++ src/i18n/strings/en_EN.json | 2 ++ src/settings/Settings.tsx | 6 ++++ 5 files changed, 49 insertions(+) create mode 100644 res/img/element-icons/room/composer/poll.svg diff --git a/res/css/views/rooms/_MessageComposer.scss b/res/css/views/rooms/_MessageComposer.scss index c20dd43daf..62cbdb910a 100644 --- a/res/css/views/rooms/_MessageComposer.scss +++ b/res/css/views/rooms/_MessageComposer.scss @@ -252,6 +252,10 @@ limitations under the License. mask-image: url('$(res)/img/element-icons/room/composer/attach.svg'); } +.mx_MessageComposer_poll::before { + mask-image: url('$(res)/img/element-icons/room/composer/poll.svg'); +} + .mx_MessageComposer_voiceMessage::before { mask-image: url('$(res)/img/voip/mic-on-mask.svg'); } diff --git a/res/img/element-icons/room/composer/poll.svg b/res/img/element-icons/room/composer/poll.svg new file mode 100644 index 0000000000..063edab7ab --- /dev/null +++ b/res/img/element-icons/room/composer/poll.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/components/views/rooms/MessageComposer.tsx b/src/components/views/rooms/MessageComposer.tsx index f14af69a6d..e092081e6a 100644 --- a/src/components/views/rooms/MessageComposer.tsx +++ b/src/components/views/rooms/MessageComposer.tsx @@ -52,6 +52,8 @@ import EditorModel from "../../../editor/model"; import EmojiPicker from '../emojipicker/EmojiPicker'; import MemberStatusMessageAvatar from "../avatars/MemberStatusMessageAvatar"; import UIStore, { UI_EVENTS } from '../../../stores/UIStore'; +import Modal from "../../../Modal"; +import InfoDialog from "../dialogs/InfoDialog"; let instanceCount = 0; const NARROW_MODE_BREAKPOINT = 500; @@ -193,6 +195,31 @@ class UploadButton extends React.Component { } } +// TODO: [polls] Make this component actually do something +class PollButton extends React.PureComponent { + private onCreateClick = () => { + Modal.createTrackedDialog('Polls', 'Not Yet Implemented', InfoDialog, { + // XXX: Deliberately not translated given this dialog is meant to be replaced and we don't + // want to clutter the language files with short-lived strings. + title: "Polls are currently in development", + description: "" + + "Thanks for testing polls! We haven't quite gotten a chance to write the feature yet " + + "though. Check back later for updates.", + hasCloseButton: true, + }); + }; + + render() { + return ( + + ); + } +} + interface IProps { room: Room; resizeNotifier: ResizeNotifier; @@ -432,6 +459,11 @@ export default class MessageComposer extends React.Component { private renderButtons(menuPosition): JSX.Element | JSX.Element[] { const buttons: JSX.Element[] = []; if (!this.state.haveRecording) { + if (SettingsStore.getValue("feature_polls")) { + buttons.push( + + ); + } buttons.push( , ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index bdc86a9e08..c9573a69db 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -823,6 +823,7 @@ "Show message previews for reactions in all rooms": "Show message previews for reactions in all rooms", "Offline encrypted messaging using dehydrated devices": "Offline encrypted messaging using dehydrated devices", "Send pseudonymous analytics data": "Send pseudonymous analytics data", + "Polls (under active development)": "Polls (under active development)", "Show info about bridges in room settings": "Show info about bridges in room settings", "New layout switcher (with message bubbles)": "New layout switcher (with message bubbles)", "Don't send read receipts": "Don't send read receipts", @@ -1575,6 +1576,7 @@ "Emoji picker": "Emoji picker", "Add emoji": "Add emoji", "Upload file": "Upload file", + "Create poll": "Create poll", "Reply to encrypted thread…": "Reply to encrypted thread…", "Reply to thread…": "Reply to thread…", "Send an encrypted reply…": "Send an encrypted reply…", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 9fba69a63b..d36ea2ac94 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -246,6 +246,12 @@ export const SETTINGS: {[setting: string]: ISetting} = { default: false, controller: new PseudonymousAnalyticsController(), }, + "feature_polls": { + isFeature: true, + supportedLevels: LEVELS_FEATURE, + displayName: _td("Polls (under active development)"), + default: false, + }, "doNotDisturb": { supportedLevels: [SettingLevel.DEVICE], default: false,