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

FEATURE: Add buttons for unassigning from posts to the topic level assign menu #554

Conversation

AndrewPrigorshnev
Copy link
Contributor

@AndrewPrigorshnev AndrewPrigorshnev commented Mar 20, 2024

Before, we only had buttons for assigning and unassigning topic on this menu:

Screenshot 2024-03-22 at 20 21 48

This PR adds dynamic buttons for unassigning posts to the menu:

Screenshot 2024-03-23 at 18 05 16

@AndrewPrigorshnev AndrewPrigorshnev force-pushed the feature/add-buttons-for-unassigning-from-posts-to-the-topic-level-assign-menu branch 4 times, most recently from d2ab473 to e0d3e6b Compare March 23, 2024 21:03
@AndrewPrigorshnev AndrewPrigorshnev marked this pull request as ready for review March 23, 2024 21:12
@AndrewPrigorshnev
Copy link
Contributor Author

AndrewPrigorshnev commented Mar 23, 2024

cc @chapoi styles – ac75719

margins on d-icon make icons and avatars on the menu play well together:

Screenshot 2024-03-24 at 01 19 28

@@ -15,6 +15,7 @@ import { iconHTML, iconNode } from "discourse-common/lib/icon-library";
import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
import BulkAssign from "../components/bulk-actions/assign-user";
import TopicLevelAssignMenu from "../lib/topic-level-assign-menu";
Copy link
Contributor

@jjaffeux jjaffeux Mar 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could put this in /components? It feels more like a component than a lib.

Maybe it will cause an issue for now though, if we don't export a component, not sure.

Copy link
Contributor Author

@AndrewPrigorshnev AndrewPrigorshnev Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this makes sense. We usually put such classes into the lib folder, but I agree that the components folder is a better place for it, even though technically speaking it's not an Ember component. I moved it into components/ and everything seem to work fine.

@@ -917,7 +828,7 @@ export default {
}

withPluginApi("0.13.0", (api) => {
includeIsAssignedOnTopic(api);
extendTopicModel(api);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the name change here 👍

@@ -0,0 +1,227 @@
import { getOwner } from "@ember/application";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point me the new code here please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry, it should be difficult to distinguish where is the old code and where the implementation of the new buttons. I extracted commits with refactoring and the new code. So now you can review it separately:

  1. REFACTOR: Extract topic level assign menu code into separate file
  2. REFACTOR: Extract methods (nothing new was added on this stage, I've just extracted some methods to make further changes easier)
  3. Implement

@AndrewPrigorshnev AndrewPrigorshnev force-pushed the feature/add-buttons-for-unassigning-from-posts-to-the-topic-level-assign-menu branch 3 times, most recently from 781c7a6 to 1ca5dfa Compare March 26, 2024 19:15
Comment on lines +58 to +60
const map = new Map();
this.assignees().forEach((user) => map.set(user.username, user));
return [...map.values()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be a one-liner?

Suggested change
const map = new Map();
this.assignees().forEach((user) => map.set(user.username, user));
return [...map.values()];
return [...new Set(this.assignees().map((u) => u.username))];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your version of code does another thing. We need to return an array of unique assignee objects here, while your one-liner returns an array of unique usernames.

@AndrewPrigorshnev AndrewPrigorshnev force-pushed the feature/add-buttons-for-unassigning-from-posts-to-the-topic-level-assign-menu branch from 1ca5dfa to c4ec0b4 Compare March 29, 2024 11:58
@AndrewPrigorshnev AndrewPrigorshnev merged commit 2676522 into main Mar 29, 2024
5 checks passed
@AndrewPrigorshnev AndrewPrigorshnev deleted the feature/add-buttons-for-unassigning-from-posts-to-the-topic-level-assign-menu branch March 29, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants