Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Controller from "@ember/controller";
import { action } from "@ember/object";
import { getOwner } from "@ember/owner";
import { service } from "@ember/service";
import { TrackedArray } from "@ember-compat/tracked-built-ins";
import { popupAjaxError } from "discourse/lib/ajax-error";
import UppyUpload from "discourse/lib/uppy/uppy-upload";
import UppyMediaOptimization from "discourse/lib/uppy-media-optimization-plugin";
Expand All @@ -15,7 +16,7 @@ export default class DiscourseAiBotConversations extends Controller {
@service site;
@service siteSettings;

@tracked uploads = [];
@tracked uploads = new TrackedArray();
// Don't track this directly - we'll get it from uppyUpload

textarea = null;
Expand Down Expand Up @@ -46,8 +47,6 @@ export default class DiscourseAiBotConversations extends Controller {
init() {
super.init(...arguments);

this.uploads = [];

this.uppyUpload = new UppyUpload(getOwner(this), {
id: "ai-bot-file-uploader",
type: "ai-bot-conversation",
Expand Down Expand Up @@ -85,7 +84,7 @@ export default class DiscourseAiBotConversations extends Controller {
},

uploadDone: (upload) => {
this.uploads.pushObject(upload);
this.uploads.push(upload);
},

// Fix: Don't try to set inProgressUploads directly
Expand Down Expand Up @@ -162,7 +161,7 @@ export default class DiscourseAiBotConversations extends Controller {

@action
removeUpload(upload) {
this.uploads.removeObject(upload);
this.uploads = new TrackedArray(this.uploads.filter((u) => u !== upload));
}

@action
Expand All @@ -178,7 +177,7 @@ export default class DiscourseAiBotConversations extends Controller {
this.aiBotConversationsHiddenSubmit.uploads = this.uploads;
try {
await this.aiBotConversationsHiddenSubmit.submitToBot();
this.uploads.clear();
this.uploads = new TrackedArray();
} catch (error) {
popupAjaxError(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default RouteTemplate(
<DButton
@icon="xmark"
@action={{fn @controller.cancelUpload upload}}
class="btn-flat ai-bot-upload__remove"
class="btn-flat ai-bot-upload__cancel"
/>
</div>
{{/each}}
Expand Down
3 changes: 0 additions & 3 deletions spec/system/ai_bot/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,13 @@
end

it "allows removing an upload before submission" do
skip "TODO: fix this test for playwright"

ai_pm_homepage.visit
expect(ai_pm_homepage).to have_homepage

file_path = file_from_fixtures("logo.png", "images").path
attach_file([file_path]) { find(".ai-bot-upload-btn", visible: true).click }
expect(page).to have_css(".ai-bot-upload", count: 1)

# TODO: for some reason this line fails in playwright
find(".ai-bot-upload__remove").click

expect(page).to have_no_css(".ai-bot-upload")
Expand Down
Loading