Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UX: Allow warning / hint to be clicked to toggle whispering #10

Merged
merged 7 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
padding: 2px 8px;
font-size: var(--font-down-2);
border-radius: 10px;
.d-icon {
margin-right: 4px;
}
&.whispering {
color: var(--tertiary);
background-color: var(--tertiary-low);
Expand Down
6 changes: 6 additions & 0 deletions javascripts/discourse/api-initializers/whisper-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { apiInitializer } from "discourse/lib/api";
import whisperWarning from "../components/whisper-warning";

export default apiInitializer("1.8.0", (api) => {
api.renderInOutlet("composer-action-after", whisperWarning);
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
import { service } from "@ember/service";
import I18n from "discourse-i18n";
import DButton from "discourse/components/d-button";
import concatClass from "discourse/helpers/concat-class";
import I18n from "discourse-common/helpers/i18n";

export default class WhisperWarning extends Component {
@service currentUser;
@service composer;

get shouldRender() {
get showWarning() {
// checks if the current user is replying in a group PM
const allowedGroups =
this.args.outletArgs.model.topic?.get("allowedGroups");
Expand All @@ -29,7 +33,7 @@ export default class WhisperWarning extends Component {
this.currentUser.groups?.filter((group) => {
return group.name === "accidentalloudmouths";
}).length > 0;
const canWhisper = this.currentUser.whisperer;
const canWhisper = this.composer.showWhisperToggle;
const isNotNewTopic =
this.args.outletArgs.model.get("action") !== "createTopic";
const isNotNewPM =
Expand All @@ -48,16 +52,30 @@ export default class WhisperWarning extends Component {
);
}

get isWhispering() {
let whisper = this.args.outletArgs.model.get("whisper");
return whisper;
get translatedLabel() {
if (this.composer.isWhispering) {
I18n.t(themePrefix("whispering"));
} else {
I18n.t(themePrefix("public_reply"));
}
}

get publicLabel() {
return I18n.t(themePrefix("public_reply"));
}

get whisperLabel() {
return I18n.t(themePrefix("whispering"));
@action
toggleWhisper() {
this.composer.toggleWhisper();
}
<template>
{{#if this.showWarning}}
<DButton
@preventFocus={{true}}
@action={{this.toggleWhisper}}
@icon="far-eye-slash"
@class={{concatClass
"whisper-hint"
(if this.composer.isWhispering "whispering" "public")
}}
@translatedLabel={{this.translatedLabel}}
/>
{{/if}}
</template>
}

This file was deleted.