Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UX: add bulk-select to mobile topic lists (#15386)
- Loading branch information
1 parent
5894e7d
commit b5c1132
Showing
12 changed files
with
271 additions
and
26 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/assets/javascripts/discourse/app/components/bulk-select-toggle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Component from "@ember/component"; | ||
import { action } from "@ember/object"; | ||
import { getOwner } from "discourse-common/lib/get-owner"; | ||
|
||
export default Component.extend({ | ||
parentController: null, | ||
|
||
@action | ||
toggleBulkSelect() { | ||
const controller = getOwner(this).lookup( | ||
`controller:${this.parentController}` | ||
); | ||
const selection = controller.selected; | ||
controller.toggleProperty("bulkSelectEnabled"); | ||
selection.clear(); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
app/assets/javascripts/discourse/app/templates/components/bulk-select-toggle.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<DButton @class={{"bulk-select"}} @action={{action "toggleBulkSelect"}} @icon={{"list"}} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 15 additions & 18 deletions
33
app/assets/javascripts/discourse/app/templates/components/topic-list.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
app/assets/javascripts/discourse/app/templates/mobile/list/topic-list-item.hbr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
app/assets/javascripts/discourse/tests/acceptance/mobile-topic-bulk-actions-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { | ||
acceptance, | ||
invisible, | ||
query, | ||
queryAll, | ||
updateCurrentUser, | ||
} from "discourse/tests/helpers/qunit-helpers"; | ||
import { click, visit } from "@ember/test-helpers"; | ||
import { test } from "qunit"; | ||
import I18n from "I18n"; | ||
|
||
acceptance("Topic - Bulk Actions - Mobile", function (needs) { | ||
needs.user(); | ||
needs.mobileView(); | ||
|
||
needs.settings({ tagging_enabled: true }); | ||
needs.pretender((server, helper) => { | ||
server.put("/topics/bulk", () => { | ||
return helper.response({ | ||
topic_ids: [], | ||
}); | ||
}); | ||
}); | ||
|
||
test("bulk select - modal", async function (assert) { | ||
updateCurrentUser({ moderator: true, enable_defer: true }); | ||
await visit("/latest"); | ||
await click("button.bulk-select"); | ||
|
||
await click(queryAll("input.bulk-select")[0]); | ||
await click(queryAll("input.bulk-select")[1]); | ||
|
||
await click(".bulk-select-actions"); | ||
|
||
assert.ok( | ||
query("#discourse-modal-title").innerHTML.includes( | ||
I18n.t("topics.bulk.actions") | ||
), | ||
"it opens bulk-select modal" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.change_category") | ||
), | ||
"it shows an option to change category" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.close_topics") | ||
), | ||
"it shows an option to close topics" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.archive_topics") | ||
), | ||
"it shows an option to archive topics" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.notification_level") | ||
), | ||
"it shows an option to update notification level" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes(I18n.t("topics.bulk.defer")), | ||
"it shows an option to reset read" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.unlist_topics") | ||
), | ||
"it shows an option to unlist topics" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.reset_bump_dates") | ||
), | ||
"it shows an option to reset bump dates" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.change_tags") | ||
), | ||
"it shows an option to replace tags" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.append_tags") | ||
), | ||
"it shows an option to append tags" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes( | ||
I18n.t("topics.bulk.remove_tags") | ||
), | ||
"it shows an option to remove all tags" | ||
); | ||
|
||
assert.ok( | ||
query(".bulk-buttons").innerHTML.includes(I18n.t("topics.bulk.delete")), | ||
"it shows an option to delete topics" | ||
); | ||
}); | ||
|
||
test("bulk select - delete topics", async function (assert) { | ||
updateCurrentUser({ moderator: true }); | ||
await visit("/latest"); | ||
await click("button.bulk-select"); | ||
|
||
await click(queryAll("input.bulk-select")[0]); | ||
await click(queryAll("input.bulk-select")[1]); | ||
|
||
await click(".bulk-select-actions"); | ||
await click(".modal-body .delete-topics"); | ||
|
||
assert.ok( | ||
invisible(".topic-bulk-actions-modal"), | ||
"it closes the bulk select modal" | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters