2023-12-14 11:47:20 -05:00
|
|
|
import Component from "@glimmer/component";
|
2024-01-12 18:28:06 -05:00
|
|
|
import { fn } from "@ember/helper";
|
2024-08-06 13:57:39 -04:00
|
|
|
import { on } from "@ember/modifier";
|
2023-12-14 11:47:20 -05:00
|
|
|
import { action } from "@ember/object";
|
|
|
|
import DButton from "discourse/components/d-button";
|
2024-08-06 13:57:39 -04:00
|
|
|
import withEventValue from "discourse/helpers/with-event-value";
|
2023-12-14 11:47:20 -05:00
|
|
|
import i18n from "discourse-common/helpers/i18n";
|
|
|
|
import not from "truth-helpers/helpers/not";
|
|
|
|
|
|
|
|
export default class AiHelperCustomPrompt extends Component {
|
2024-01-12 18:28:06 -05:00
|
|
|
@action
|
2024-08-06 13:57:39 -04:00
|
|
|
sendInput(event) {
|
|
|
|
if (event.key !== "Enter") {
|
|
|
|
return;
|
|
|
|
}
|
2024-01-12 18:28:06 -05:00
|
|
|
return this.args.submit(this.args.promptArgs);
|
|
|
|
}
|
|
|
|
|
2023-12-14 11:47:20 -05:00
|
|
|
<template>
|
2024-08-06 13:57:39 -04:00
|
|
|
<div class="ai-custom-prompt">
|
|
|
|
|
|
|
|
<input
|
|
|
|
{{on "input" (withEventValue (fn (mut @value)))}}
|
|
|
|
{{on "keydown" this.sendInput}}
|
|
|
|
value={{@value}}
|
2023-12-14 11:47:20 -05:00
|
|
|
placeholder={{i18n
|
|
|
|
"discourse_ai.ai_helper.context_menu.custom_prompt.placeholder"
|
|
|
|
}}
|
|
|
|
class="ai-custom-prompt__input"
|
2024-08-06 13:57:39 -04:00
|
|
|
type="text"
|
2024-09-13 14:59:30 -04:00
|
|
|
autofocus="autofocus"
|
2023-12-14 11:47:20 -05:00
|
|
|
/>
|
|
|
|
|
|
|
|
<DButton
|
|
|
|
@icon="discourse-sparkles"
|
2024-01-12 18:28:06 -05:00
|
|
|
@action={{fn @submit @promptArgs}}
|
2023-12-14 11:47:20 -05:00
|
|
|
@disabled={{not @value.length}}
|
2024-01-12 18:28:06 -05:00
|
|
|
class="ai-custom-prompt__submit btn-primary"
|
2023-12-14 11:47:20 -05:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
}
|