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
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 scripts/apps/authoring/authoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {AuthoringTopbar2React} from './authoring-topbar2-react';
import {appConfig} from 'appConfig';
import {FullPreview} from '../preview/fullPreview';
import {sdApi} from 'api';
import {TextWithMentions} from 'apps/users/components';

export interface IOnChangeParams {
item: IArticle;
Expand Down Expand Up @@ -118,6 +119,7 @@ angular.module('superdesk.apps.authoring', [
.directive('sdPreviewFormatted', directive.PreviewFormattedDirective)
.directive('sdAuthoringContainer', directive.AuthoringContainerDirective)
.directive('sdAuthoringEmbedded', directive.AuthoringEmbeddedDirective)
.component('sdTextWithMentions', reactToAngular1(TextWithMentions, ['data']))
.directive('sdAuthoringHeader', directive.AuthoringHeaderDirective)
.directive('sdItemAssociation', directive.ItemAssociationDirective)
.directive('sdItemCarousel', directive.ItemCarouselDirective)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

<sd-text-with-mentions data="item.data.msg"></sd-text-with-mentions>
<span class="date" sd-absdate datetime="item.data.date"></span>
</div>
</div>
Expand All @@ -21,7 +22,8 @@ <h4 class="label">{{commentObj.fieldName}}</h4>
<div class="flex-row sibling-spacer-10">
<sd-user-avatar data-user="users[reply.authorId]"></sd-user-avatar>
<div>
<div class="text" sd-comment-text data-comment="comment" data-name="{{users[reply.authorId].display_name || users[reply.authorId].username}}" data-text="{{reply.msg.split('(user:')[0]}}"></div>
<b>{{users[reply.authorId].display_name || users[reply.authorId].username}}:</b>
<sd-text-with-mentions data="reply.msg"></sd-text-with-mentions>
<span class="date" sd-absdate datetime="reply.date"></span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion scripts/apps/users/components/TextWithMentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

const n = msg.length;

const r = []; // array of components to render
Expand Down