1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-08-04 13:05:24 +02:00

Prepare for collection board type, refactoring, update dependencies

This commit is contained in:
Maksim Eltyshev 2020-08-04 01:32:46 +05:00
parent 402645bc99
commit 30ed77af59
190 changed files with 2144 additions and 1817 deletions

View file

@ -0,0 +1,71 @@
import React, { useCallback, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import { Button } from 'semantic-ui-react';
import { withPopup } from '../../../lib/popup';
import { FilePicker, Popup } from '../../../lib/custom-ui';
import styles from './AvatarEditPopup.module.scss';
const AvatarEditStep = React.memo(({ defaultValue, onUpdate, onDelete, onClose }) => {
const [t] = useTranslation();
const field = useRef(null);
const handleFileSelect = useCallback(
(file) => {
onUpdate({
file,
});
onClose();
},
[onUpdate, onClose],
);
const handleDeleteClick = useCallback(() => {
onDelete();
onClose();
}, [onDelete, onClose]);
useEffect(() => {
field.current.focus();
}, []);
return (
<>
<Popup.Header>
{t('common.editAvatar', {
context: 'title',
})}
</Popup.Header>
<Popup.Content>
<div className={styles.action}>
<FilePicker accept="image/*" onSelect={handleFileSelect}>
<Button
ref={field}
content={t('action.uploadNewAvatar')}
className={styles.actionButton}
/>
</FilePicker>
</div>
{defaultValue && (
<Button negative content={t('action.deleteAvatar')} onClick={handleDeleteClick} />
)}
</Popup.Content>
</>
);
});
AvatarEditStep.propTypes = {
defaultValue: PropTypes.string,
onUpdate: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
};
AvatarEditStep.defaultProps = {
defaultValue: undefined,
};
export default withPopup(AvatarEditStep);