ref(profile-settings) Use new input component (#11928)
This commit is contained in:
parent
2cea6c7b98
commit
30a0a624a2
|
@ -12,6 +12,8 @@ import { InputProps } from '../types';
|
||||||
interface IInputProps extends InputProps {
|
interface IInputProps extends InputProps {
|
||||||
bottomLabel?: string;
|
bottomLabel?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
id?: string;
|
||||||
|
name?: string;
|
||||||
type?: 'text' | 'email' | 'number' | 'password';
|
type?: 'text' | 'email' | 'number' | 'password';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +121,9 @@ const Input = ({
|
||||||
disabled,
|
disabled,
|
||||||
error,
|
error,
|
||||||
icon,
|
icon,
|
||||||
|
id,
|
||||||
label,
|
label,
|
||||||
|
name,
|
||||||
onChange,
|
onChange,
|
||||||
placeholder,
|
placeholder,
|
||||||
type = 'text',
|
type = 'text',
|
||||||
|
@ -144,6 +148,8 @@ const Input = ({
|
||||||
className = { clsx(styles.input, isMobile && 'is-mobile',
|
className = { clsx(styles.input, isMobile && 'is-mobile',
|
||||||
error && 'error', clearable && styles.clearableInput, icon && styles.iconInput) }
|
error && 'error', clearable && styles.clearableInput, icon && styles.iconInput) }
|
||||||
disabled = { disabled }
|
disabled = { disabled }
|
||||||
|
{ ...(id ? { id } : {}) }
|
||||||
|
name = { name }
|
||||||
onChange = { handleChange }
|
onChange = { handleChange }
|
||||||
placeholder = { placeholder }
|
placeholder = { placeholder }
|
||||||
type = { type }
|
type = { type }
|
||||||
|
|
|
@ -1,26 +1,31 @@
|
||||||
// @flow
|
/* eslint-disable lines-around-comment */
|
||||||
|
|
||||||
import Button from '@atlaskit/button/standard-button';
|
import Button from '@atlaskit/button/standard-button';
|
||||||
import { FieldTextStateless } from '@atlaskit/field-text';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import UIEvents from '../../../../../service/UI/UIEvents';
|
import UIEvents from '../../../../../service/UI/UIEvents';
|
||||||
import {
|
import {
|
||||||
sendAnalytics,
|
sendAnalytics,
|
||||||
createProfilePanelButtonEvent
|
createProfilePanelButtonEvent
|
||||||
|
// @ts-ignore
|
||||||
} from '../../../analytics';
|
} from '../../../analytics';
|
||||||
|
// @ts-ignore
|
||||||
import { AbstractDialogTab } from '../../../base/dialog';
|
import { AbstractDialogTab } from '../../../base/dialog';
|
||||||
|
// @ts-ignore
|
||||||
import type { Props as AbstractDialogTabProps } from '../../../base/dialog';
|
import type { Props as AbstractDialogTabProps } from '../../../base/dialog';
|
||||||
|
// @ts-ignore
|
||||||
import { translate } from '../../../base/i18n';
|
import { translate } from '../../../base/i18n';
|
||||||
|
import Input from '../../../base/ui/components/web/Input';
|
||||||
|
// @ts-ignore
|
||||||
import { openLogoutDialog } from '../../actions';
|
import { openLogoutDialog } from '../../actions';
|
||||||
|
|
||||||
declare var APP: Object;
|
// eslint-disable-next-line no-var
|
||||||
|
declare var APP: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the React {@code Component} props of {@link ProfileTab}.
|
* The type of the React {@code Component} props of {@link ProfileTab}.
|
||||||
*/
|
*/
|
||||||
export type Props = {
|
export type Props = AbstractDialogTabProps & {
|
||||||
...$Exact<AbstractDialogTabProps>,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not server-side authentication is available.
|
* Whether or not server-side authentication is available.
|
||||||
|
@ -42,16 +47,16 @@ export type Props = {
|
||||||
*/
|
*/
|
||||||
email: string,
|
email: string,
|
||||||
|
|
||||||
/**
|
|
||||||
* If the display name is read only.
|
|
||||||
*/
|
|
||||||
readOnlyName: boolean,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to hide the email input in the profile settings.
|
* Whether to hide the email input in the profile settings.
|
||||||
*/
|
*/
|
||||||
hideEmailInSettings?: boolean,
|
hideEmailInSettings?: boolean,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the display name is read only.
|
||||||
|
*/
|
||||||
|
readOnlyName: boolean,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked to obtain translated strings.
|
* Invoked to obtain translated strings.
|
||||||
*/
|
*/
|
||||||
|
@ -84,29 +89,25 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
||||||
this._onEmailChange = this._onEmailChange.bind(this);
|
this._onEmailChange = this._onEmailChange.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDisplayNameChange: (Object) => void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes display name of the user.
|
* Changes display name of the user.
|
||||||
*
|
*
|
||||||
* @param {Object} e - The key event to handle.
|
* @param {string} value - The key event to handle.
|
||||||
*
|
*
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_onDisplayNameChange({ target: { value } }) {
|
_onDisplayNameChange(value: string) {
|
||||||
super._onChange({ displayName: value });
|
super._onChange({ displayName: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
_onEmailChange: (Object) => void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes email of the user.
|
* Changes email of the user.
|
||||||
*
|
*
|
||||||
* @param {Object} e - The key event to handle.
|
* @param {string} value - The key event to handle.
|
||||||
*
|
*
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_onEmailChange({ target: { value } }) {
|
_onEmailChange(value: string) {
|
||||||
super._onChange({ email: value });
|
super._onChange({ email: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,33 +124,30 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
||||||
email,
|
email,
|
||||||
hideEmailInSettings,
|
hideEmailInSettings,
|
||||||
readOnlyName,
|
readOnlyName,
|
||||||
t
|
t // @ts-ignore
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className = 'profile-edit'>
|
<div className = 'profile-edit'>
|
||||||
<div className = 'profile-edit-field'>
|
<div className = 'profile-edit-field'>
|
||||||
<FieldTextStateless
|
<Input
|
||||||
autoComplete = 'name'
|
disabled = { readOnlyName }
|
||||||
compact = { true }
|
|
||||||
id = 'setDisplayName'
|
id = 'setDisplayName'
|
||||||
isReadOnly = { readOnlyName }
|
|
||||||
label = { t('profile.setDisplayNameLabel') }
|
label = { t('profile.setDisplayNameLabel') }
|
||||||
|
name = 'name'
|
||||||
onChange = { this._onDisplayNameChange }
|
onChange = { this._onDisplayNameChange }
|
||||||
placeholder = { t('settings.name') }
|
placeholder = { t('settings.name') }
|
||||||
shouldFitContainer = { true }
|
|
||||||
type = 'text'
|
type = 'text'
|
||||||
value = { displayName } />
|
value = { displayName } />
|
||||||
</div>
|
</div>
|
||||||
{!hideEmailInSettings && <div className = 'profile-edit-field'>
|
{!hideEmailInSettings && <div className = 'profile-edit-field'>
|
||||||
<FieldTextStateless
|
<Input
|
||||||
compact = { true }
|
|
||||||
id = 'setEmail'
|
id = 'setEmail'
|
||||||
label = { t('profile.setEmailLabel') }
|
label = { t('profile.setEmailLabel') }
|
||||||
|
name = 'email'
|
||||||
onChange = { this._onEmailChange }
|
onChange = { this._onEmailChange }
|
||||||
placeholder = { t('profile.setEmailInput') }
|
placeholder = { t('profile.setEmailInput') }
|
||||||
shouldFitContainer = { true }
|
|
||||||
type = 'text'
|
type = 'text'
|
||||||
value = { email } />
|
value = { email } />
|
||||||
</div>}
|
</div>}
|
||||||
|
@ -159,8 +157,6 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onAuthToggle: () => void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the dialog for logging in or out of a server and closes this
|
* Shows the dialog for logging in or out of a server and closes this
|
||||||
* dialog.
|
* dialog.
|
||||||
|
@ -169,6 +165,7 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_onAuthToggle() {
|
_onAuthToggle() {
|
||||||
|
// @ts-ignore
|
||||||
if (this.props.authLogin) {
|
if (this.props.authLogin) {
|
||||||
sendAnalytics(createProfilePanelButtonEvent('logout.button'));
|
sendAnalytics(createProfilePanelButtonEvent('logout.button'));
|
||||||
|
|
||||||
|
@ -192,6 +189,7 @@ class ProfileTab extends AbstractDialogTab<Props> {
|
||||||
const {
|
const {
|
||||||
authLogin,
|
authLogin,
|
||||||
t
|
t
|
||||||
|
// @ts-ignore
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
|
@ -125,7 +125,8 @@ const styles = theme => {
|
||||||
|
|
||||||
'& .profile-edit-field': {
|
'& .profile-edit-field': {
|
||||||
flex: 0.5,
|
flex: 0.5,
|
||||||
marginRight: '20px'
|
marginRight: '20px',
|
||||||
|
marginTop: `${theme.spacing(3)}px`
|
||||||
},
|
},
|
||||||
|
|
||||||
'& .settings-sub-pane': {
|
'& .settings-sub-pane': {
|
||||||
|
|
Loading…
Reference in New Issue