diff --git a/components/__snapshots__/picture_selector.test.tsx.snap b/components/__snapshots__/picture_selector.test.tsx.snap new file mode 100644 index 000000000000..f4221101ef6f --- /dev/null +++ b/components/__snapshots__/picture_selector.test.tsx.snap @@ -0,0 +1,118 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/picture_selector should match snapshot, default picture provided 1`] = ` +
+ +
+
+ +
+
+`; + +exports[`components/picture_selector should match snapshot, existing picture provided 1`] = ` +
+ +
+
+ +
+
+`; + +exports[`components/picture_selector should match snapshot, no picture selected 1`] = ` +
+ +
+
+ +
+
+`; diff --git a/components/next_steps_view/index.ts b/components/next_steps_view/index.ts index 3ff12276ead2..12d6b5505c88 100644 --- a/components/next_steps_view/index.ts +++ b/components/next_steps_view/index.ts @@ -20,10 +20,9 @@ function makeMapStateToProps() { return (state: GlobalState) => { const license = getLicense(state); - const currentUser = getCurrentUser(state); return { - currentUserId: currentUser.id, + currentUser: getCurrentUser(state), preferences: getCategory(state, Preferences.RECOMMENDED_NEXT_STEPS), skuName: license.SkuShortName, }; diff --git a/components/next_steps_view/next_steps_view.test.tsx b/components/next_steps_view/next_steps_view.test.tsx index 2c51f5528219..276871b9fcc3 100644 --- a/components/next_steps_view/next_steps_view.test.tsx +++ b/components/next_steps_view/next_steps_view.test.tsx @@ -5,10 +5,11 @@ import React from 'react'; import {shallow} from 'enzyme'; import NextStepsView from 'components/next_steps_view/next_steps_view'; +import {TestHelper} from 'utils/test_helper'; describe('components/next_steps_view', () => { const baseProps = { - currentUserId: 'user_id', + currentUser: TestHelper.getUserMock(), preferences: [], skuName: '', actions: { diff --git a/components/next_steps_view/next_steps_view.tsx b/components/next_steps_view/next_steps_view.tsx index 965d46f83c7b..db796514bfc9 100644 --- a/components/next_steps_view/next_steps_view.tsx +++ b/components/next_steps_view/next_steps_view.tsx @@ -6,6 +6,7 @@ import classNames from 'classnames'; import {FormattedMessage} from 'react-intl'; import {PreferenceType} from 'mattermost-redux/types/preferences'; +import {UserProfile} from 'mattermost-redux/types/users'; import Accordion from 'components/accordion'; import Card from 'components/card/card'; @@ -16,7 +17,7 @@ import {Steps, StepType} from './steps'; import './next_steps_view.scss'; type Props = { - currentUserId: string; + currentUser: UserProfile; preferences: PreferenceType[]; skuName: string; actions: { @@ -86,9 +87,9 @@ export default class NextStepsView extends React.PureComponent { onFinish = (setExpanded: (expandedKey: string) => void) => { return (id: string) => { - this.props.actions.savePreferences(this.props.currentUserId, [{ + this.props.actions.savePreferences(this.props.currentUser.id, [{ category: Preferences.RECOMMENDED_NEXT_STEPS, - user_id: this.props.currentUserId, + user_id: this.props.currentUser.id, name: id, value: 'true', }]); @@ -117,12 +118,14 @@ export default class NextStepsView extends React.PureComponent { } renderStep = (step: StepType, index: number) => { + const {id, title} = step; + let icon = (
{index + 1}
); - if (this.isStepComplete(step.id)) { + if (this.isStepComplete(id)) { icon = ( ); @@ -130,22 +133,23 @@ export default class NextStepsView extends React.PureComponent { return (setExpanded: (expandedKey: string) => void, expandedKey: string) => ( diff --git a/components/next_steps_view/steps.ts b/components/next_steps_view/steps.ts index 2ed010f7003a..a5583cef70ce 100644 --- a/components/next_steps_view/steps.ts +++ b/components/next_steps_view/steps.ts @@ -3,6 +3,7 @@ import {createSelector} from 'reselect'; import {makeGetCategory} from 'mattermost-redux/selectors/entities/preferences'; +import {UserProfile} from 'mattermost-redux/types/users'; import {GlobalState} from 'types/store'; import {RecommendedNextSteps, Preferences} from 'utils/constants'; @@ -12,6 +13,7 @@ import CompleteProfileStep from './steps/complete_profile_step'; export type StepComponentProps = { id: string; + currentUser: UserProfile; onSkip: (id: string) => void; onFinish: (id: string) => void; } diff --git a/components/next_steps_view/steps/complete_profile_step.tsx b/components/next_steps_view/steps/complete_profile_step.tsx index 659fcaca415b..6c0f5deaeb7f 100644 --- a/components/next_steps_view/steps/complete_profile_step.tsx +++ b/components/next_steps_view/steps/complete_profile_step.tsx @@ -4,15 +4,25 @@ import React from 'react'; import {FormattedMessage} from 'react-intl'; +import PictureSelector from 'components/picture_selector'; +import * as Utils from 'utils/utils'; + import {StepComponentProps} from '../steps'; type Props = StepComponentProps & { }; type State = { + profilePicture?: File; }; export default class CompleteProfileStep extends React.PureComponent { + constructor(props: Props) { + super(props); + + this.state = {}; + } + onSkip = () => { this.props.onSkip(this.props.id); } @@ -21,10 +31,38 @@ export default class CompleteProfileStep extends React.PureComponent { + this.setState({profilePicture}); + } + + onRemovePicture = () => { + this.setState({profilePicture: undefined}); + } + render() { + const {currentUser} = this.props; + + // Make sure picture has been set + const pictureSrc = currentUser.last_picture_update ? Utils.imageURLForUser(currentUser.id, currentUser.last_picture_update) : undefined; + const defaultSrc = Utils.defaultImageURLForUser(currentUser.id); + return (
- {'AAAAAAAA'} +
+ +
{/* + ); + } + + return ( +
+ +
+
+ +
+ {removeButton} +
+ ); +}; + +export default PictureSelector; diff --git a/i18n/en.json b/i18n/en.json index 3b4747824aaa..ec48414a0a91 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -3138,6 +3138,9 @@ "pending_post_actions.retry": "Retry", "permalink.error.access": "Permalink belongs to a deleted message or to a channel to which you do not have access.", "permalink.error.title": "Message Not Found", + "picture_selector.image.ariaLabel": "Picture selector image", + "picture_selector.remove_picture": "Remove picture", + "picture_selector.select_button.ariaLabel": "Select picture", "post_body.check_for_out_of_channel_groups_mentions.message": "did not get notified by this mention because they are not in the channel. They cannot be added to the channel because they are not a member of the linked groups. To add them to this channel, they must be added to the linked groups.", "post_body.check_for_out_of_channel_mentions.link.and": " and ", "post_body.check_for_out_of_channel_mentions.link.private": "add them to this private channel",