From 3e7ff16a27d844ae35b650efce4456cebfd22b2b Mon Sep 17 00:00:00 2001 From: Daniele Valverde <34126648+danielevalverde@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:21:54 -0300 Subject: [PATCH] CV2-5048: Delete the user profile page (#2053) * Delete the user profile page Reference: CV2-5048 * add formattedMessage to make strings translated Reference: CV2-5048 --- .../src/app/components/task/Task.json | 5 ++ .../src/app/components/task/Tasks.json | 5 ++ src/app/components/Root.js | 3 - src/app/components/layout/ProfileLink.js | 20 ------- src/app/components/layout/ProfileLink.test.js | 17 ------ src/app/components/task/Task.js | 19 ++----- src/app/components/task/Tasks.js | 12 ++-- src/app/components/user/User.js | 29 ---------- src/app/components/user/UserComponent.js | 47 ---------------- src/app/components/user/UserInfo.js | 55 ------------------- src/app/relay/UserRoute.js | 13 ----- src/app/relay/userFragment.js | 19 ------- 12 files changed, 22 insertions(+), 222 deletions(-) delete mode 100644 src/app/components/layout/ProfileLink.js delete mode 100644 src/app/components/layout/ProfileLink.test.js delete mode 100644 src/app/components/user/User.js delete mode 100644 src/app/components/user/UserComponent.js delete mode 100644 src/app/components/user/UserInfo.js delete mode 100644 src/app/relay/UserRoute.js delete mode 100644 src/app/relay/userFragment.js diff --git a/localization/react-intl/src/app/components/task/Task.json b/localization/react-intl/src/app/components/task/Task.json index 732dff1c3a..67616bcd0f 100644 --- a/localization/react-intl/src/app/components/task/Task.json +++ b/localization/react-intl/src/app/components/task/Task.json @@ -79,6 +79,11 @@ "description": "This is a label that appears while a file upload is ongoing.", "defaultMessage": "Saving {file}…" }, + { + "id": "metadata.savedByLabel", + "description": "This is a label that indicates when and by whom the task was saved.", + "defaultMessage": "Saved {timeAgo} by {userName}" + }, { "id": "task.uploadWarningTitle", "description": "Warning to prevent user from navigating away while upload is running", diff --git a/localization/react-intl/src/app/components/task/Tasks.json b/localization/react-intl/src/app/components/task/Tasks.json index 1750f63a89..4a44cfb899 100644 --- a/localization/react-intl/src/app/components/task/Tasks.json +++ b/localization/react-intl/src/app/components/task/Tasks.json @@ -19,6 +19,11 @@ "description": "Error message displayed when a URL is not in the correct format in the form, which prevents the form from being saved.", "defaultMessage": "Could not save, at least one URL is invalid" }, + { + "id": "tasks.savedByLabel", + "description": "This is a label that indicates when and by whom the task was saved.", + "defaultMessage": "Saved {timeAgo} by {userName}" + }, { "id": "tasks.contentTrash", "description": "This message tells the user that the content typically shown in unavailable when the item is in the trash", diff --git a/src/app/components/Root.js b/src/app/components/Root.js index a519dacf14..56b5f777c4 100644 --- a/src/app/components/Root.js +++ b/src/app/components/Root.js @@ -12,7 +12,6 @@ import UserConfirmPage from './UserConfirmPage'; import UserPasswordChange from './UserPasswordChange'; import UserPasswordReset from './login/UserPasswordReset'; import ErrorBoundary from './error/ErrorBoundary'; -import User from './user/User'; import Me from './user/Me'; import Team from './team/Team'; import AssignedToMe from './team/AssignedToMe'; @@ -77,8 +76,6 @@ class Root extends Component { - - diff --git a/src/app/components/layout/ProfileLink.js b/src/app/components/layout/ProfileLink.js deleted file mode 100644 index 168d3b4eca..0000000000 --- a/src/app/components/layout/ProfileLink.js +++ /dev/null @@ -1,20 +0,0 @@ -import { Link } from 'react-router'; -import React from 'react'; - -const ProfileLink = ({ className, user }) => { - if (!user) return null; - let url = ''; - if (user.dbid && user.is_active) { - url = `/check/user/${user.dbid}`; - } - - return url ? - - {user.name} - : - - {user.name} - ; -}; - -export default ProfileLink; diff --git a/src/app/components/layout/ProfileLink.test.js b/src/app/components/layout/ProfileLink.test.js deleted file mode 100644 index c52c0e5bb9..0000000000 --- a/src/app/components/layout/ProfileLink.test.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import ProfileLink from './ProfileLink'; -import { mountWithIntlProvider } from '../../../../test/unit/helpers/intl-test'; - -const user = { - dbid: 1, - is_active: true, - name: 'User Name', -}; - -describe('', () => { - it('should render user name and profile link', () => { - const wrapper = mountWithIntlProvider(); - expect(wrapper.html()).toMatch('User Name'); - expect(wrapper.find('a').hostNodes()).toHaveLength(1); - }); -}); diff --git a/src/app/components/task/Task.js b/src/app/components/task/Task.js index 1e07a00a74..36fbaf9163 100644 --- a/src/app/components/task/Task.js +++ b/src/app/components/task/Task.js @@ -13,7 +13,6 @@ import GenericUnknownErrorMessage from '../GenericUnknownErrorMessage'; import NavigateAwayDialog from '../NavigateAwayDialog'; import ParsedText from '../ParsedText'; import { getErrorMessage } from '../../helpers'; -import ProfileLink from '../layout/ProfileLink'; import CheckContext from '../../CheckContext'; import UpdateTaskMutation from '../../relay/mutations/UpdateTaskMutation'; import UpdateDynamicMutation from '../../relay/mutations/UpdateDynamicMutation'; @@ -31,7 +30,6 @@ function getResponseData(response) { if (response.attribution) { response.attribution.edges.forEach((user) => { const u = user.node; - data.by.push(); data.byPictures.push(u); }); } @@ -531,13 +529,12 @@ class Task extends Component { return ( responseObj && responseObj.annotator ? (
- Saved {timeAgo} by{' '} - - {responseObj.annotator.user?.name} - +
) : null ); @@ -781,11 +778,7 @@ class Task extends Component { const taskAnswered = !!response; const assignments = task.assignments.edges; - const assignmentComponents = []; assignments.forEach((assignment) => { - assignmentComponents.push( - , - ); if (currentUser && assignment.node.dbid === currentUser.dbid) { taskAssigned = true; } diff --git a/src/app/components/task/Tasks.js b/src/app/components/task/Tasks.js index 189da3a001..46234896cc 100644 --- a/src/app/components/task/Tasks.js +++ b/src/app/components/task/Tasks.js @@ -222,12 +222,12 @@ const Tasks = ({ } return (
- Saved {moment(latestEditInfo.latestDate).fromNow()} by{' '} - - {latestEditInfo.latestAuthorName} - +
); }; diff --git a/src/app/components/user/User.js b/src/app/components/user/User.js deleted file mode 100644 index 6213127c2a..0000000000 --- a/src/app/components/user/User.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import Relay from 'react-relay/classic'; -import UserComponent from './UserComponent'; -import ErrorBoundary from '../error/ErrorBoundary'; -import MediasLoading from '../media/MediasLoading'; -import UserRoute from '../../relay/UserRoute'; -import userFragment from '../../relay/userFragment'; - -const UserContainer = Relay.createContainer(UserComponent, { - fragments: { - user: () => userFragment, - }, -}); - -const User = (props) => { - const route = new UserRoute({ userId: props.params.userId }); - return ( - - } - renderFetched={data => } - /> - - ); -}; - -export default User; diff --git a/src/app/components/user/UserComponent.js b/src/app/components/user/UserComponent.js deleted file mode 100644 index 968ffa7157..0000000000 --- a/src/app/components/user/UserComponent.js +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { browserHistory } from 'react-router'; -import cx from 'classnames/bind'; -import UserInfo from './UserInfo'; -import PageTitle from '../PageTitle'; -import CheckContext from '../../CheckContext'; -import styles from './user.module.css'; - -class UserComponent extends React.Component { - componentWillMount() { - const { user } = this.props; - if (!user.is_active) { - browserHistory.push('/check/not-found'); - } - if (user.dbid === this.getContext().currentUser.dbid) { - browserHistory.push('/check/me/profile'); - } - } - - getContext() { - return new CheckContext(this).getContextStore(); - } - - render() { - const { user } = this.props; - const context = this.getContext(); - - return ( - -
-
-
- -
-
-
-
- ); - } -} - -UserComponent.contextTypes = { - store: PropTypes.object, -}; - -export default UserComponent; diff --git a/src/app/components/user/UserInfo.js b/src/app/components/user/UserInfo.js deleted file mode 100644 index bcce8ed5af..0000000000 --- a/src/app/components/user/UserInfo.js +++ /dev/null @@ -1,55 +0,0 @@ -import React from 'react'; -import { injectIntl, FormattedMessage } from 'react-intl'; -import cx from 'classnames/bind'; -import { parseStringUnixTimestamp } from '../../helpers'; -import SourcePicture from '../source/SourcePicture'; -import styles from '../user/user.module.css'; - -const UserInfo = (props) => { - if (props.user.source === null) return null; - - return ( -
-
- -
- -
-
-
-
{props.user.name}
-
-
-
- - • - -
-
-
- ); -}; - -export default injectIntl(UserInfo); diff --git a/src/app/relay/UserRoute.js b/src/app/relay/UserRoute.js deleted file mode 100644 index e758e25881..0000000000 --- a/src/app/relay/UserRoute.js +++ /dev/null @@ -1,13 +0,0 @@ -import Relay from 'react-relay/classic'; - -class UserRoute extends Relay.Route { - static queries = { - user: () => Relay.QL`query User { user(id: $userId) }`, - }; - static paramDefinitions = { - userId: { required: true }, - }; - static routeName = 'UserRoute'; -} - -export default UserRoute; diff --git a/src/app/relay/userFragment.js b/src/app/relay/userFragment.js deleted file mode 100644 index 89d54e49f5..0000000000 --- a/src/app/relay/userFragment.js +++ /dev/null @@ -1,19 +0,0 @@ -import Relay from 'react-relay/classic'; -import sourceFragment from './sourceFragment'; - -const userFragment = Relay.QL` - fragment on User { - id, - dbid, - name, - email, - is_active, - profile_image, - number_of_teams, - source { - ${sourceFragment} - } - } -`; - -export default userFragment;