DEV: Use the new bulk topic actions api (#491)
This commit is contained in:
parent
43cb34c698
commit
458306fa6b
|
@ -0,0 +1,19 @@
|
||||||
|
<div>
|
||||||
|
<AssignUserForm
|
||||||
|
@model={{this.model}}
|
||||||
|
@onSubmit={{this.assign}}
|
||||||
|
@formApi={{this.formApi}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<DButton
|
||||||
|
class="btn-primary"
|
||||||
|
@action={{this.formApi.submit}}
|
||||||
|
@label={{if
|
||||||
|
this.model.reassign
|
||||||
|
"discourse_assign.reassign.title"
|
||||||
|
"discourse_assign.assign_modal.assign"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
|
@ -0,0 +1,20 @@
|
||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
|
export default class AssignUser extends Component {
|
||||||
|
model = {};
|
||||||
|
|
||||||
|
// `submit` property will be mutated by the `AssignUserForm` component
|
||||||
|
formApi = {
|
||||||
|
submit() {},
|
||||||
|
};
|
||||||
|
|
||||||
|
@action
|
||||||
|
async assign() {
|
||||||
|
return this.args.performAndRefresh({
|
||||||
|
type: "assign",
|
||||||
|
username: this.model.username,
|
||||||
|
note: this.model.note,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,13 +8,11 @@ import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import SearchAdvancedOptions from "discourse/components/search-advanced-options";
|
import SearchAdvancedOptions from "discourse/components/search-advanced-options";
|
||||||
import TopicButtonAction, {
|
|
||||||
addBulkButton,
|
|
||||||
} from "discourse/controllers/topic-bulk-actions";
|
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown";
|
import { registerTopicFooterDropdown } from "discourse/lib/register-topic-footer-dropdown";
|
||||||
import RawHtml from "discourse/widgets/raw-html";
|
import RawHtml from "discourse/widgets/raw-html";
|
||||||
|
import BulkAssign from "../components/bulk-actions/assign-user";
|
||||||
|
|
||||||
const PLUGIN_ID = "discourse-assign";
|
const PLUGIN_ID = "discourse-assign";
|
||||||
|
|
||||||
|
@ -912,30 +910,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
TopicButtonAction.reopen({
|
|
||||||
actions: {
|
|
||||||
showReAssign() {
|
|
||||||
const controller = getOwner(this).lookup("controller:bulk-assign");
|
|
||||||
controller.set("model", { username: "", note: "" });
|
|
||||||
this.send("changeBulkTemplate", "modal/bulk-assign");
|
|
||||||
},
|
|
||||||
|
|
||||||
unassignTopics() {
|
|
||||||
this.performAndRefresh({ type: "unassign" });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
addBulkButton("showReAssign", "assign", {
|
|
||||||
icon: "user-plus",
|
|
||||||
class: "btn-default assign-topics",
|
|
||||||
});
|
|
||||||
|
|
||||||
addBulkButton("unassignTopics", "unassign", {
|
|
||||||
icon: "user-times",
|
|
||||||
class: "btn-default unassign-topics",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
withPluginApi("0.13.0", (api) => {
|
withPluginApi("0.13.0", (api) => {
|
||||||
|
@ -953,6 +927,58 @@ export default {
|
||||||
api.addGroupPostSmallActionCode("unassigned_group_from_post");
|
api.addGroupPostSmallActionCode("unassigned_group_from_post");
|
||||||
|
|
||||||
api.addUserSearchOption("assignableGroups");
|
api.addUserSearchOption("assignableGroups");
|
||||||
|
|
||||||
|
if (api.addBulkActionButton) {
|
||||||
|
api.addBulkActionButton({
|
||||||
|
label: "topics.bulk.assign",
|
||||||
|
icon: "user-plus",
|
||||||
|
class: "btn-default assign-topics",
|
||||||
|
action({ setComponent }) {
|
||||||
|
setComponent(BulkAssign);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
api.addBulkActionButton({
|
||||||
|
label: "topics.bulk.unassign",
|
||||||
|
icon: "user-times",
|
||||||
|
class: "btn-default unassign-topics",
|
||||||
|
action({ performAndRefresh }) {
|
||||||
|
performAndRefresh({ type: "unassign" });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// TODO: Remove this path after core 3.1.0.beta7 is released
|
||||||
|
const {
|
||||||
|
default: TopicButtonAction,
|
||||||
|
addBulkButton,
|
||||||
|
} = require("discourse/controllers/topic-bulk-actions");
|
||||||
|
|
||||||
|
TopicButtonAction.reopen({
|
||||||
|
actions: {
|
||||||
|
showReAssign() {
|
||||||
|
const controller = getOwner(this).lookup(
|
||||||
|
"controller:bulk-assign"
|
||||||
|
);
|
||||||
|
controller.set("model", { username: "", note: "" });
|
||||||
|
this.send("changeBulkTemplate", "modal/bulk-assign");
|
||||||
|
},
|
||||||
|
|
||||||
|
unassignTopics() {
|
||||||
|
this.performAndRefresh({ type: "unassign" });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
addBulkButton("showReAssign", "assign", {
|
||||||
|
icon: "user-plus",
|
||||||
|
class: "btn-default assign-topics",
|
||||||
|
});
|
||||||
|
|
||||||
|
addBulkButton("unassignTopics", "unassign", {
|
||||||
|
icon: "user-times",
|
||||||
|
class: "btn-default unassign-topics",
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue