Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Modernise assignment topic-list implementation #510

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions .github/workflows/discourse-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ on:
jobs:
ci:
uses: discourse/.github/.github/workflows/discourse-plugin.yml@v1
with:
core_ref: render-glimmer-raw
18 changes: 17 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
{}
{
"plugins": ["prettier-plugin-ember-template-tag"],
"overrides": [
{
"files": "*.gjs",
"options": {
"parser": "ember-template-tag"
}
},
{
"files": "*.gts",
"options": {
"parser": "ember-template-tag"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<Textarea
id="assign-modal-note"
@value={{@model.note}}
{{! template-lint-disable no-down-event-binding }}
{{on "keydown" this.handleTextAreaKeydown}}
/>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Component from "@glimmer/component";
import AssignActionsDropdown from "./assign-actions-dropdown";
import { inject as service } from "@ember/service";
import { action } from "@ember/object";

export default class AssignedTopicListColumn_Test extends Component {
<template>
<td class="topic-list-data">
{{#if @topic.assigned_to_user}}
<AssignActionsDropdown
@topic={{@topic}}
@assignee={{@topic.assigned_to_user.username}}
@unassign={{this.unassign}}
@reassign={{this.reassign}}
/>
{{else if @topic.assigned_to_group}}
<AssignActionsDropdown
@topic={{@topic}}
@assignee={{@topic.assigned_to_group.name}}
@group={{true}}
@unassign={{this.unassign}}
@reassign={{this.reassign}}
/>
{{else}}
<AssignActionsDropdown @topic={{@topic}} @unassign={{this.unassign}} />
{{/if}}
</td>
</template>

@service taskActions;
@service router;

@action
async unassign(targetId, targetType = "Topic") {
await this.taskActions.unassign(targetId, targetType);
this.router.refresh();
}

@action
reassign(topic) {
this.taskActions.showAssignModal(topic, {
onSuccess: () => this.router.refresh(),
});
}
}

This file was deleted.

This file was deleted.

46 changes: 0 additions & 46 deletions assets/javascripts/discourse/components/assigned-topic-list.hbs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{raw "assign-topic-buttons" topic=context.topic}}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { action } from "@ember/object";

export default class GroupAssignedShow extends UserTopicsList {
@service taskActions;
@service router;
@controller user;

queryParams = ["order", "ascending", "search"];
Expand Down Expand Up @@ -45,13 +46,13 @@ export default class GroupAssignedShow extends UserTopicsList {
@action
async unassign(targetId, targetType = "Topic") {
await this.taskActions.unassign(targetId, targetType);
this.send("changeAssigned");
this.router.refresh();
}

@action
reassign(topic) {
this.taskActions.showAssignModal(topic, {
onSuccess: () => this.send("changeAssigned"),
onSuccess: () => this.router.refresh(),
});
}

Expand Down
13 changes: 0 additions & 13 deletions assets/javascripts/discourse/controllers/user-activity-assigned.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ export default class UserActivityAssigned extends UserTopicsList {
});
}

@action
async unassign(targetId, targetType = "Topic") {
await this.taskActions.unassign(targetId, targetType);
this.send("changeAssigned");
}

@action
reassign(topic) {
this.taskActions.showAssignModal(topic, {
onSuccess: () => this.send("changeAssigned"),
});
}

@action
changeSort(sortBy) {
if (sortBy === this.order) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{{view.html}}}
21 changes: 21 additions & 0 deletions assets/javascripts/discourse/raw-views/assign-topic-buttons.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import EmberObject from "@ember/object";
import rawRenderGlimmer from "discourse/lib/raw-render-glimmer";
import AssignedTopicListColumn from "../components/assigned-topic-list-column";
import { inject as service } from "@ember/service";

const ASSIGN_LIST_ROUTES = ["userActivity.assigned", "group.assigned.show"];

export default class extends EmberObject {
@service router;

get html() {
if (ASSIGN_LIST_ROUTES.includes(this.router.currentRouteName)) {
return rawRenderGlimmer(
this,
"div.assign-topic-buttons",
<template><AssignedTopicListColumn @topic={{@data.topic}} /></template>,
{ topic: this.topic }
);
}
}
}
10 changes: 0 additions & 10 deletions assets/javascripts/discourse/routes/group-assigned-show.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import DiscourseRoute from "discourse/routes/discourse";
import { findOrResetCachedTopicList } from "discourse/lib/cached-topic-list";

export default class GroupAssignedShow extends DiscourseRoute {
beforeModel(transition) {
if (transition.from?.localName === "show") {
this.session.set("topicListScrollPosition", 1);
}
}

model(params) {
let filter;
if (["everyone", this.modelFor("group").name].includes(params.filter)) {
Expand Down Expand Up @@ -36,8 +30,4 @@ export default class GroupAssignedShow extends DiscourseRoute {
search: this.currentModel.params.search,
});
}

renderTemplate() {
this.render("group-topics-list");
}
}
5 changes: 0 additions & 5 deletions assets/javascripts/discourse/routes/group-assigned.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ export default class GroupAssigned extends DiscourseRoute {
this.transitionTo("group.assigned.show", "everyone");
}
}

@action
changeAssigned() {
this.refresh();
}
}
5 changes: 0 additions & 5 deletions assets/javascripts/discourse/routes/user-activity-assigned.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@ export default class UserActivityAssigned extends UserTopicListRoute {
titleToken() {
return I18n.t("discourse_assign.assigned");
}

@action
changeAssigned() {
this.refresh();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@selector=".paginated-topics-list .topic-list tr"
@action={{action "loadMore"}}
>
<BasicAssignedTopicList
<BasicTopicList
@topicList={{this.model}}
@hideCategory={{this.hideCategory}}
@showPosters={{this.showPosters}}
Expand Down
Loading