Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 45f368e

Browse files
committed
render modal without a service
1 parent 5b5c38c commit 45f368e

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

assets/javascripts/discourse/components/ai-llm-editor-form.gjs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export default class AiLlmEditorForm extends Component {
2323
@service toasts;
2424
@service router;
2525
@service dialog;
26-
@service modal;
2726

2827
@tracked isSaving = false;
2928

@@ -33,6 +32,8 @@ export default class AiLlmEditorForm extends Component {
3332
@tracked apiKeySecret = true;
3433
@tracked quotaCount = 0;
3534

35+
@tracked modalIsVisible = false;
36+
3637
constructor() {
3738
super(...arguments);
3839
this.updateQuotaCount();
@@ -108,9 +109,7 @@ export default class AiLlmEditorForm extends Component {
108109

109110
@action
110111
openAddQuotaModal() {
111-
this.modal.show(AiLlmQuotaModal, {
112-
model: { llm: this.args.model, onSave: this.updateQuotaCount },
113-
});
112+
this.modalIsVisible = true;
114113
}
115114

116115
@computed("args.model.provider")
@@ -197,6 +196,12 @@ export default class AiLlmEditorForm extends Component {
197196
});
198197
}
199198

199+
@action
200+
closeAddQuotaModal() {
201+
this.modalIsVisible = false;
202+
this.updateQuotaCount();
203+
}
204+
200205
<template>
201206
{{#if this.seeded}}
202207
<div class="alert alert-info">
@@ -369,6 +374,12 @@ export default class AiLlmEditorForm extends Component {
369374
@label="discourse_ai.llms.quotas.add"
370375
class="btn"
371376
/>
377+
{{#if this.modalIsVisible}}
378+
<AiLlmQuotaModal
379+
@model={{(hash llm=@model)}}
380+
@closeModal={{this.closeAddQuotaModal}}
381+
/>
382+
{{/if}}
372383
{{/if}}
373384
<DButton
374385
class="btn-primary ai-llm-editor__save"

assets/javascripts/discourse/components/ai-llm-quota-editor.gjs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Component from "@glimmer/component";
22
import { tracked } from "@glimmer/tracking";
3-
import { fn } from "@ember/helper";
3+
import { fn, hash } from "@ember/helper";
44
import { on } from "@ember/modifier";
55
import { action } from "@ember/object";
66
import { service } from "@ember/service";
@@ -13,12 +13,12 @@ export default class AiLlmQuotaEditor extends Component {
1313
@service store;
1414
@service dialog;
1515
@service site;
16-
@service modal;
1716

1817
@tracked newQuotaGroupIds = null;
1918
@tracked newQuotaTokens = null;
2019
@tracked newQuotaUsages = null;
2120
@tracked newQuotaDuration = 86400; // 1 day default
21+
@tracked modalIsVisible = false;
2222

2323
@action
2424
updateExistingQuotaTokens(quota, event) {
@@ -37,9 +37,7 @@ export default class AiLlmQuotaEditor extends Component {
3737

3838
@action
3939
openAddQuotaModal() {
40-
this.modal.show(AiLlmQuotaModal, {
41-
model: { llm: this.args.model },
42-
});
40+
this.modalIsVisible = true;
4341
}
4442

4543
get canAddQuota() {
@@ -94,6 +92,11 @@ export default class AiLlmQuotaEditor extends Component {
9492
}
9593
}
9694

95+
@action
96+
closeAddQuotaModal() {
97+
this.modalIsVisible = false;
98+
}
99+
97100
<template>
98101
<div class="ai-llm-quotas">
99102
<table class="ai-llm-quotas__table">
@@ -162,6 +165,13 @@ export default class AiLlmQuotaEditor extends Component {
162165
@label="discourse_ai.llms.quotas.add"
163166
class="btn"
164167
/>
168+
169+
{{#if this.modalIsVisible}}
170+
<AiLlmQuotaModal
171+
@model={{(hash llm=@model)}}
172+
@closeModal={{this.closeAddQuotaModal}}
173+
/>
174+
{{/if}}
165175
</div>
166176
</div>
167177
</template>

0 commit comments

Comments
 (0)