Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

#753 Activity log - Make links instead of text in log message #869

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

NikolaSvobodova1983
Copy link

Resolves #753 Activity log - Make links instead of text in log message
Type: feature

Solution

LinkedCommentFormatter class adds the link to old activity log comment, already storing in DB.
It tries to find the comment's string pattern by system keyword, parses the comment, and changes the parameter of the comment to link.

LinkedCommentCreator class adding the link to the newly created activity log comment, which is about to insert to DB.
It uses comment's pattern, comment's parameters and activity log system keyword to create linked comment and store it to DB.

Links patterns to the entities are stored in ActivityEntityKeywordsProvider class.

Breaking changes

  1. CustomerActivityService.InsertActivity - on each invoke the method calls LinkedCommentCreator.CreateLinkedComment.
    In case CreateLinkedComment method throws an exception, it throws the exception further.

  2. Cshtml view files are changed so that the column 'comments' are not encoded anymore - so the link is shown in the correct way. May be not safe.

Testing

Added unit tests:
LinkedCommentFormatterTests
LinkedCommentCreatorTests

@NikolaSvobodova1983
Copy link
Author

Not sure, maybe it would be better to store all the links into the database.

This file should not be changed on this commit.
@PatrykPorabik
Copy link
Contributor

PatrykPorabik commented Jun 23, 2020

Hello @NikolaSvobodova1983

Thanks a lot for your contribution, however, I'm curious if it's not too complex and a complicated approach to this task. There is a lot of changes when I thought and expected to have a much simpler solution. I don't know if it's worth overall to implement such a lot of code, just to show links in Activity Log. We will think about that.

@NikolaSvobodova1983
Copy link
Author

NikolaSvobodova1983 commented Jun 23, 2020

Hello @NikolaSvobodova1983
Thanks a lot for your contribution, however, I'm curious if it's not too complex and a complicated approach to this task. There is a lot of changes when I thought and expected to have a much simpler solution. I don't know if it's worth overall to implement such a lot of code, just to show links in Activity Log. We will think about that.

Hello @PatrykPorabik
So my solution is actually consists of 2 parts - create the new Activity Log Comment as 'linked' (which is smaller part) + parse 'old' Activity Log Comment and combine it to the new comment which is linked (which is bigger, more complicated part).
In case you're ok with the fact that 'old' comments will be shown without links, and new comments will be shown with links, this code can be simplified.
Anyway, we need some place where I can store the pair 'ActivityLog system keyword - link url'. (like, f.e., 'EditProduct' - '\Admin\Product\Edit{0}')
Right now I'm storing it in code, but I can move it to the database and make the solution even smaller.
Please let me know if you need those improvements from me.
Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
GrandNode 4.80
  
Awaiting triage
2 participants