From c45392954498925b1b414ff6b49296817ea02981 Mon Sep 17 00:00:00 2001 From: Tomas Kikutis Date: Thu, 10 Aug 2023 16:04:17 +0200 Subject: [PATCH] Use custom avatars (#1839) --- .../AssignmentItem/AssignmentItem_test.tsx | 4 +- .../Assignments/AssignmentItem/index.tsx | 11 +- .../AssignmentPreviewHeader.tsx | 7 +- .../CoverageEditor/CoverageFormHeader.tsx | 14 +- client/components/Coverages/CoverageIcons.tsx | 8 +- client/components/Coverages/CoverageItem.tsx | 27 +--- .../LockContainer/LockContainerPopup.tsx | 4 +- client/components/LockContainer/index.tsx | 8 +- .../Form/SelectUserInput/SelectUserPopup.tsx | 6 +- .../UI/Form/SelectUserInput/index.tsx | 4 +- client/components/UserAvatar/index.tsx | 130 +++++++----------- client/components/index.ts | 1 - package-lock.json | 18 +-- package.json | 2 +- 14 files changed, 90 insertions(+), 154 deletions(-) diff --git a/client/components/Assignments/AssignmentItem/AssignmentItem_test.tsx b/client/components/Assignments/AssignmentItem/AssignmentItem_test.tsx index 87994f1ce..d61202109 100644 --- a/client/components/Assignments/AssignmentItem/AssignmentItem_test.tsx +++ b/client/components/Assignments/AssignmentItem/AssignmentItem_test.tsx @@ -8,7 +8,7 @@ import {Provider} from 'react-redux'; import * as helpers from '../../tests/helpers'; import {cloneDeep} from 'lodash'; import {AbsoluteDate} from '../../AbsoluteDate'; -import {UserAvatar} from '../../UserAvatar'; +import {UserAvatarWithMargin} from '../../UserAvatar'; describe('assignments', () => { describe('components', () => { @@ -101,7 +101,7 @@ describe('assignments', () => { const wrapper = getMountedWrapper(); expect(wrapper.find('.icon-time').length).toBe(1); - expect(wrapper.find(UserAvatar).length).toBe(1); + expect(wrapper.find(UserAvatarWithMargin).length).toBe(1); expect(wrapper.find(AbsoluteDate).length).toBe(1); }); diff --git a/client/components/Assignments/AssignmentItem/index.tsx b/client/components/Assignments/AssignmentItem/index.tsx index 7b70d304c..57b1a018d 100644 --- a/client/components/Assignments/AssignmentItem/index.tsx +++ b/client/components/Assignments/AssignmentItem/index.tsx @@ -20,7 +20,7 @@ import {ASSIGNMENTS, CLICK_DELAY} from '../../../constants'; import {getAssignmentTypeInfo} from '../../../utils/assignments'; import {Menu} from 'superdesk-ui-framework/react'; -import {UserAvatar} from '../../'; +import {UserAvatarWithMargin} from '../../../components/UserAvatar'; import {Item, Border, Column, Row} from '../../UI/List'; import {getComponentForField, getAssignmentsListView} from './fields'; @@ -217,14 +217,7 @@ export class AssignmentItem extends React.Component { return ( - + ); } diff --git a/client/components/Assignments/AssignmentPreviewContainer/AssignmentPreviewHeader.tsx b/client/components/Assignments/AssignmentPreviewContainer/AssignmentPreviewHeader.tsx index 48c863eda..93fc66a50 100644 --- a/client/components/Assignments/AssignmentPreviewContainer/AssignmentPreviewHeader.tsx +++ b/client/components/Assignments/AssignmentPreviewContainer/AssignmentPreviewHeader.tsx @@ -9,7 +9,6 @@ import {assignmentUtils, planningUtils, gettext, stringUtils} from '../../../uti import {Item, Column, Row} from '../../UI/List'; import {ContentBlock, ContentBlockInner, Tools} from '../../UI/SidePanel'; import { - UserAvatar, AbsoluteDate, PriorityLabel, StateLabel, @@ -18,6 +17,7 @@ import { ItemActionsMenu, Label, } from '../../'; +import {UserAvatar} from '../../../components/UserAvatar'; import {TO_BE_CONFIRMED_FIELD} from '../../../constants'; export const AssignmentPreviewHeader = ({ @@ -77,10 +77,7 @@ export const AssignmentPreviewHeader = ({ ) diff --git a/client/components/Coverages/CoverageEditor/CoverageFormHeader.tsx b/client/components/Coverages/CoverageEditor/CoverageFormHeader.tsx index dcc41be83..26c534fb3 100644 --- a/client/components/Coverages/CoverageEditor/CoverageFormHeader.tsx +++ b/client/components/Coverages/CoverageEditor/CoverageFormHeader.tsx @@ -8,7 +8,7 @@ import {IArticle, IDesk, IUser} from 'superdesk-api'; import {getCreator, getItemInArrayById, gettext, planningUtils, onEventCapture} from '../../../utils'; import {Item, Border, Column, Row as ListRow} from '../../UI/List'; import {Button} from '../../UI'; -import {UserAvatar} from '../../'; +import {UserAvatar} from '../../../components/UserAvatar'; import {StateLabel} from '../../StateLabel'; import * as actions from '../../../actions'; @@ -85,10 +85,8 @@ export class CoverageFormHeaderComponent extends React.PureComponent { @@ -122,10 +120,8 @@ export class CoverageFormHeaderComponent extends React.PureComponent { diff --git a/client/components/Coverages/CoverageIcons.tsx b/client/components/Coverages/CoverageIcons.tsx index 4662d6325..08aa5ce11 100644 --- a/client/components/Coverages/CoverageIcons.tsx +++ b/client/components/Coverages/CoverageIcons.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import moment from 'moment-timezone'; -import {getUserInitials} from './../../components/UserAvatar'; +import {getCustomAvatarContent, getUserInitials} from './../../components/UserAvatar'; import * as config from 'appConfig'; import {IPlanningCoverageItem, IG2ContentType, IContactItem, IPlanningConfig} from '../../interfaces'; import {IUser, IDesk} from 'superdesk-api'; @@ -17,7 +17,7 @@ import { import {IPropsAvatarPlaceholder} from 'superdesk-ui-framework/react/components/avatar/avatar-placeholder'; import {IPropsAvatar} from 'superdesk-ui-framework/react/components/avatar/avatar'; import {trimStartExact} from 'superdesk-core/scripts/core/helpers/utils'; -import {getItemWorkflowStateLabel, planningUtils} from '../../utils'; +import {getItemWorkflowStateLabel, gettext, planningUtils} from '../../utils'; import {getVocabularyItemFieldTranslated} from '../../utils/vocabularies'; import {getUserInterfaceLanguageFromCV} from '../../utils/users'; import './coverage-icons.scss'; @@ -67,8 +67,9 @@ export function getAvatarForCoverage( if (user == null) { const placeholder: Omit = { - kind: 'plus-button', + kind: 'user-icon', icon: icon, + tooltip: gettext('Unassigned'), }; return placeholder; @@ -78,6 +79,7 @@ export function getAvatarForCoverage( imageUrl: user.picture_url, displayName: user.display_name, icon: icon, + customContent: getCustomAvatarContent(user), }; return avatar; diff --git a/client/components/Coverages/CoverageItem.tsx b/client/components/Coverages/CoverageItem.tsx index dfd12729d..100118b46 100644 --- a/client/components/Coverages/CoverageItem.tsx +++ b/client/components/Coverages/CoverageItem.tsx @@ -20,7 +20,6 @@ import {getUserInterfaceLanguageFromCV} from '../../utils/users'; import {Item, Column, Row, Border, ActionMenu} from '../UI/List'; import {StateLabel, InternalNoteLabel} from '../../components'; import {CoverageIcons} from './CoverageIcons'; -import {UserAvatar} from '../UserAvatar'; interface IProps { coverage: IPlanningCoverageItem; @@ -166,20 +165,12 @@ export class CoverageItemComponent extends React.Component { return ( - {this.state.userAssigned ? ( - - ) : ( - - )} + ); } @@ -187,12 +178,6 @@ export class CoverageItemComponent extends React.Component { renderFirstRow() { return ( - {this.state.displayContentType} diff --git a/client/components/LockContainer/LockContainerPopup.tsx b/client/components/LockContainer/LockContainerPopup.tsx index 7f662b497..cf51db53b 100644 --- a/client/components/LockContainer/LockContainerPopup.tsx +++ b/client/components/LockContainer/LockContainerPopup.tsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import {gettext} from '../../utils'; -import {UserAvatar} from '../'; +import {UserAvatarWithMargin} from '../../components/UserAvatar'; import {Popup, Header, Content, Footer} from '../UI/Popup'; import {Button} from '../UI'; @@ -33,7 +33,7 @@ export const LockContainerPopup = ({ noBorder={true} /> - +
{user.display_name}