mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 04:14:38 +08:00
FIX: only show discourse-ai CTA to admins (#26895)
This commit is contained in:
@ -12,6 +12,7 @@ import i18n from "discourse-common/helpers/i18n";
|
|||||||
|
|
||||||
export default class ChatModalThreadSettings extends Component {
|
export default class ChatModalThreadSettings extends Component {
|
||||||
@service chatApi;
|
@service chatApi;
|
||||||
|
@service currentUser;
|
||||||
|
|
||||||
@tracked editedTitle = this.thread.title || "";
|
@tracked editedTitle = this.thread.title || "";
|
||||||
@tracked saving = false;
|
@tracked saving = false;
|
||||||
@ -74,17 +75,19 @@ export default class ChatModalThreadSettings extends Component {
|
|||||||
<span>{{this.threadTitleLength}}</span>/50
|
<span>{{this.threadTitleLength}}</span>/50
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="discourse-ai-cta">
|
{{#if this.currentUser.admin}}
|
||||||
<p class="discourse-ai-cta__title">{{icon "info-circle"}}
|
<div class="discourse-ai-cta">
|
||||||
{{i18n "chat.thread_title_modal.discourse_ai.title"}}</p>
|
<p class="discourse-ai-cta__title">{{icon "info-circle"}}
|
||||||
<p class="discourse-ai-cta__description">{{htmlSafe
|
{{i18n "chat.thread_title_modal.discourse_ai.title"}}</p>
|
||||||
(i18n
|
<p class="discourse-ai-cta__description">{{htmlSafe
|
||||||
"chat.thread_title_modal.discourse_ai.description"
|
(i18n
|
||||||
url="<a href='https://www.discourse.org/ai' rel='noopener noreferrer' target='_blank'>Discourse AI</a>"
|
"chat.thread_title_modal.discourse_ai.description"
|
||||||
)
|
url="<a href='https://www.discourse.org/ai' rel='noopener noreferrer' target='_blank'>Discourse AI</a>"
|
||||||
}}
|
)
|
||||||
</p>
|
}}
|
||||||
</div>
|
</p>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</:body>
|
</:body>
|
||||||
<:footer>
|
<:footer>
|
||||||
<DButton
|
<DButton
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
import { getOwner } from "@ember/application";
|
||||||
|
import { render } from "@ember/test-helpers";
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
|
import ChatModalThreadSettings from "discourse/plugins/chat/discourse/components/chat/modal/thread-settings";
|
||||||
|
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||||
|
|
||||||
|
module("Discourse Chat | Component | <ThreadSettings />", function (hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test("discourse-ai - admin", async function (assert) {
|
||||||
|
this.currentUser.admin = true;
|
||||||
|
const thread = new ChatFabricators(getOwner(this)).thread();
|
||||||
|
|
||||||
|
await render(<template>
|
||||||
|
<ChatModalThreadSettings @inline={{true}} @model={{thread}} />
|
||||||
|
</template>);
|
||||||
|
|
||||||
|
assert.dom(".discourse-ai-cta").exists();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("discourse-ai - not admin", async function (assert) {
|
||||||
|
this.currentUser.admin = false;
|
||||||
|
const thread = new ChatFabricators(getOwner(this)).thread();
|
||||||
|
|
||||||
|
await render(<template>
|
||||||
|
<ChatModalThreadSettings @inline={{true}} @model={{thread}} />
|
||||||
|
</template>);
|
||||||
|
|
||||||
|
assert.dom(".discourse-ai-cta").doesNotExist();
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user