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

Possibility to tag people! #86

Open
antoniomuso opened this issue Aug 3, 2023 · 16 comments
Open

Possibility to tag people! #86

antoniomuso opened this issue Aug 3, 2023 · 16 comments
Labels
enhancement New feature or request

Comments

@antoniomuso
Copy link
Contributor

antoniomuso commented Aug 3, 2023

What do you think about the feature of tagging people?

USE CASE:
Typing a Question/Answer you can use @persone with suggestions to tag a person. The tag could be an event in EventBroker. Currently, there are these action kinds:

type Action =
  | 'comment_answer'
  | 'correct_answer'
  | 'incorrect_answer'
  | 'post_question'
  | 'comment_question'
  | 'vote_question'
  | 'post_answer'
  | 'vote_answer';

We can add to these the tag Action! WDYT?

@drodil
Copy link
Owner

drodil commented Aug 3, 2023

Would make more sense if Backstage had some sort of notification support. Sure, this could be done now using the broker and let app developers handle it themselves and later, if the notification support comes along, extend also to it.

On the other thought, why should this only be limited to users? I think tagging groups would also be a nice thing.

Don't know how hard it is to implement to be honest, but if you want to give it a try, you are most welcome to do so :) If you don't have time for that, I may take a look at some point.

How does this sound?

@drodil drodil added the enhancement New feature or request label Aug 4, 2023
@antoniomuso
Copy link
Contributor Author

LGTM! I am on vacation now. When I come back, I will take a look!

@drodil
Copy link
Owner

drodil commented Jan 11, 2024

Hey @antoniomuso !

Do you have any new thoughts about this? I would really like to have something like this in place especially when the new notifications plugin is under way in the backstage project. Do you have any ideas if there's ready made UI component to show suggestions for tagging? In the backend side I don't think this is very hard to accomplish

@antoniomuso
Copy link
Contributor Author

Hi @drodil, I didn't research on that. I don't think some UI component exists, but it is simple to handle using Entity catalog Api useApi(catalogApiRef) using the .queryEntities(..) method.

@drodil
Copy link
Owner

drodil commented Jan 11, 2024

Yeah @antoniomuso it's simple to fetch the users, only problem is how it could work in the UI like it does for example here on GitHub when mentioning someone. Maybe it also requires that backend has to parse the user entities from the content to add the tags.

This also highly relates to #61 because without notifications there's not much sense to tag anyone.

@antoniomuso
Copy link
Contributor Author

With API, you can query and get all the users starting with characters you pass as input.

   /**
     * Gets paginated entities from the catalog.
     *
     * @remarks
     *
     * @example
     *
     * ```
     * const response = await catalogClient.queryEntities({
     *   filter: [{ kind: 'group' }],
     *   limit: 20,
     *   fullTextFilter: {
     *     term: 'A',
     *   }
     *   orderFields: { field: 'metadata.name' order: 'asc' },
     * });
     * ```
     *
     * this will match all entities of type group having a name starting
     * with 'A', ordered by name ascending.
     *
     * The response will contain a maximum of 20 entities. In case
     * more than 20 entities exist, the response will contain a nextCursor
     * property that can be used to fetch the next batch of entities.
     *
     * ```
     * const secondBatchResponse = await catalogClient
     *  .queryEntities({ cursor: response.nextCursor });
     * ```
     *
     * secondBatchResponse will contain the next batch of (maximum) 20 entities,
     * together with a prevCursor property, useful to fetch the previous batch.
     *
     * @public
     *
     * @param request - Request parameters
     * @param options - Additional options
     */
    queryEntities(request?: QueryEntitiesRequest, options?: CatalogRequestOptions): Promise<QueryEntitiesResponse>;
   

@antoniomuso
Copy link
Contributor Author

In my instance, I had implemented the notification system thanks to the Action events.

@kedaroh-bh
Copy link
Contributor

Hi @drodil,
I can see the react-mde which is used for MarkdownEditor now has support to load suggestions which will trigger on typing specified character (@), though it do not provide much options for UI customization but solves our need, below is quick try out screenshot.

Need your views on saving it to DB or just get it from content and notify them ?

image

@drodil
Copy link
Owner

drodil commented Jun 4, 2024

I think it would be enough to just get it from the content and introduce a function for getting an array of entity refs starting with @ from the content in the qeta-common package so that it can be used in both the frontend and backend. It requires a lot more effort to save them to own table separately and then update them if the content changes. Also, there needs to be support to render links to the entities in content for these mentions (probably best to use the EntityRefLink component if possible). And, additionally we need support for the events service as mentioned in the original description of this issue. But other than that, I think the react-mde way is the easiest and a good way forward.

Are you using the queryEntities to find the users/groups like @antoniomuso described in one of the comments?

@kedaroh-bh
Copy link
Contributor

kedaroh-bh commented Jun 4, 2024

yes, using catalogApi.queryEntities.

Agree to not save in DB as not much use of it other than notification, one use case I can see is filtering question which has logged in user mentioned.

@drodil
Copy link
Owner

drodil commented Jun 4, 2024

Yeah, that could be one use case. If it's not too much trouble to save those in DB, maybe we should do that then? Anyways we need to parse the entities from the content. And what comes to the filtering, maybe there could be a new checkbox filter related to me or something that would search for questions with mentions to current users ownershipEntityRefs; just to get also the user's groups included in the filter. But again, the filtering can be done later.

@kedaroh-bh
Copy link
Contributor

I would like to work on this, please check below things and let me know if missing anything:

  1. Implement loadSuggestion option from react-mde, and loading users and groups using catalogApi.queryEntities with text filtering.
  2. Show entityRef string once selected (for default namespace just display metadata.name, for other show entityRef :/)
  3. In preview render mention as link which will redirect to user/group page
  4. Create utility method in common package to extract mentions.
  5. Backend create new table for "mentions" with entityRef and reference to questionId and answerId.
  6. Save mention, delete old.
  7. trigger notification
  8. While updating question and answer, remove old mentions and create new.

@drodil
Copy link
Owner

drodil commented Jun 5, 2024

Awesome, sounds like a plan. Some thoughts:

  1. I think it makes sense to use the complete entityRef for all entities just to be able to distinguish groups and users. It also makes it easier to extract and validate the mentions if they are complete entity references
  2. You probably need two new tables, one for questions and one for answers. So it should be something like question_mentions and answer_mentions. Comments are currently only using plain text field so there's no possibility to mention people in comments. Should this be changed also to use the react-mde, WDYT? This could also be done separately from this

Otherwise, it looks like it's ready for implementation! Thanks a lot again!

@drodil
Copy link
Owner

drodil commented Jun 5, 2024

Oh, another thing to point number 7: I think @antoniomuso also requested an event using the eventsService from mentions so that would be required too apart from the notification. Minor thing to add once the whole thing is working but something to keep in mind :)

@kedaroh-bh
Copy link
Contributor

Sure @drodil, I started working on it.

  1. Users from default namespace which will be mostly mentioned, so I think its good to show just metadata.name instead of whole ref string which is not that much readable, however this is just for display while saving we will save complete ref.
  2. Earlier I thought to create single table for both question and answer mention just like attachments but looks like long run it is not that much scalable. So we will use two different tables
  3. I haven't went much deep in event implementation so not much sure about it, but Event I will implement after of above implementation.

@drodil
Copy link
Owner

drodil commented Jun 10, 2024

Hi,
I'm just worried it's not possible to tag groups and distinguish them from users if you let the default namespace and entity kind out of the mention. I hope it would work for groups as well, WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants