mirror of
https://github.com/plankanban/planka.git
synced 2025-07-26 00:29:48 +02:00
Add file attachments
This commit is contained in:
parent
87a3cf751a
commit
f743f4ea8b
103 changed files with 1847 additions and 305 deletions
|
@ -60,7 +60,7 @@ const Filter = React.memo(
|
|||
<span key={user.id} className={styles.filterItem}>
|
||||
<User
|
||||
name={user.name}
|
||||
avatar={user.avatar}
|
||||
avatarUrl={user.avatarUrl}
|
||||
size="small"
|
||||
onClick={() => handleUserRemoveClick(user.id)}
|
||||
/>
|
||||
|
|
|
@ -103,7 +103,7 @@ const Card = React.memo(
|
|||
<span className={classNames(styles.attachments, styles.attachmentsRight)}>
|
||||
{users.map((user) => (
|
||||
<span key={user.id} className={classNames(styles.attachment, styles.attachmentRight)}>
|
||||
<User name={user.name} avatar={user.avatar} size="tiny" />
|
||||
<User name={user.name} avatarUrl={user.avatarUrl} size="tiny" />
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
.card:hover {
|
||||
background-color: #f5f6f7;
|
||||
border-bottom-color: rgba(9, 45, 66, 0.25);
|
||||
border-bottom-color: rgba(9, 30, 66, 0.25);
|
||||
}
|
||||
|
||||
.card:hover .target {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
.field {
|
||||
background: #fff !important;
|
||||
border: 1px solid rgba(9, 45, 66, 0.13) !important;
|
||||
border: 1px solid rgba(9, 30, 66, 0.13) !important;
|
||||
border-radius: 3px !important;
|
||||
box-sizing: border-box;
|
||||
color: #333 !important;
|
||||
|
|
|
@ -62,7 +62,7 @@ const Item = React.memo(({ type, data, createdAt, user }) => {
|
|||
return (
|
||||
<Comment>
|
||||
<span className={styles.user}>
|
||||
<User name={user.name} avatar={user.avatar} />
|
||||
<User name={user.name} avatarUrl={user.avatarUrl} />
|
||||
</span>
|
||||
<div className={classNames(styles.content)}>
|
||||
<div>{contentNode}</div>
|
||||
|
|
|
@ -24,7 +24,7 @@ const ItemComment = React.memo(
|
|||
return (
|
||||
<Comment>
|
||||
<span className={styles.user}>
|
||||
<User name={user.name} avatar={user.avatar} />
|
||||
<User name={user.name} avatarUrl={user.avatarUrl} />
|
||||
</span>
|
||||
<div className={classNames(styles.content)}>
|
||||
<div className={styles.title}>
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
.text {
|
||||
background-color: #fff;
|
||||
border-radius: 0px 8px 8px;
|
||||
box-shadow: 0 1px 2px -1px rgba(9, 45, 66, 0.25),
|
||||
0 0 0 1px rgba(9, 45, 66, 0.08);
|
||||
box-shadow: 0 1px 2px -1px rgba(9, 30, 66, 0.25),
|
||||
0 0 0 1px rgba(9, 30, 66, 0.08);
|
||||
box-sizing: border-box;
|
||||
color: #17394d;
|
||||
display: inline-block;
|
||||
|
|
45
client/src/components/CardModal/Attachments/Attachments.jsx
Normal file
45
client/src/components/CardModal/Attachments/Attachments.jsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
import React, { useCallback } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Item from './Item';
|
||||
|
||||
const Attachments = React.memo(({ items, onUpdate, onDelete }) => {
|
||||
const handleUpdate = useCallback(
|
||||
(id, data) => {
|
||||
onUpdate(id, data);
|
||||
},
|
||||
[onUpdate],
|
||||
);
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id) => {
|
||||
onDelete(id);
|
||||
},
|
||||
[onDelete],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{items.map((item) => (
|
||||
<Item
|
||||
key={item.id}
|
||||
name={item.name}
|
||||
url={item.url}
|
||||
thumbnailUrl={item.thumbnailUrl}
|
||||
createdAt={item.createdAt}
|
||||
isPersisted={item.isPersisted}
|
||||
onUpdate={(data) => handleUpdate(item.id, data)}
|
||||
onDelete={() => handleDelete(item.id)}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
Attachments.propTypes = {
|
||||
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default Attachments;
|
107
client/src/components/CardModal/Attachments/EditPopup.jsx
Executable file
107
client/src/components/CardModal/Attachments/EditPopup.jsx
Executable file
|
@ -0,0 +1,107 @@
|
|||
import dequal from 'dequal';
|
||||
import React, { useCallback, useEffect, useRef } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Form } from 'semantic-ui-react';
|
||||
import { withPopup } from '../../../lib/popup';
|
||||
import { Input, Popup } from '../../../lib/custom-ui';
|
||||
|
||||
import { useForm, useSteps } from '../../../hooks';
|
||||
import DeleteStep from '../../DeleteStep';
|
||||
|
||||
import styles from './EditPopup.module.css';
|
||||
|
||||
const StepTypes = {
|
||||
DELETE: 'DELETE',
|
||||
};
|
||||
|
||||
const EditStep = React.memo(({ defaultData, onUpdate, onDelete, onClose }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
const [data, handleFieldChange] = useForm(() => ({
|
||||
name: '',
|
||||
...defaultData,
|
||||
}));
|
||||
|
||||
const [step, openStep, handleBack] = useSteps();
|
||||
|
||||
const nameField = useRef(null);
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
const cleanData = {
|
||||
...data,
|
||||
name: data.name.trim(),
|
||||
};
|
||||
|
||||
if (!cleanData.name) {
|
||||
nameField.current.select();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dequal(cleanData, defaultData)) {
|
||||
onUpdate(cleanData);
|
||||
}
|
||||
|
||||
onClose();
|
||||
}, [defaultData, onUpdate, onClose, data]);
|
||||
|
||||
const handleDeleteClick = useCallback(() => {
|
||||
openStep(StepTypes.DELETE);
|
||||
}, [openStep]);
|
||||
|
||||
useEffect(() => {
|
||||
nameField.current.select();
|
||||
}, []);
|
||||
|
||||
if (step && step.type === StepTypes.DELETE) {
|
||||
return (
|
||||
<DeleteStep
|
||||
title={t('common.deleteAttachment', {
|
||||
context: 'title',
|
||||
})}
|
||||
content={t('common.areYouSureYouWantToDeleteThisAttachment')}
|
||||
buttonContent={t('action.deleteAttachment')}
|
||||
onConfirm={onDelete}
|
||||
onBack={handleBack}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Popup.Header>
|
||||
{t('common.editAttachment', {
|
||||
context: 'title',
|
||||
})}
|
||||
</Popup.Header>
|
||||
<Popup.Content>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<div className={styles.text}>{t('common.title')}</div>
|
||||
<Input
|
||||
fluid
|
||||
ref={nameField}
|
||||
name="name"
|
||||
value={data.name}
|
||||
className={styles.field}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<Button positive content={t('action.save')} />
|
||||
</Form>
|
||||
<Button
|
||||
content={t('action.delete')}
|
||||
className={styles.deleteButton}
|
||||
onClick={handleDeleteClick}
|
||||
/>
|
||||
</Popup.Content>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
EditStep.propTypes = {
|
||||
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default withPopup(EditStep);
|
|
@ -0,0 +1,17 @@
|
|||
.deleteButton {
|
||||
bottom: 12px;
|
||||
box-shadow: 0 1px 0 #cbcccc;
|
||||
position: absolute;
|
||||
right: 9px;
|
||||
}
|
||||
|
||||
.field {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.text {
|
||||
color: #444444;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
padding-bottom: 6px;
|
||||
}
|
85
client/src/components/CardModal/Attachments/Item.jsx
Normal file
85
client/src/components/CardModal/Attachments/Item.jsx
Normal file
|
@ -0,0 +1,85 @@
|
|||
import React, { useCallback } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Icon, Loader } from 'semantic-ui-react';
|
||||
|
||||
import EditPopup from './EditPopup';
|
||||
|
||||
import styles from './Item.module.css';
|
||||
|
||||
const Item = React.memo(
|
||||
({ name, url, thumbnailUrl, createdAt, isPersisted, onUpdate, onDelete }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
window.open(url, '_blank');
|
||||
}, [url]);
|
||||
|
||||
if (!isPersisted) {
|
||||
return (
|
||||
<div className={classNames(styles.wrapper, styles.wrapperSubmitting)}>
|
||||
<Loader inverted />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const filename = url.split('/').pop();
|
||||
const extension = filename.slice((Math.max(0, filename.lastIndexOf('.')) || Infinity) + 1);
|
||||
|
||||
return (
|
||||
/* eslint-disable jsx-a11y/click-events-have-key-events,
|
||||
jsx-a11y/no-static-element-interactions */
|
||||
<div className={styles.wrapper} onClick={handleClick}>
|
||||
{/* eslint-enable jsx-a11y/click-events-have-key-events,
|
||||
jsx-a11y/no-static-element-interactions */}
|
||||
<div
|
||||
className={styles.thumbnail}
|
||||
style={{
|
||||
backgroundImage: thumbnailUrl && `url(${thumbnailUrl}`,
|
||||
}}
|
||||
>
|
||||
{!thumbnailUrl && <span className={styles.extension}>{extension || '-'}</span>}
|
||||
</div>
|
||||
<div className={styles.details}>
|
||||
<span className={styles.name}>{name}</span>
|
||||
<span className={styles.options}>
|
||||
{t('format:longDateTime', {
|
||||
postProcess: 'formatDate',
|
||||
value: createdAt,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
<EditPopup
|
||||
defaultData={{
|
||||
name,
|
||||
}}
|
||||
onUpdate={onUpdate}
|
||||
onDelete={onDelete}
|
||||
>
|
||||
<Button className={classNames(styles.button, styles.target)}>
|
||||
<Icon fitted name="pencil" size="small" />
|
||||
</Button>
|
||||
</EditPopup>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Item.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
url: PropTypes.string,
|
||||
thumbnailUrl: PropTypes.string,
|
||||
createdAt: PropTypes.instanceOf(Date),
|
||||
isPersisted: PropTypes.bool.isRequired,
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
Item.defaultProps = {
|
||||
url: undefined,
|
||||
thumbnailUrl: undefined,
|
||||
createdAt: undefined,
|
||||
};
|
||||
|
||||
export default Item;
|
90
client/src/components/CardModal/Attachments/Item.module.css
Normal file
90
client/src/components/CardModal/Attachments/Item.module.css
Normal file
|
@ -0,0 +1,90 @@
|
|||
.button {
|
||||
background: transparent !important;
|
||||
box-shadow: none !important;
|
||||
line-height: 28px !important;
|
||||
margin: 0 !important;
|
||||
min-height: auto !important;
|
||||
opacity: 0;
|
||||
padding: 0 !important;
|
||||
position: absolute;
|
||||
right: 2px;
|
||||
top: 2px;
|
||||
width: 28px;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: rgba(9, 30, 66, 0.08) !important;
|
||||
}
|
||||
|
||||
.details {
|
||||
box-sizing: border-box;
|
||||
padding: 8px 32px 8px 128px;
|
||||
margin: 0;
|
||||
min-height: 80px;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.extension {
|
||||
color: #5e6c84;
|
||||
display: block;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
height: 100%;
|
||||
line-height: 80px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.name {
|
||||
color: #17394d;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
line-height: 20px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.options {
|
||||
display: block;
|
||||
color: #6b808c;
|
||||
line-height: 20px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
border-radius: 3px;
|
||||
background-color: rgba(9, 30, 66, 0.04);
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
border-radius: 3px;
|
||||
height: 80px;
|
||||
left: 0;
|
||||
margin-top: -40px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
top: 50%;
|
||||
width: 112px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
cursor: pointer;
|
||||
margin-bottom: 8px;
|
||||
min-height: 80px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.wrapper:hover .details {
|
||||
background-color: rgba(9, 30, 66, 0.04);
|
||||
}
|
||||
|
||||
.wrapper:hover .target {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.wrapperSubmitting {
|
||||
background-color: rgba(9, 30, 66, 0.04);
|
||||
}
|
3
client/src/components/CardModal/Attachments/index.js
Normal file
3
client/src/components/CardModal/Attachments/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import Attachments from './Attachments';
|
||||
|
||||
export default Attachments;
|
|
@ -3,11 +3,12 @@ import PropTypes from 'prop-types';
|
|||
import classNames from 'classnames';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Grid, Icon, Modal } from 'semantic-ui-react';
|
||||
import { Markdown } from '../../lib/custom-ui';
|
||||
import { FilePicker, Markdown } from '../../lib/custom-ui';
|
||||
|
||||
import NameField from './NameField';
|
||||
import EditDescription from './EditDescription';
|
||||
import Tasks from './Tasks';
|
||||
import Attachments from './Attachments';
|
||||
import Actions from './Actions';
|
||||
import User from '../User';
|
||||
import Label from '../Label';
|
||||
|
@ -33,6 +34,7 @@ const CardModal = React.memo(
|
|||
users,
|
||||
labels,
|
||||
tasks,
|
||||
attachments,
|
||||
actions,
|
||||
allProjectMemberships,
|
||||
allLabels,
|
||||
|
@ -49,6 +51,9 @@ const CardModal = React.memo(
|
|||
onTaskCreate,
|
||||
onTaskUpdate,
|
||||
onTaskDelete,
|
||||
onAttachmentCreate,
|
||||
onAttachmentUpdate,
|
||||
onAttachmentDelete,
|
||||
onActionsFetch,
|
||||
onCommentActionCreate,
|
||||
onCommentActionUpdate,
|
||||
|
@ -93,6 +98,15 @@ const CardModal = React.memo(
|
|||
[onUpdate],
|
||||
);
|
||||
|
||||
const handleAttachmentFileSelect = useCallback(
|
||||
(file) => {
|
||||
onAttachmentCreate({
|
||||
file,
|
||||
});
|
||||
},
|
||||
[onAttachmentCreate],
|
||||
);
|
||||
|
||||
const handleToggleSubscribeClick = useCallback(() => {
|
||||
onUpdate({
|
||||
isSubscribed: !isSubscribed,
|
||||
|
@ -134,7 +148,7 @@ const CardModal = React.memo(
|
|||
onUserSelect={onUserAdd}
|
||||
onUserDeselect={onUserRemove}
|
||||
>
|
||||
<User name={user.name} avatar={user.avatar} />
|
||||
<User name={user.name} avatarUrl={user.avatarUrl} />
|
||||
</ProjectMembershipsPopup>
|
||||
</span>
|
||||
))}
|
||||
|
@ -255,6 +269,19 @@ const CardModal = React.memo(
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
{attachments.length > 0 && (
|
||||
<div className={styles.contentModule}>
|
||||
<div className={styles.moduleWrapper}>
|
||||
<Icon name="attach" className={styles.moduleIcon} />
|
||||
<div className={styles.moduleHeader}>{t('common.attachments')}</div>
|
||||
<Attachments
|
||||
items={attachments}
|
||||
onUpdate={onAttachmentUpdate}
|
||||
onDelete={onAttachmentDelete}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<Actions
|
||||
items={actions}
|
||||
isFetching={isActionsFetching}
|
||||
|
@ -306,6 +333,12 @@ const CardModal = React.memo(
|
|||
{t('common.timer')}
|
||||
</Button>
|
||||
</EditTimerPopup>
|
||||
<FilePicker onSelect={handleAttachmentFileSelect}>
|
||||
<Button fluid className={styles.actionButton}>
|
||||
<Icon name="attach" className={styles.actionIcon} />
|
||||
{t('common.attachment')}
|
||||
</Button>
|
||||
</FilePicker>
|
||||
</div>
|
||||
<div className={styles.actions}>
|
||||
<span className={styles.actionsTitle}>{t('common.actions')}</span>
|
||||
|
@ -347,6 +380,7 @@ CardModal.propTypes = {
|
|||
users: PropTypes.array.isRequired,
|
||||
labels: PropTypes.array.isRequired,
|
||||
tasks: PropTypes.array.isRequired,
|
||||
attachments: PropTypes.array.isRequired,
|
||||
actions: PropTypes.array.isRequired,
|
||||
allProjectMemberships: PropTypes.array.isRequired,
|
||||
allLabels: PropTypes.array.isRequired,
|
||||
|
@ -364,6 +398,9 @@ CardModal.propTypes = {
|
|||
onTaskCreate: PropTypes.func.isRequired,
|
||||
onTaskUpdate: PropTypes.func.isRequired,
|
||||
onTaskDelete: PropTypes.func.isRequired,
|
||||
onAttachmentCreate: PropTypes.func.isRequired,
|
||||
onAttachmentUpdate: PropTypes.func.isRequired,
|
||||
onAttachmentDelete: PropTypes.func.isRequired,
|
||||
onActionsFetch: PropTypes.func.isRequired,
|
||||
onCommentActionCreate: PropTypes.func.isRequired,
|
||||
onCommentActionUpdate: PropTypes.func.isRequired,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.actionButton {
|
||||
background: #ebeef0 !important;
|
||||
box-shadow: 0 1px 0 0 rgba(9, 45, 66, 0.13) !important;
|
||||
box-shadow: 0 1px 0 0 rgba(9, 30, 66, 0.13) !important;
|
||||
color: #444 !important;
|
||||
margin-top: 8px !important;
|
||||
overflow: hidden;
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
.actionButton:hover {
|
||||
background: #dfe3e6 !important;
|
||||
box-shadow: 0 1px 0 0 rgba(9, 45, 66, 0.25) !important;
|
||||
box-shadow: 0 1px 0 0 rgba(9, 30, 66, 0.25) !important;
|
||||
color: #4c4c4c !important;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
|||
}
|
||||
|
||||
.dueDate {
|
||||
background: #dce0e4;
|
||||
background: rgba(9, 30, 66, 0.04);
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
color: #6b808c;
|
||||
|
@ -79,12 +79,12 @@
|
|||
}
|
||||
|
||||
.dueDate:hover {
|
||||
background: #d2d8dc;
|
||||
background: rgba(9, 30, 66, 0.08);
|
||||
color: #17394d;
|
||||
}
|
||||
|
||||
.descriptionButton {
|
||||
background: rgba(9, 45, 66, 0.08);
|
||||
background: rgba(9, 30, 66, 0.04);
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
display: block;
|
||||
|
@ -100,7 +100,7 @@
|
|||
}
|
||||
|
||||
.descriptionButton:hover {
|
||||
background-color: rgba(9, 45, 66, 0.13);
|
||||
background-color: rgba(9, 30, 66, 0.08);
|
||||
color: #092d42;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
.field {
|
||||
background: #fff !important;
|
||||
border: 1px solid rgba(9, 45, 66, 0.13) !important;
|
||||
border: 1px solid rgba(9, 30, 66, 0.13) !important;
|
||||
border-radius: 3px !important;
|
||||
color: #17394d !important;
|
||||
display: block !important;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
.field {
|
||||
background: #fff !important;
|
||||
border: 1px solid rgba(9, 45, 66, 0.13) !important;
|
||||
border: 1px solid rgba(9, 30, 66, 0.08) !important;
|
||||
border-radius: 3px !important;
|
||||
color: #17394d !important;
|
||||
display: block !important;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
.field {
|
||||
background: #fff !important;
|
||||
border: 1px solid rgba(9, 45, 66, 0.13) !important;
|
||||
border: 1px solid rgba(9, 30, 66, 0.13) !important;
|
||||
border-radius: 3px !important;
|
||||
box-sizing: border-box !important;
|
||||
color: #17394d !important;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: rgba(9, 45, 66, 0.13) !important;
|
||||
background-color: rgba(9, 30, 66, 0.08) !important;
|
||||
}
|
||||
|
||||
.checkboxWrapper {
|
||||
|
@ -30,7 +30,7 @@
|
|||
}
|
||||
|
||||
.content:hover {
|
||||
background-color: rgba(9, 45, 66, 0.08);
|
||||
background-color: rgba(9, 30, 66, 0.04);
|
||||
}
|
||||
|
||||
.content:hover .target {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
|
||||
.taskButton:hover {
|
||||
background-color: rgba(9, 45, 66, 0.13);
|
||||
background-color: rgba(9, 30, 66, 0.04);
|
||||
color: #092d42;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ const NotificationsStep = React.memo(({ items, onDelete, onClose }) => {
|
|||
<>
|
||||
<User
|
||||
name={item.action.user.name}
|
||||
avatar={item.action.user.avatar}
|
||||
avatarUrl={item.action.user.avatarUrl}
|
||||
size="large"
|
||||
/>
|
||||
<span className={styles.content}>{renderItemContent(item)}</span>
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
}
|
||||
|
||||
.headerButton:hover {
|
||||
background-color: rgba(9, 45, 66, 0.13) !important;
|
||||
background-color: rgba(9, 30, 66, 0.13) !important;
|
||||
color: #516b7a !important;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ const AddMembershipStep = React.memo(({ users, currentUserIds, onCreate, onClose
|
|||
<UserItem
|
||||
key={user.id}
|
||||
name={user.name}
|
||||
avatar={user.avatar}
|
||||
avatarUrl={user.avatarUrl}
|
||||
isActive={currentUserIds.includes(user.id)}
|
||||
onSelect={() => handleUserSelect(user.id)}
|
||||
/>
|
||||
|
|
|
@ -6,7 +6,7 @@ import User from '../../User';
|
|||
|
||||
import styles from './UserItem.module.css';
|
||||
|
||||
const UserItem = React.memo(({ name, avatar, isActive, onSelect }) => (
|
||||
const UserItem = React.memo(({ name, avatarUrl, isActive, onSelect }) => (
|
||||
<button
|
||||
type="button"
|
||||
disabled={isActive}
|
||||
|
@ -14,7 +14,7 @@ const UserItem = React.memo(({ name, avatar, isActive, onSelect }) => (
|
|||
onClick={onSelect}
|
||||
>
|
||||
<span className={styles.user}>
|
||||
<User name={name} avatar={avatar} />
|
||||
<User name={name} avatarUrl={avatarUrl} />
|
||||
</span>
|
||||
<div className={classNames(styles.menuItemText, isActive && styles.menuItemTextActive)}>
|
||||
{name}
|
||||
|
@ -24,13 +24,13 @@ const UserItem = React.memo(({ name, avatar, isActive, onSelect }) => (
|
|||
|
||||
UserItem.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
avatar: PropTypes.string,
|
||||
avatarUrl: PropTypes.string,
|
||||
isActive: PropTypes.bool.isRequired,
|
||||
onSelect: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
UserItem.defaultProps = {
|
||||
avatar: undefined,
|
||||
avatarUrl: undefined,
|
||||
};
|
||||
|
||||
export default UserItem;
|
||||
|
|
|
@ -39,7 +39,7 @@ const EditMembershipStep = React.memo(({ user, isEditable, onDelete }) => {
|
|||
return (
|
||||
<>
|
||||
<span className={styles.user}>
|
||||
<User name={user.name} avatar={user.avatar} size="large" />
|
||||
<User name={user.name} avatarUrl={user.avatarUrl} size="large" />
|
||||
</span>
|
||||
<span className={styles.content}>
|
||||
<div className={styles.name}>{user.name}</div>
|
||||
|
|
|
@ -56,7 +56,7 @@ const Project = React.memo(
|
|||
>
|
||||
<User
|
||||
name={membership.user.name}
|
||||
avatar={membership.user.avatar}
|
||||
avatarUrl={membership.user.avatarUrl}
|
||||
size="large"
|
||||
isDisabled={!membership.isPersisted}
|
||||
/>
|
||||
|
|
|
@ -24,7 +24,7 @@ const Item = React.memo(({ isPersisted, isActive, user, onUserSelect, onUserDese
|
|||
onClick={handleToggleClick}
|
||||
>
|
||||
<span className={styles.user}>
|
||||
<User name={user.name} avatar={user.avatar} />
|
||||
<User name={user.name} avatarUrl={user.avatarUrl} />
|
||||
</span>
|
||||
<div className={classNames(styles.menuItemText, isActive && styles.menuItemTextActive)}>
|
||||
{user.name}
|
||||
|
|
|
@ -72,10 +72,10 @@ const getColor = (name) => {
|
|||
return COLORS[sum % COLORS.length];
|
||||
};
|
||||
|
||||
const User = React.memo(({ name, avatar, size, isDisabled, onClick }) => {
|
||||
const User = React.memo(({ name, avatarUrl, size, isDisabled, onClick }) => {
|
||||
const style = {
|
||||
...STYLES[size],
|
||||
background: avatar ? `url("${avatar}")` : getColor(name),
|
||||
background: avatarUrl ? `url("${avatarUrl}")` : getColor(name),
|
||||
};
|
||||
|
||||
const contentNode = (
|
||||
|
@ -84,7 +84,7 @@ const User = React.memo(({ name, avatar, size, isDisabled, onClick }) => {
|
|||
className={classNames(styles.wrapper, onClick && styles.hoverable)}
|
||||
style={style}
|
||||
>
|
||||
{!avatar && <span className={styles.initials}>{initials(name)}</span>}
|
||||
{!avatarUrl && <span className={styles.initials}>{initials(name)}</span>}
|
||||
</span>
|
||||
);
|
||||
|
||||
|
@ -99,14 +99,14 @@ const User = React.memo(({ name, avatar, size, isDisabled, onClick }) => {
|
|||
|
||||
User.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
avatar: PropTypes.string,
|
||||
avatarUrl: PropTypes.string,
|
||||
size: PropTypes.oneOf(Object.values(SIZES)),
|
||||
isDisabled: PropTypes.bool,
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
|
||||
User.defaultProps = {
|
||||
avatar: undefined,
|
||||
avatarUrl: undefined,
|
||||
size: SIZES.MEDIUM,
|
||||
isDisabled: false,
|
||||
onClick: undefined,
|
||||
|
|
|
@ -17,15 +17,15 @@ const AccountPane = React.memo(
|
|||
email,
|
||||
name,
|
||||
username,
|
||||
avatar,
|
||||
avatarUrl,
|
||||
phone,
|
||||
organization,
|
||||
isAvatarUploading,
|
||||
isAvatarUpdating,
|
||||
usernameUpdateForm,
|
||||
emailUpdateForm,
|
||||
passwordUpdateForm,
|
||||
onUpdate,
|
||||
onAvatarUpload,
|
||||
onAvatarUpdate,
|
||||
onUsernameUpdate,
|
||||
onUsernameUpdateMessageDismiss,
|
||||
onEmailUpdate,
|
||||
|
@ -37,18 +37,18 @@ const AccountPane = React.memo(
|
|||
|
||||
const handleAvatarDelete = useCallback(() => {
|
||||
onUpdate({
|
||||
avatar: null,
|
||||
avatarUrl: null,
|
||||
});
|
||||
}, [onUpdate]);
|
||||
|
||||
return (
|
||||
<Tab.Pane attached={false} className={styles.wrapper}>
|
||||
<EditAvatarPopup
|
||||
defaultValue={avatar}
|
||||
onUpload={onAvatarUpload}
|
||||
defaultValue={avatarUrl}
|
||||
onUpdate={onAvatarUpdate}
|
||||
onDelete={handleAvatarDelete}
|
||||
>
|
||||
<User name={name} avatar={avatar} size="massive" isDisabled={isAvatarUploading} />
|
||||
<User name={name} avatarUrl={avatarUrl} size="massive" isDisabled={isAvatarUpdating} />
|
||||
</EditAvatarPopup>
|
||||
<br />
|
||||
<br />
|
||||
|
@ -123,17 +123,17 @@ AccountPane.propTypes = {
|
|||
email: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
username: PropTypes.string,
|
||||
avatar: PropTypes.string,
|
||||
avatarUrl: PropTypes.string,
|
||||
phone: PropTypes.string,
|
||||
organization: PropTypes.string,
|
||||
isAvatarUploading: PropTypes.bool.isRequired,
|
||||
isAvatarUpdating: PropTypes.bool.isRequired,
|
||||
/* eslint-disable react/forbid-prop-types */
|
||||
usernameUpdateForm: PropTypes.object.isRequired,
|
||||
emailUpdateForm: PropTypes.object.isRequired,
|
||||
passwordUpdateForm: PropTypes.object.isRequired,
|
||||
/* eslint-enable react/forbid-prop-types */
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onAvatarUpload: PropTypes.func.isRequired,
|
||||
onAvatarUpdate: PropTypes.func.isRequired,
|
||||
onUsernameUpdate: PropTypes.func.isRequired,
|
||||
onUsernameUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||
onEmailUpdate: PropTypes.func.isRequired,
|
||||
|
@ -144,7 +144,7 @@ AccountPane.propTypes = {
|
|||
|
||||
AccountPane.defaultProps = {
|
||||
username: undefined,
|
||||
avatar: undefined,
|
||||
avatarUrl: undefined,
|
||||
phone: undefined,
|
||||
organization: undefined,
|
||||
};
|
||||
|
|
|
@ -3,23 +3,24 @@ import PropTypes from 'prop-types';
|
|||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from 'semantic-ui-react';
|
||||
import { withPopup } from '../../../lib/popup';
|
||||
import { Popup } from '../../../lib/custom-ui';
|
||||
import { FilePicker, Popup } from '../../../lib/custom-ui';
|
||||
|
||||
import styles from './EditAvatarPopup.module.css';
|
||||
|
||||
const EditAvatarStep = React.memo(({ defaultValue, onUpload, onDelete, onClose }) => {
|
||||
const EditAvatarStep = React.memo(({ defaultValue, onUpdate, onDelete, onClose }) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
const field = useRef(null);
|
||||
|
||||
const handleFieldChange = useCallback(
|
||||
({ target }) => {
|
||||
if (target.files[0]) {
|
||||
onUpload(target.files[0]);
|
||||
onClose();
|
||||
}
|
||||
const handleFileSelect = useCallback(
|
||||
(file) => {
|
||||
onUpdate({
|
||||
file,
|
||||
});
|
||||
|
||||
onClose();
|
||||
},
|
||||
[onUpload, onClose],
|
||||
[onUpdate, onClose],
|
||||
);
|
||||
|
||||
const handleDeleteClick = useCallback(() => {
|
||||
|
@ -39,15 +40,14 @@ const EditAvatarStep = React.memo(({ defaultValue, onUpload, onDelete, onClose }
|
|||
})}
|
||||
</Popup.Header>
|
||||
<Popup.Content>
|
||||
<div className={styles.input}>
|
||||
<Button content={t('action.uploadNewAvatar')} className={styles.customButton} />
|
||||
<input
|
||||
ref={field}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
className={styles.file}
|
||||
onChange={handleFieldChange}
|
||||
/>
|
||||
<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} />
|
||||
|
@ -59,7 +59,7 @@ const EditAvatarStep = React.memo(({ defaultValue, onUpload, onDelete, onClose }
|
|||
|
||||
EditAvatarStep.propTypes = {
|
||||
defaultValue: PropTypes.string,
|
||||
onUpload: PropTypes.func.isRequired,
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
};
|
||||
|
|
|
@ -1,25 +1,4 @@
|
|||
.customButton {
|
||||
background: transparent !important;
|
||||
color: #6b808c !important;
|
||||
font-weight: normal !important;
|
||||
height: 36px;
|
||||
line-height: 24px !important;
|
||||
padding: 6px 12px !important;
|
||||
text-align: left !important;
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.file {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.input {
|
||||
.action {
|
||||
border: none;
|
||||
display: inline-block;
|
||||
height: 36px;
|
||||
|
@ -29,6 +8,18 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.input:hover {
|
||||
.action:hover {
|
||||
background: #e9e9e9 !important;
|
||||
}
|
||||
|
||||
.actionButton {
|
||||
background: transparent !important;
|
||||
color: #6b808c !important;
|
||||
font-weight: normal !important;
|
||||
height: 36px;
|
||||
line-height: 24px !important;
|
||||
padding: 6px 12px !important;
|
||||
text-align: left !important;
|
||||
text-decoration: underline !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@ const UserSettingsModal = React.memo(
|
|||
email,
|
||||
name,
|
||||
username,
|
||||
avatar,
|
||||
avatarUrl,
|
||||
phone,
|
||||
organization,
|
||||
subscribeToOwnCards,
|
||||
isAvatarUploading,
|
||||
isAvatarUpdating,
|
||||
usernameUpdateForm,
|
||||
emailUpdateForm,
|
||||
passwordUpdateForm,
|
||||
onUpdate,
|
||||
onAvatarUpload,
|
||||
onAvatarUpdate,
|
||||
onUsernameUpdate,
|
||||
onUsernameUpdateMessageDismiss,
|
||||
onEmailUpdate,
|
||||
|
@ -41,15 +41,15 @@ const UserSettingsModal = React.memo(
|
|||
email={email}
|
||||
name={name}
|
||||
username={username}
|
||||
avatar={avatar}
|
||||
avatarUrl={avatarUrl}
|
||||
phone={phone}
|
||||
organization={organization}
|
||||
isAvatarUploading={isAvatarUploading}
|
||||
isAvatarUpdating={isAvatarUpdating}
|
||||
usernameUpdateForm={usernameUpdateForm}
|
||||
emailUpdateForm={emailUpdateForm}
|
||||
passwordUpdateForm={passwordUpdateForm}
|
||||
onUpdate={onUpdate}
|
||||
onAvatarUpload={onAvatarUpload}
|
||||
onAvatarUpdate={onAvatarUpdate}
|
||||
onUsernameUpdate={onUsernameUpdate}
|
||||
onUsernameUpdateMessageDismiss={onUsernameUpdateMessageDismiss}
|
||||
onEmailUpdate={onEmailUpdate}
|
||||
|
@ -89,18 +89,18 @@ UserSettingsModal.propTypes = {
|
|||
email: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
username: PropTypes.string,
|
||||
avatar: PropTypes.string,
|
||||
avatarUrl: PropTypes.string,
|
||||
phone: PropTypes.string,
|
||||
organization: PropTypes.string,
|
||||
subscribeToOwnCards: PropTypes.bool.isRequired,
|
||||
isAvatarUploading: PropTypes.bool.isRequired,
|
||||
isAvatarUpdating: PropTypes.bool.isRequired,
|
||||
/* eslint-disable react/forbid-prop-types */
|
||||
usernameUpdateForm: PropTypes.object.isRequired,
|
||||
emailUpdateForm: PropTypes.object.isRequired,
|
||||
passwordUpdateForm: PropTypes.object.isRequired,
|
||||
/* eslint-enable react/forbid-prop-types */
|
||||
onUpdate: PropTypes.func.isRequired,
|
||||
onAvatarUpload: PropTypes.func.isRequired,
|
||||
onAvatarUpdate: PropTypes.func.isRequired,
|
||||
onUsernameUpdate: PropTypes.func.isRequired,
|
||||
onUsernameUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||
onEmailUpdate: PropTypes.func.isRequired,
|
||||
|
@ -112,7 +112,7 @@ UserSettingsModal.propTypes = {
|
|||
|
||||
UserSettingsModal.defaultProps = {
|
||||
username: undefined,
|
||||
avatar: undefined,
|
||||
avatarUrl: undefined,
|
||||
phone: undefined,
|
||||
organization: undefined,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue