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

Fix:the user name in inline comments section is followed by some internal code which should be omitted in UI [SDESK-6685] #4161

Merged
merged 6 commits into from
Dec 21, 2022

Conversation

devketanpro
Copy link
Member

No description provided.

…rnal code which should be omitted in UI [SDESK-6685]
@petrjasek petrjasek modified the milestones: 2.7, 2.6 Dec 16, 2022
@tomaskikutis
Copy link
Member

Did you manage to reproduce it? If so where? I tried on sd-develop, but couldn't.

@devketanpro
Copy link
Member Author

Did you manage to reproduce it? If so where? I tried on sd-develop, but couldn't.

it is reproduced on the sd-develop, I shared the snapvideo please check.

https://www.awesomescreenshot.com/video/13342665?key=feb1b50cb31e7ab975577ebcba9a10ed

@tomaskikutis
Copy link
Member

I see. I was looking at article comments.

One issue with your approach is that if there is text after the mention it is not shown.

Another thing, is that mentions should be displayed like this. There is code already in article comments that is doing the extraction of user ID and name. Could you reuse it and make editor comments look the same?

@@ -13,7 +13,7 @@ const mentionRegexp = /@\[([^\]]+)\]\((desk|user):([^\)]+)\)/g;
* @description Displays a text containing mentions.
*/
export const TextWithMentions: React.StatelessComponent<any> = ({children, ...props}) => {
const msg = children;
const msg = props.data ? props.data : children;
Copy link
Member

Choose a reason for hiding this comment

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

can you add TypeScript types to props of this component?

Given children can only be a string and that there's only one usage of the component, it'd be better to use a standard prop like message: string. We'd then get better enforcement of types by TypeScript and it would work well with angular too without the need to accept the same data via 2 props like now.

@@ -11,7 +11,8 @@ <h4 class="label">{{commentObj.fieldName}}</h4>
<div class="flex-row sibling-spacer-10">
<sd-user-avatar data-user="users[item.data.authorId]"></sd-user-avatar>
<div>
<div class="text" sd-comment-text data-name="{{users[item.data.authorId].display_name || users[item.data.authorId].username}}" data-text="{{item.data.msg.split('(user:')[0]}}"></div>
<b>{{users[item.data.authorId].display_name || users[item.data.authorId].username}}:</b>
Copy link
Member

Choose a reason for hiding this comment

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

Can we modify the back-end so display_name defaults to username if not provided. Isn't it already like that @petrjasek ?

Copy link
Member

Choose a reason for hiding this comment

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

it should be like that already

Copy link
Member

Choose a reason for hiding this comment

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

great, then you can remove the fallback @devketanpro

@petrjasek petrjasek modified the milestones: 2.6, 2.7 Dec 20, 2022

export interface ITextWithMention {
message: string;
props: any;
Copy link
Member

Choose a reason for hiding this comment

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

props isn't used anywhere, you should remove it. Also since we now have a TypeScript interface, we no longer need propTypes for this component, do remove it. Regarding naming, we have a convention to use IProps/IState for interfaces used for react component props/state - let's stick to that here too.

export interface IProps {
message: string;
}
export const TextWithMentions: React.StatelessComponent<any> = ({message, ...props}: IProps) => {
Copy link
Member

Choose a reason for hiding this comment

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

props isn't used anywhere, you should remove it

React.StatelessComponent<any> = ({message, ...props}
//                                            ^ I meant from everywhere, not only interface

Copy link
Member Author

Choose a reason for hiding this comment

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

I was about to remove it but then I thought if anyone pass other prop than message then it would be wrong.

Copy link
Member

Choose a reason for hiding this comment

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

The interface won't allow passing any other prop than message. If someone wanted to pass anything else then they would add it everywhere - to the interface and to implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, so I will remove it.

@devketanpro devketanpro merged commit 501f6c8 into superdesk:develop Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants