2023-08-23 13:35:40 -04:00
|
|
|
<div {{did-insert this.setupContextMenu}}>
|
|
|
|
{{#if this.showContextMenu}}
|
|
|
|
<div class="ai-helper-context-menu">
|
|
|
|
{{#if (eq this.menuState this.CONTEXT_MENU_STATES.triggers)}}
|
|
|
|
<ul class="ai-helper-context-menu__trigger">
|
|
|
|
<li>
|
|
|
|
<DButton
|
2023-09-05 16:21:05 -04:00
|
|
|
@icon="discourse-sparkles"
|
2023-08-23 13:35:40 -04:00
|
|
|
@action={{this.toggleAiHelperOptions}}
|
|
|
|
@label="discourse_ai.ai_helper.context_menu.trigger"
|
|
|
|
class="btn-flat"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
{{else if (eq this.menuState this.CONTEXT_MENU_STATES.options)}}
|
|
|
|
<ul class="ai-helper-context-menu__options">
|
|
|
|
{{#each this.helperOptions as |option|}}
|
|
|
|
<li data-name={{option.name}} data-value={{option.value}}>
|
|
|
|
<DButton
|
|
|
|
@class="btn-flat"
|
|
|
|
@translatedLabel={{option.name}}
|
|
|
|
@action={{this.updateSelected}}
|
|
|
|
@actionParam={{option.value}}
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
{{/each}}
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
{{else if (eq this.menuState this.CONTEXT_MENU_STATES.loading)}}
|
|
|
|
<ul class="ai-helper-context-menu__loading">
|
|
|
|
<li>
|
|
|
|
<div class="dot-falling"></div>
|
|
|
|
<span>
|
|
|
|
{{i18n "discourse_ai.ai_helper.context_menu.loading"}}
|
|
|
|
</span>
|
2023-09-07 16:50:56 -04:00
|
|
|
<DButton
|
|
|
|
@icon="times"
|
|
|
|
@title="discourse_ai.ai_helper.context_menu.cancel"
|
|
|
|
@action={{this.cancelAIAction}}
|
|
|
|
class="btn-flat cancel-request"
|
|
|
|
/>
|
2023-08-23 13:35:40 -04:00
|
|
|
</li>
|
2023-09-07 16:50:56 -04:00
|
|
|
|
2023-08-23 13:35:40 -04:00
|
|
|
</ul>
|
|
|
|
|
2023-08-24 20:49:24 -04:00
|
|
|
{{else if (eq this.menuState this.CONTEXT_MENU_STATES.review)}}
|
|
|
|
<ul class="ai-helper-context-menu__review">
|
|
|
|
<li>
|
|
|
|
<DButton
|
|
|
|
@icon="exchange-alt"
|
|
|
|
@label="discourse_ai.ai_helper.context_menu.view_changes"
|
|
|
|
@action={{this.viewChanges}}
|
|
|
|
class="btn-flat view-changes"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<DButton
|
|
|
|
@icon="undo"
|
|
|
|
@label="discourse_ai.ai_helper.context_menu.revert"
|
|
|
|
@action={{this.undoAIAction}}
|
|
|
|
class="btn-flat revert"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<DButton
|
|
|
|
@icon="check"
|
|
|
|
@label="discourse_ai.ai_helper.context_menu.confirm"
|
|
|
|
@action={{this.confirmChanges}}
|
|
|
|
class="btn-flat confirm"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2023-08-23 13:35:40 -04:00
|
|
|
{{else if (eq this.menuState this.CONTEXT_MENU_STATES.resets)}}
|
|
|
|
<ul class="ai-helper-context-menu__resets">
|
|
|
|
<li>
|
|
|
|
<DButton
|
|
|
|
@icon="undo"
|
|
|
|
@label="discourse_ai.ai_helper.context_menu.undo"
|
|
|
|
@action={{this.undoAIAction}}
|
|
|
|
class="btn-flat undo"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<DButton
|
|
|
|
@icon="discourse-sparkles"
|
|
|
|
@label="discourse_ai.ai_helper.context_menu.regen"
|
|
|
|
@action={{this.updateSelected}}
|
|
|
|
@actionParam={{this.lastUsedOption}}
|
|
|
|
class="btn-flat"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
2023-08-24 20:49:24 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{{#if this.showDiffModal}}
|
|
|
|
<Modal::DiffModal
|
|
|
|
@confirm={{this.confirmChanges}}
|
|
|
|
@diff={{this.diff}}
|
|
|
|
@oldValue={{this.selectedText}}
|
|
|
|
@newValue={{this.newSelectedText}}
|
|
|
|
@closeModal={{fn (mut this.showDiffModal) false}}
|
|
|
|
/>
|
|
|
|
{{/if}}
|