Skip to content

Commit 6727e32

Browse files
authored
FIX: edit button not working (#379)
After this PR <a> link stopped working correctly page started doing a full reload. <Button> component behaves correctly. #376
1 parent 85b485e commit 6727e32

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

assets/javascripts/discourse/templates/admin/plugins-explorer-queries-details.gjs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ export default RouteTemplate(
5959
/>
6060

6161
<h1>
62-
{{@controller.model.name}}
62+
<span>{{@controller.model.name}}</span>
6363
{{#unless @controller.editDisabled}}
64-
<a
65-
href
66-
{{on "click" @controller.editName}}
67-
class="edit-query-name"
68-
>
69-
{{icon "pencil"}}
70-
</a>
64+
<DButton
65+
@action={{@controller.editName}}
66+
@icon="pencil"
67+
class="edit-query-name btn-transparent"
68+
/>
7169
{{/unless}}
7270
</h1>
7371
</div>

assets/stylesheets/explorer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ table.group-reports {
215215
margin: 0 0.5em 0 0;
216216
color: var(--primary);
217217

218-
a {
218+
button .d-icon {
219219
color: currentcolor;
220220
}
221221
}

spec/system/explorer_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727

2828
expect(page).to have_field("limit", with: 42)
2929
end
30+
31+
it "allows to edit custom name" do
32+
visit("/admin/plugins/explorer/queries/#{query_1.id}")
33+
find(".query-run .btn-primary").click
34+
find(".edit-query-name").click
35+
find(".name-text-field input").fill_in(with: "My custom name edited")
36+
find(".btn-primary").click
37+
find("button span", text: "Save Changes and Run").click
38+
expect(page.find(".name h1")).to have_content("My custom name edited")
39+
end
3040
end
3141

3242
context "with the old url format" do

test/javascripts/acceptance/run-query-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ acceptance("Data Explorer Plugin | Run Query", function (needs) {
320320
await visit("/admin/plugins/explorer/queries/2");
321321

322322
assert
323-
.dom("div.name h1")
323+
.dom("div.name h1 span")
324324
.hasText("What about 0?", "the query name was rendered");
325325

326326
assert

0 commit comments

Comments
 (0)