Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6268ced4cb | ||
|
|
e7495e0067 | ||
|
|
b8c065e0c8 | ||
|
|
86e4864d1b | ||
|
|
0be598ca9e | ||
|
|
ba850801c5 | ||
|
|
c9b23652d1 | ||
|
|
8490629e4c | ||
|
|
76fcd79203 | ||
|
|
3ce1bc0419 | ||
|
|
540fbfceb5 | ||
|
|
48a56648e2 | ||
|
|
6d002c311c |
+2
-6
@@ -16,13 +16,9 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY server/.npmrc server/package.json server/package-lock.json ./
|
COPY server/.npmrc server/package.json server/package-lock.json ./
|
||||||
|
|
||||||
RUN apk add \
|
RUN npm install npm@latest --global \
|
||||||
g++ make python3 \
|
|
||||||
--virtual node-pre-gyp-dependencies \
|
|
||||||
--no-cache \
|
|
||||||
&& npm install npm@latest --global \
|
|
||||||
&& npm install --production \
|
&& npm install --production \
|
||||||
&& apk del node-pre-gyp-dependencies --purge
|
&& apk del vips-dependencies --purge
|
||||||
|
|
||||||
COPY docker-start.sh start.sh
|
COPY docker-start.sh start.sh
|
||||||
COPY server .
|
COPY server .
|
||||||
|
|||||||
+1
-2
@@ -24,5 +24,4 @@ RUN apk -U upgrade \
|
|||||||
&& ./configure \
|
&& ./configure \
|
||||||
&& make \
|
&& make \
|
||||||
&& make install-strip \
|
&& make install-strip \
|
||||||
&& rm -rf /tmp/vips-${VIPS_VERSION} \
|
&& rm -rf /tmp/vips-${VIPS_VERSION}
|
||||||
&& apk del vips-dependencies --purge
|
|
||||||
|
|||||||
Generated
+56
@@ -17,6 +17,7 @@
|
|||||||
"js-cookie": "^3.0.1",
|
"js-cookie": "^3.0.1",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"node-sass": "^7.0.1",
|
"node-sass": "^7.0.1",
|
||||||
|
"photoswipe": "^5.2.7",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-beautiful-dnd": "^13.0.0",
|
"react-beautiful-dnd": "^13.0.0",
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
"react-i18next": "^11.16.6",
|
"react-i18next": "^11.16.6",
|
||||||
"react-input-mask": "^2.0.4",
|
"react-input-mask": "^2.0.4",
|
||||||
"react-markdown": "^8.0.2",
|
"react-markdown": "^8.0.2",
|
||||||
|
"react-photoswipe-gallery": "^2.2.1",
|
||||||
"react-redux": "^7.2.8",
|
"react-redux": "^7.2.8",
|
||||||
"react-router-dom": "^5.3.1",
|
"react-router-dom": "^5.3.1",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
@@ -34,6 +36,7 @@
|
|||||||
"redux-logger": "^3.0.6",
|
"redux-logger": "^3.0.6",
|
||||||
"redux-orm": "^0.16.2",
|
"redux-orm": "^0.16.2",
|
||||||
"redux-saga": "^1.1.3",
|
"redux-saga": "^1.1.3",
|
||||||
|
"remark-breaks": "^3.0.2",
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
"reselect": "^4.1.5",
|
"reselect": "^4.1.5",
|
||||||
"sails.io.js": "^1.2.1",
|
"sails.io.js": "^1.2.1",
|
||||||
@@ -16223,6 +16226,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||||
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
||||||
},
|
},
|
||||||
|
"node_modules/photoswipe": {
|
||||||
|
"version": "5.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.2.7.tgz",
|
||||||
|
"integrity": "sha512-AogMba7W/O5gOtDIZ8cQuou1ltwxlaLNoZY1qi1s+kbYXpZk9D6rXxnNGAfDppl+bfe+sKLW2w2sx+3uQ8oPzg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/picocolors": {
|
"node_modules/picocolors": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
||||||
@@ -18229,6 +18240,16 @@
|
|||||||
"react-dom": "^15.5.x || ^16.x || ^17.x"
|
"react-dom": "^15.5.x || ^16.x || ^17.x"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-photoswipe-gallery": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-photoswipe-gallery/-/react-photoswipe-gallery-2.2.1.tgz",
|
||||||
|
"integrity": "sha512-xaUKKmwRLCpEzB8+bU7yxjXvRBHaInpBcI6YQY0UOeFctHAL3jGRDk9j2YbwmlgN7kRStHTcyrSNxr+zSaOnKg==",
|
||||||
|
"peerDependencies": {
|
||||||
|
"photoswipe": ">= 5.2.2",
|
||||||
|
"prop-types": ">= 15.7.0",
|
||||||
|
"react": ">= 16.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-popper": {
|
"node_modules/react-popper": {
|
||||||
"version": "2.2.5",
|
"version": "2.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.2.5.tgz",
|
||||||
@@ -18824,6 +18845,20 @@
|
|||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/remark-breaks": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/remark-breaks/-/remark-breaks-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-x96YDJ9X+Ry0/JNZFKfr1hpcAKvGYWfUTszxY9RbxKEqq6uzPPoLCuHdZsLPZZUdAv3nCROyc7FPrQLWr2rxyw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^3.0.0",
|
||||||
|
"unified": "^10.0.0",
|
||||||
|
"unist-util-visit": "^4.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/remark-gfm": {
|
"node_modules/remark-gfm": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
|
||||||
@@ -34995,6 +35030,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||||
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
||||||
},
|
},
|
||||||
|
"photoswipe": {
|
||||||
|
"version": "5.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.2.7.tgz",
|
||||||
|
"integrity": "sha512-AogMba7W/O5gOtDIZ8cQuou1ltwxlaLNoZY1qi1s+kbYXpZk9D6rXxnNGAfDppl+bfe+sKLW2w2sx+3uQ8oPzg=="
|
||||||
|
},
|
||||||
"picocolors": {
|
"picocolors": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
||||||
@@ -36304,6 +36344,12 @@
|
|||||||
"integrity": "sha512-a5Q7CkWznBRUWPmocCvE8b6lEYw1s6+opp/60dCunhO+G6E4tDTO2Sd2jKE+leEnnrLAE2Wj5DlDHNqj5wPv1Q==",
|
"integrity": "sha512-a5Q7CkWznBRUWPmocCvE8b6lEYw1s6+opp/60dCunhO+G6E4tDTO2Sd2jKE+leEnnrLAE2Wj5DlDHNqj5wPv1Q==",
|
||||||
"requires": {}
|
"requires": {}
|
||||||
},
|
},
|
||||||
|
"react-photoswipe-gallery": {
|
||||||
|
"version": "2.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-photoswipe-gallery/-/react-photoswipe-gallery-2.2.1.tgz",
|
||||||
|
"integrity": "sha512-xaUKKmwRLCpEzB8+bU7yxjXvRBHaInpBcI6YQY0UOeFctHAL3jGRDk9j2YbwmlgN7kRStHTcyrSNxr+zSaOnKg==",
|
||||||
|
"requires": {}
|
||||||
|
},
|
||||||
"react-popper": {
|
"react-popper": {
|
||||||
"version": "2.2.5",
|
"version": "2.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.2.5.tgz",
|
||||||
@@ -36761,6 +36807,16 @@
|
|||||||
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
|
||||||
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk="
|
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk="
|
||||||
},
|
},
|
||||||
|
"remark-breaks": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/remark-breaks/-/remark-breaks-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-x96YDJ9X+Ry0/JNZFKfr1hpcAKvGYWfUTszxY9RbxKEqq6uzPPoLCuHdZsLPZZUdAv3nCROyc7FPrQLWr2rxyw==",
|
||||||
|
"requires": {
|
||||||
|
"@types/mdast": "^3.0.0",
|
||||||
|
"unified": "^10.0.0",
|
||||||
|
"unist-util-visit": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"remark-gfm": {
|
"remark-gfm": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
|
||||||
|
|||||||
@@ -74,6 +74,7 @@
|
|||||||
"js-cookie": "^3.0.1",
|
"js-cookie": "^3.0.1",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"node-sass": "^7.0.1",
|
"node-sass": "^7.0.1",
|
||||||
|
"photoswipe": "^5.2.7",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-beautiful-dnd": "^13.0.0",
|
"react-beautiful-dnd": "^13.0.0",
|
||||||
@@ -83,6 +84,7 @@
|
|||||||
"react-i18next": "^11.16.6",
|
"react-i18next": "^11.16.6",
|
||||||
"react-input-mask": "^2.0.4",
|
"react-input-mask": "^2.0.4",
|
||||||
"react-markdown": "^8.0.2",
|
"react-markdown": "^8.0.2",
|
||||||
|
"react-photoswipe-gallery": "^2.2.1",
|
||||||
"react-redux": "^7.2.8",
|
"react-redux": "^7.2.8",
|
||||||
"react-router-dom": "^5.3.1",
|
"react-router-dom": "^5.3.1",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
@@ -91,6 +93,7 @@
|
|||||||
"redux-logger": "^3.0.6",
|
"redux-logger": "^3.0.6",
|
||||||
"redux-orm": "^0.16.2",
|
"redux-orm": "^0.16.2",
|
||||||
"redux-saga": "^1.1.3",
|
"redux-saga": "^1.1.3",
|
||||||
|
"remark-breaks": "^3.0.2",
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
"reselect": "^4.1.5",
|
"reselect": "^4.1.5",
|
||||||
"sails.io.js": "^1.2.1",
|
"sails.io.js": "^1.2.1",
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ export const handleUserUpdate = (user) => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updateUserEmail = (id, data) => ({
|
||||||
|
type: EntryActionTypes.USER_EMAIL_UPDATE,
|
||||||
|
payload: {
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const updateCurrentUserEmail = (data) => ({
|
export const updateCurrentUserEmail = (data) => ({
|
||||||
type: EntryActionTypes.CURRENT_USER_EMAIL_UPDATE,
|
type: EntryActionTypes.CURRENT_USER_EMAIL_UPDATE,
|
||||||
payload: {
|
payload: {
|
||||||
@@ -48,11 +56,26 @@ export const updateCurrentUserEmail = (data) => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const clearUserEmailUpdateError = (id) => ({
|
||||||
|
type: EntryActionTypes.USER_EMAIL_UPDATE_ERROR_CLEAR,
|
||||||
|
payload: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const clearCurrentUserEmailUpdateError = () => ({
|
export const clearCurrentUserEmailUpdateError = () => ({
|
||||||
type: EntryActionTypes.CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR,
|
type: EntryActionTypes.CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR,
|
||||||
payload: {},
|
payload: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updateUserPassword = (id, data) => ({
|
||||||
|
type: EntryActionTypes.USER_PASSWORD_UPDATE,
|
||||||
|
payload: {
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const updateCurrentUserPassword = (data) => ({
|
export const updateCurrentUserPassword = (data) => ({
|
||||||
type: EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE,
|
type: EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE,
|
||||||
payload: {
|
payload: {
|
||||||
@@ -60,11 +83,26 @@ export const updateCurrentUserPassword = (data) => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const clearUserPasswordUpdateError = (id) => ({
|
||||||
|
type: EntryActionTypes.USER_PASSWORD_UPDATE_ERROR_CLEAR,
|
||||||
|
payload: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const clearCurrentUserPasswordUpdateError = () => ({
|
export const clearCurrentUserPasswordUpdateError = () => ({
|
||||||
type: EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR,
|
type: EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR,
|
||||||
payload: {},
|
payload: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const updateUserUsername = (id, data) => ({
|
||||||
|
type: EntryActionTypes.USER_USERNAME_UPDATE,
|
||||||
|
payload: {
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const updateCurrentUserUsername = (data) => ({
|
export const updateCurrentUserUsername = (data) => ({
|
||||||
type: EntryActionTypes.CURRENT_USER_USERNAME_UPDATE,
|
type: EntryActionTypes.CURRENT_USER_USERNAME_UPDATE,
|
||||||
payload: {
|
payload: {
|
||||||
@@ -72,6 +110,13 @@ export const updateCurrentUserUsername = (data) => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const clearUserUsernameUpdateError = (id) => ({
|
||||||
|
type: EntryActionTypes.USER_USERNAME_UPDATE_ERROR_CLEAR,
|
||||||
|
payload: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const clearCurrentUserUsernameUpdateError = () => ({
|
export const clearCurrentUserUsernameUpdateError = () => ({
|
||||||
type: EntryActionTypes.CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR,
|
type: EntryActionTypes.CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR,
|
||||||
payload: {},
|
payload: {},
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button } from 'semantic-ui-react';
|
import { Gallery, Item as GalleryItem } from 'react-photoswipe-gallery';
|
||||||
|
import { Button, Grid } from 'semantic-ui-react';
|
||||||
import { useToggle } from '../../../lib/hooks';
|
import { useToggle } from '../../../lib/hooks';
|
||||||
|
|
||||||
import Item from './Item';
|
import Item from './Item';
|
||||||
|
|
||||||
import styles from './Attachments.module.scss';
|
import styles from './Attachments.module.scss';
|
||||||
|
|
||||||
const Attachments = React.memo(({ items, onUpdate, onDelete, onCoverUpdate }) => {
|
const INITIALLY_VISIBLE = 4;
|
||||||
const [t] = useTranslation();
|
|
||||||
const [isOpened, toggleOpened] = useToggle();
|
|
||||||
|
|
||||||
const handleToggleClick = useCallback(() => {
|
const Attachments = React.memo(
|
||||||
toggleOpened();
|
({ items, onUpdate, onDelete, onCoverUpdate, onGalleryOpen, onGalleryClose }) => {
|
||||||
}, [toggleOpened]);
|
const [t] = useTranslation();
|
||||||
|
const [isAllVisible, toggleAllVisible] = useToggle();
|
||||||
|
|
||||||
const handleCoverSelect = useCallback(
|
const handleCoverSelect = useCallback(
|
||||||
(id) => {
|
(id) => {
|
||||||
@@ -41,48 +41,110 @@ const Attachments = React.memo(({ items, onUpdate, onDelete, onCoverUpdate }) =>
|
|||||||
[onDelete],
|
[onDelete],
|
||||||
);
|
);
|
||||||
|
|
||||||
const visibleItems = isOpened ? items : items.slice(0, 4);
|
const handleBeforeGalleryOpen = useCallback(
|
||||||
|
(gallery) => {
|
||||||
|
onGalleryOpen();
|
||||||
|
|
||||||
|
gallery.on('destroy', () => {
|
||||||
|
onGalleryClose();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[onGalleryOpen, onGalleryClose],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleToggleAllVisibleClick = useCallback(() => {
|
||||||
|
toggleAllVisible();
|
||||||
|
}, [toggleAllVisible]);
|
||||||
|
|
||||||
|
const galleryItemsNode = items.map((item, index) => {
|
||||||
|
const props = item.image
|
||||||
|
? item.image
|
||||||
|
: {
|
||||||
|
content: (
|
||||||
|
<Grid verticalAlign="middle" className={styles.contentWrapper}>
|
||||||
|
<Grid.Column textAlign="center" className={styles.content}>
|
||||||
|
{t('common.thereIsNoPreviewAvailableForThisAttachment')}
|
||||||
|
</Grid.Column>
|
||||||
|
</Grid>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
const isVisible = isAllVisible || index < INITIALLY_VISIBLE;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<GalleryItem
|
||||||
{visibleItems.map((item) => (
|
{...props} // eslint-disable-line react/jsx-props-no-spreading
|
||||||
<Item
|
|
||||||
key={item.id}
|
key={item.id}
|
||||||
|
original={item.url}
|
||||||
|
caption={item.name}
|
||||||
|
>
|
||||||
|
{({ ref, open }) =>
|
||||||
|
isVisible ? (
|
||||||
|
<Item
|
||||||
|
ref={ref}
|
||||||
name={item.name}
|
name={item.name}
|
||||||
url={item.url}
|
url={item.url}
|
||||||
coverUrl={item.coverUrl}
|
coverUrl={item.coverUrl}
|
||||||
createdAt={item.createdAt}
|
createdAt={item.createdAt}
|
||||||
isCover={item.isCover}
|
isCover={item.isCover}
|
||||||
isPersisted={item.isPersisted}
|
isPersisted={item.isPersisted}
|
||||||
|
onClick={item.image ? open : undefined}
|
||||||
onCoverSelect={() => handleCoverSelect(item.id)}
|
onCoverSelect={() => handleCoverSelect(item.id)}
|
||||||
onCoverDeselect={handleCoverDeselect}
|
onCoverDeselect={handleCoverDeselect}
|
||||||
onUpdate={(data) => handleUpdate(item.id, data)}
|
onUpdate={(data) => handleUpdate(item.id, data)}
|
||||||
onDelete={() => handleDelete(item.id)}
|
onDelete={() => handleDelete(item.id)}
|
||||||
/>
|
/>
|
||||||
))}
|
) : (
|
||||||
{items.length > 4 && (
|
<span ref={ref} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</GalleryItem>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Gallery
|
||||||
|
withCaption
|
||||||
|
withDownloadButton
|
||||||
|
options={{
|
||||||
|
showHideAnimationType: 'none',
|
||||||
|
closeTitle: '',
|
||||||
|
zoomTitle: '',
|
||||||
|
arrowPrevTitle: '',
|
||||||
|
arrowNextTitle: '',
|
||||||
|
errorMsg: '',
|
||||||
|
}}
|
||||||
|
onBeforeOpen={handleBeforeGalleryOpen}
|
||||||
|
>
|
||||||
|
{galleryItemsNode}
|
||||||
|
</Gallery>
|
||||||
|
{items.length > INITIALLY_VISIBLE && (
|
||||||
<Button
|
<Button
|
||||||
fluid
|
fluid
|
||||||
content={
|
content={
|
||||||
isOpened
|
isAllVisible
|
||||||
? t('action.showFewerAttachments')
|
? t('action.showFewerAttachments')
|
||||||
: t('action.showAllAttachments', {
|
: t('action.showAllAttachments', {
|
||||||
hidden: items.length - visibleItems.length,
|
hidden: items.length - INITIALLY_VISIBLE,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
className={styles.toggleButton}
|
className={styles.toggleButton}
|
||||||
onClick={handleToggleClick}
|
onClick={handleToggleAllVisibleClick}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
Attachments.propTypes = {
|
Attachments.propTypes = {
|
||||||
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
|
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
onUpdate: PropTypes.func.isRequired,
|
onUpdate: PropTypes.func.isRequired,
|
||||||
onDelete: PropTypes.func.isRequired,
|
onDelete: PropTypes.func.isRequired,
|
||||||
onCoverUpdate: PropTypes.func.isRequired,
|
onCoverUpdate: PropTypes.func.isRequired,
|
||||||
|
onGalleryOpen: PropTypes.func.isRequired,
|
||||||
|
onGalleryClose: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Attachments;
|
export default Attachments;
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
:global(#app) {
|
:global(#app) {
|
||||||
|
.content {
|
||||||
|
color: #fff;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contentWrapper {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.toggleButton {
|
.toggleButton {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ import EditPopup from './EditPopup';
|
|||||||
|
|
||||||
import styles from './Item.module.scss';
|
import styles from './Item.module.scss';
|
||||||
|
|
||||||
const Item = React.memo(
|
const Item = React.forwardRef(
|
||||||
({
|
(
|
||||||
|
{
|
||||||
name,
|
name,
|
||||||
url,
|
url,
|
||||||
coverUrl,
|
coverUrl,
|
||||||
@@ -18,14 +19,21 @@ const Item = React.memo(
|
|||||||
isPersisted,
|
isPersisted,
|
||||||
onCoverSelect,
|
onCoverSelect,
|
||||||
onCoverDeselect,
|
onCoverDeselect,
|
||||||
|
onClick,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
onDelete,
|
onDelete,
|
||||||
}) => {
|
},
|
||||||
|
ref,
|
||||||
|
) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback(() => {
|
||||||
|
if (onClick) {
|
||||||
|
onClick();
|
||||||
|
} else {
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}, [url]);
|
}
|
||||||
|
}, [url, onClick]);
|
||||||
|
|
||||||
const handleToggleCoverClick = useCallback(
|
const handleToggleCoverClick = useCallback(
|
||||||
(event) => {
|
(event) => {
|
||||||
@@ -54,7 +62,7 @@ const Item = React.memo(
|
|||||||
return (
|
return (
|
||||||
/* eslint-disable jsx-a11y/click-events-have-key-events,
|
/* eslint-disable jsx-a11y/click-events-have-key-events,
|
||||||
jsx-a11y/no-static-element-interactions */
|
jsx-a11y/no-static-element-interactions */
|
||||||
<div className={styles.wrapper} onClick={handleClick}>
|
<div ref={ref} className={styles.wrapper} onClick={handleClick}>
|
||||||
{/* eslint-enable jsx-a11y/click-events-have-key-events,
|
{/* eslint-enable jsx-a11y/click-events-have-key-events,
|
||||||
jsx-a11y/no-static-element-interactions */}
|
jsx-a11y/no-static-element-interactions */}
|
||||||
<div
|
<div
|
||||||
@@ -133,6 +141,7 @@ Item.propTypes = {
|
|||||||
createdAt: PropTypes.instanceOf(Date),
|
createdAt: PropTypes.instanceOf(Date),
|
||||||
isCover: PropTypes.bool.isRequired,
|
isCover: PropTypes.bool.isRequired,
|
||||||
isPersisted: PropTypes.bool.isRequired,
|
isPersisted: PropTypes.bool.isRequired,
|
||||||
|
onClick: PropTypes.func,
|
||||||
onCoverSelect: PropTypes.func.isRequired,
|
onCoverSelect: PropTypes.func.isRequired,
|
||||||
onCoverDeselect: PropTypes.func.isRequired,
|
onCoverDeselect: PropTypes.func.isRequired,
|
||||||
onUpdate: PropTypes.func.isRequired,
|
onUpdate: PropTypes.func.isRequired,
|
||||||
@@ -143,6 +152,7 @@ Item.defaultProps = {
|
|||||||
url: undefined,
|
url: undefined,
|
||||||
coverUrl: undefined,
|
coverUrl: undefined,
|
||||||
createdAt: undefined,
|
createdAt: undefined,
|
||||||
|
onClick: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Item;
|
export default React.memo(Item);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback } from 'react';
|
import React, { useCallback, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -73,6 +73,8 @@ const CardModal = React.memo(
|
|||||||
}) => {
|
}) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
||||||
|
const isGalleryOpened = useRef(false);
|
||||||
|
|
||||||
const handleNameUpdate = useCallback(
|
const handleNameUpdate = useCallback(
|
||||||
(newName) => {
|
(newName) => {
|
||||||
onUpdate({
|
onUpdate({
|
||||||
@@ -124,6 +126,22 @@ const CardModal = React.memo(
|
|||||||
});
|
});
|
||||||
}, [isSubscribed, onUpdate]);
|
}, [isSubscribed, onUpdate]);
|
||||||
|
|
||||||
|
const handleGalleryOpen = useCallback(() => {
|
||||||
|
isGalleryOpened.current = true;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleGalleryClose = useCallback(() => {
|
||||||
|
isGalleryOpened.current = false;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleClose = useCallback(() => {
|
||||||
|
if (isGalleryOpened.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
onClose();
|
||||||
|
}, [onClose]);
|
||||||
|
|
||||||
const userIds = users.map((user) => user.id);
|
const userIds = users.map((user) => user.id);
|
||||||
const labelIds = labels.map((label) => label.id);
|
const labelIds = labels.map((label) => label.id);
|
||||||
|
|
||||||
@@ -328,6 +346,8 @@ const CardModal = React.memo(
|
|||||||
onUpdate={onAttachmentUpdate}
|
onUpdate={onAttachmentUpdate}
|
||||||
onDelete={onAttachmentDelete}
|
onDelete={onAttachmentDelete}
|
||||||
onCoverUpdate={handleCoverUpdate}
|
onCoverUpdate={handleCoverUpdate}
|
||||||
|
onGalleryOpen={handleGalleryOpen}
|
||||||
|
onGalleryClose={handleGalleryClose}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -445,7 +465,7 @@ const CardModal = React.memo(
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open closeIcon size="small" centered={false} onClose={onClose}>
|
<Modal open closeIcon size="small" centered={false} onClose={handleClose}>
|
||||||
{canEdit ? (
|
{canEdit ? (
|
||||||
<AttachmentAddZone onCreate={onAttachmentCreate}>{contentNode}</AttachmentAddZone>
|
<AttachmentAddZone onCreate={onAttachmentCreate}>{contentNode}</AttachmentAddZone>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import CoreWrapperContainer from '../containers/CoreWrapperContainer';
|
|||||||
import NotFound from './NotFound';
|
import NotFound from './NotFound';
|
||||||
|
|
||||||
import 'react-datepicker/dist/react-datepicker.css';
|
import 'react-datepicker/dist/react-datepicker.css';
|
||||||
|
import 'photoswipe/dist/photoswipe.css';
|
||||||
import '../lib/custom-ui/styles.css';
|
import '../lib/custom-ui/styles.css';
|
||||||
|
|
||||||
import '../styles.module.scss';
|
import '../styles.module.scss';
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const createData = (timer) => {
|
|||||||
const TimerEditStep = React.memo(({ defaultValue, onUpdate, onBack, onClose }) => {
|
const TimerEditStep = React.memo(({ defaultValue, onUpdate, onBack, onClose }) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const [data, handleFieldChange, setData] = useForm(() => createData(defaultValue));
|
const [data, handleFieldChange, setData] = useForm(() => createData(defaultValue));
|
||||||
const [isEditing, toggleEdit] = useToggle();
|
const [isEditing, toggleEditing] = useToggle();
|
||||||
|
|
||||||
const hoursField = useRef(null);
|
const hoursField = useRef(null);
|
||||||
const minutesField = useRef(null);
|
const minutesField = useRef(null);
|
||||||
@@ -55,10 +55,10 @@ const TimerEditStep = React.memo(({ defaultValue, onUpdate, onBack, onClose }) =
|
|||||||
onClose();
|
onClose();
|
||||||
}, [defaultValue, onUpdate, onClose]);
|
}, [defaultValue, onUpdate, onClose]);
|
||||||
|
|
||||||
const handleToggleEditClick = useCallback(() => {
|
const handleToggleEditingClick = useCallback(() => {
|
||||||
setData(createData(defaultValue));
|
setData(createData(defaultValue));
|
||||||
toggleEdit();
|
toggleEditing();
|
||||||
}, [defaultValue, setData, toggleEdit]);
|
}, [defaultValue, setData, toggleEditing]);
|
||||||
|
|
||||||
const handleSubmit = useCallback(() => {
|
const handleSubmit = useCallback(() => {
|
||||||
const parts = {
|
const parts = {
|
||||||
@@ -149,7 +149,7 @@ const TimerEditStep = React.memo(({ defaultValue, onUpdate, onBack, onClose }) =
|
|||||||
type="button"
|
type="button"
|
||||||
icon={isEditing ? 'close' : 'edit'}
|
icon={isEditing ? 'close' : 'edit'}
|
||||||
className={styles.iconButton}
|
className={styles.iconButton}
|
||||||
onClick={handleToggleEditClick}
|
onClick={handleToggleEditingClick}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{isEditing && <Button positive content={t('action.save')} />}
|
{isEditing && <Button positive content={t('action.save')} />}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { withPopup } from '../lib/popup';
|
||||||
|
|
||||||
|
import UserEmailEditStep from './UserEmailEditStep';
|
||||||
|
|
||||||
|
export default withPopup(UserEmailEditStep);
|
||||||
+32
-14
@@ -1,15 +1,15 @@
|
|||||||
|
import omit from 'lodash/omit';
|
||||||
import isEmail from 'validator/lib/isEmail';
|
import isEmail from 'validator/lib/isEmail';
|
||||||
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Form, Message } from 'semantic-ui-react';
|
import { Button, Form, Message } from 'semantic-ui-react';
|
||||||
import { useDidUpdate, usePrevious, useToggle } from '../../../lib/hooks';
|
import { useDidUpdate, usePrevious, useToggle } from '../../lib/hooks';
|
||||||
import { withPopup } from '../../../lib/popup';
|
import { Input, Popup } from '../../lib/custom-ui';
|
||||||
import { Input, Popup } from '../../../lib/custom-ui';
|
|
||||||
|
|
||||||
import { useForm } from '../../../hooks';
|
import { useForm } from '../../hooks';
|
||||||
|
|
||||||
import styles from './EmailEditPopup.module.scss';
|
import styles from './UserEmailEditStep.module.scss';
|
||||||
|
|
||||||
const createMessage = (error) => {
|
const createMessage = (error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@@ -35,8 +35,18 @@ const createMessage = (error) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const EmailEditStep = React.memo(
|
const UserEmailEditStep = React.memo(
|
||||||
({ defaultData, email, isSubmitting, error, onUpdate, onMessageDismiss, onClose }) => {
|
({
|
||||||
|
defaultData,
|
||||||
|
email,
|
||||||
|
isSubmitting,
|
||||||
|
error,
|
||||||
|
usePasswordConfirmation,
|
||||||
|
onUpdate,
|
||||||
|
onMessageDismiss,
|
||||||
|
onBack,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const wasSubmitting = usePrevious(isSubmitting);
|
const wasSubmitting = usePrevious(isSubmitting);
|
||||||
|
|
||||||
@@ -68,13 +78,13 @@ const EmailEditStep = React.memo(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cleanData.currentPassword) {
|
if (usePasswordConfirmation && !cleanData.currentPassword) {
|
||||||
currentPasswordField.current.focus();
|
currentPasswordField.current.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate(cleanData);
|
onUpdate(usePasswordConfirmation ? cleanData : omit(cleanData, 'currentPassword'));
|
||||||
}, [email, onUpdate, onClose, data]);
|
}, [email, usePasswordConfirmation, onUpdate, onClose, data]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
emailField.current.select();
|
emailField.current.select();
|
||||||
@@ -110,7 +120,7 @@ const EmailEditStep = React.memo(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Popup.Header>
|
<Popup.Header onBack={onBack}>
|
||||||
{t('common.editEmail', {
|
{t('common.editEmail', {
|
||||||
context: 'title',
|
context: 'title',
|
||||||
})}
|
})}
|
||||||
@@ -138,6 +148,8 @@ const EmailEditStep = React.memo(
|
|||||||
className={styles.field}
|
className={styles.field}
|
||||||
onChange={handleFieldChange}
|
onChange={handleFieldChange}
|
||||||
/>
|
/>
|
||||||
|
{usePasswordConfirmation && (
|
||||||
|
<>
|
||||||
<div className={styles.text}>{t('common.currentPassword')}</div>
|
<div className={styles.text}>{t('common.currentPassword')}</div>
|
||||||
<Input.Password
|
<Input.Password
|
||||||
fluid
|
fluid
|
||||||
@@ -147,6 +159,8 @@ const EmailEditStep = React.memo(
|
|||||||
className={styles.field}
|
className={styles.field}
|
||||||
onChange={handleFieldChange}
|
onChange={handleFieldChange}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
positive
|
positive
|
||||||
content={t('action.save')}
|
content={t('action.save')}
|
||||||
@@ -160,18 +174,22 @@ const EmailEditStep = React.memo(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
EmailEditStep.propTypes = {
|
UserEmailEditStep.propTypes = {
|
||||||
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
email: PropTypes.string.isRequired,
|
email: PropTypes.string.isRequired,
|
||||||
isSubmitting: PropTypes.bool.isRequired,
|
isSubmitting: PropTypes.bool.isRequired,
|
||||||
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||||
|
usePasswordConfirmation: PropTypes.bool,
|
||||||
onUpdate: PropTypes.func.isRequired,
|
onUpdate: PropTypes.func.isRequired,
|
||||||
onMessageDismiss: PropTypes.func.isRequired,
|
onMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onBack: PropTypes.func,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
EmailEditStep.defaultProps = {
|
UserEmailEditStep.defaultProps = {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
|
usePasswordConfirmation: false,
|
||||||
|
onBack: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withPopup(EmailEditStep);
|
export default UserEmailEditStep;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import UserEmailEditStep from './UserEmailEditStep';
|
||||||
|
|
||||||
|
export default UserEmailEditStep;
|
||||||
+5
-5
@@ -5,11 +5,11 @@ import PropTypes from 'prop-types';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Form, Input } from 'semantic-ui-react';
|
import { Button, Form, Input } from 'semantic-ui-react';
|
||||||
|
|
||||||
import { useForm } from '../../../hooks';
|
import { useForm } from '../../hooks';
|
||||||
|
|
||||||
import styles from './InformationEdit.module.scss';
|
import styles from './UserInformationEdit.module.scss';
|
||||||
|
|
||||||
const InformationEdit = React.memo(({ defaultData, onUpdate }) => {
|
const UserInformationEdit = React.memo(({ defaultData, onUpdate }) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
||||||
const [data, handleFieldChange] = useForm(() => ({
|
const [data, handleFieldChange] = useForm(() => ({
|
||||||
@@ -72,9 +72,9 @@ const InformationEdit = React.memo(({ defaultData, onUpdate }) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
InformationEdit.propTypes = {
|
UserInformationEdit.propTypes = {
|
||||||
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
onUpdate: PropTypes.func.isRequired,
|
onUpdate: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default InformationEdit;
|
export default UserInformationEdit;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import UserInformationEdit from './UserInformationEdit';
|
||||||
|
|
||||||
|
export default UserInformationEdit;
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import React, { useCallback } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Popup } from '../lib/custom-ui';
|
||||||
|
|
||||||
|
import UserInformationEdit from './UserInformationEdit';
|
||||||
|
|
||||||
|
const UserInformationEditStep = React.memo(({ defaultData, onUpdate, onBack, onClose }) => {
|
||||||
|
const [t] = useTranslation();
|
||||||
|
|
||||||
|
const handleUpdate = useCallback(
|
||||||
|
(data) => {
|
||||||
|
onUpdate(data);
|
||||||
|
onClose();
|
||||||
|
},
|
||||||
|
[onUpdate, onClose],
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Popup.Header onBack={onBack}>
|
||||||
|
{t('common.editInformation', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
</Popup.Header>
|
||||||
|
<Popup.Content>
|
||||||
|
<UserInformationEdit defaultData={defaultData} onUpdate={handleUpdate} />
|
||||||
|
</Popup.Content>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
UserInformationEditStep.propTypes = {
|
||||||
|
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
|
onUpdate: PropTypes.func.isRequired,
|
||||||
|
onBack: PropTypes.func,
|
||||||
|
onClose: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
UserInformationEditStep.defaultProps = {
|
||||||
|
onBack: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UserInformationEditStep;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { withPopup } from '../lib/popup';
|
||||||
|
|
||||||
|
import UserPasswordEditStep from './UserPasswordEditStep';
|
||||||
|
|
||||||
|
export default withPopup(UserPasswordEditStep);
|
||||||
+31
-14
@@ -1,14 +1,14 @@
|
|||||||
|
import omit from 'lodash/omit';
|
||||||
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Form, Message } from 'semantic-ui-react';
|
import { Button, Form, Message } from 'semantic-ui-react';
|
||||||
import { useDidUpdate, usePrevious, useToggle } from '../../../lib/hooks';
|
import { useDidUpdate, usePrevious, useToggle } from '../../lib/hooks';
|
||||||
import { withPopup } from '../../../lib/popup';
|
import { Input, Popup } from '../../lib/custom-ui';
|
||||||
import { Input, Popup } from '../../../lib/custom-ui';
|
|
||||||
|
|
||||||
import { useForm } from '../../../hooks';
|
import { useForm } from '../../hooks';
|
||||||
|
|
||||||
import styles from './PasswordEditPopup.module.scss';
|
import styles from './UserPasswordEditStep.module.scss';
|
||||||
|
|
||||||
const createMessage = (error) => {
|
const createMessage = (error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@@ -29,8 +29,17 @@ const createMessage = (error) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const PasswordEditStep = React.memo(
|
const UserPasswordEditStep = React.memo(
|
||||||
({ defaultData, isSubmitting, error, onUpdate, onMessageDismiss, onClose }) => {
|
({
|
||||||
|
defaultData,
|
||||||
|
isSubmitting,
|
||||||
|
error,
|
||||||
|
usePasswordConfirmation,
|
||||||
|
onUpdate,
|
||||||
|
onMessageDismiss,
|
||||||
|
onBack,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const wasSubmitting = usePrevious(isSubmitting);
|
const wasSubmitting = usePrevious(isSubmitting);
|
||||||
|
|
||||||
@@ -52,13 +61,13 @@ const PasswordEditStep = React.memo(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.currentPassword) {
|
if (usePasswordConfirmation && !data.currentPassword) {
|
||||||
currentPasswordField.current.focus();
|
currentPasswordField.current.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate(data);
|
onUpdate(usePasswordConfirmation ? data : omit(data, 'currentPassword'));
|
||||||
}, [onUpdate, data]);
|
}, [usePasswordConfirmation, onUpdate, data]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
passwordField.current.select();
|
passwordField.current.select();
|
||||||
@@ -84,7 +93,7 @@ const PasswordEditStep = React.memo(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Popup.Header>
|
<Popup.Header onBack={onBack}>
|
||||||
{t('common.editPassword', {
|
{t('common.editPassword', {
|
||||||
context: 'title',
|
context: 'title',
|
||||||
})}
|
})}
|
||||||
@@ -111,6 +120,8 @@ const PasswordEditStep = React.memo(
|
|||||||
className={styles.field}
|
className={styles.field}
|
||||||
onChange={handleFieldChange}
|
onChange={handleFieldChange}
|
||||||
/>
|
/>
|
||||||
|
{usePasswordConfirmation && (
|
||||||
|
<>
|
||||||
<div className={styles.text}>{t('common.currentPassword')}</div>
|
<div className={styles.text}>{t('common.currentPassword')}</div>
|
||||||
<Input.Password
|
<Input.Password
|
||||||
fluid
|
fluid
|
||||||
@@ -120,6 +131,8 @@ const PasswordEditStep = React.memo(
|
|||||||
className={styles.field}
|
className={styles.field}
|
||||||
onChange={handleFieldChange}
|
onChange={handleFieldChange}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
positive
|
positive
|
||||||
content={t('action.save')}
|
content={t('action.save')}
|
||||||
@@ -133,17 +146,21 @@ const PasswordEditStep = React.memo(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
PasswordEditStep.propTypes = {
|
UserPasswordEditStep.propTypes = {
|
||||||
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
isSubmitting: PropTypes.bool.isRequired,
|
isSubmitting: PropTypes.bool.isRequired,
|
||||||
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||||
|
usePasswordConfirmation: PropTypes.bool,
|
||||||
onUpdate: PropTypes.func.isRequired,
|
onUpdate: PropTypes.func.isRequired,
|
||||||
onMessageDismiss: PropTypes.func.isRequired,
|
onMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onBack: PropTypes.func,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
PasswordEditStep.defaultProps = {
|
UserPasswordEditStep.defaultProps = {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
|
usePasswordConfirmation: false,
|
||||||
|
onBack: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withPopup(PasswordEditStep);
|
export default UserPasswordEditStep;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import UserPasswordEditStep from './UserPasswordEditStep';
|
||||||
|
|
||||||
|
export default UserPasswordEditStep;
|
||||||
@@ -3,12 +3,12 @@ import PropTypes from 'prop-types';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Divider, Header, Tab } from 'semantic-ui-react';
|
import { Button, Divider, Header, Tab } from 'semantic-ui-react';
|
||||||
|
|
||||||
import InformationEdit from './InformationEdit';
|
|
||||||
import AvatarEditPopup from './AvatarEditPopup';
|
import AvatarEditPopup from './AvatarEditPopup';
|
||||||
import UsernameEditPopup from './UsernameEditPopup';
|
|
||||||
import EmailEditPopup from './EmailEditPopup';
|
|
||||||
import PasswordEditPopup from './PasswordEditPopup';
|
|
||||||
import User from '../../User';
|
import User from '../../User';
|
||||||
|
import UserInformationEdit from '../../UserInformationEdit';
|
||||||
|
import UserUsernameEditPopup from '../../UserUsernameEditPopup';
|
||||||
|
import UserEmailEditPopup from '../../UserEmailEditPopup';
|
||||||
|
import UserPasswordEditPopup from '../../UserPasswordEditPopup';
|
||||||
|
|
||||||
import styles from './AccountPane.module.scss';
|
import styles from './AccountPane.module.scss';
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ const AccountPane = React.memo(
|
|||||||
</AvatarEditPopup>
|
</AvatarEditPopup>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<InformationEdit
|
<UserInformationEdit
|
||||||
defaultData={{
|
defaultData={{
|
||||||
name,
|
name,
|
||||||
phone,
|
phone,
|
||||||
@@ -68,7 +68,8 @@ const AccountPane = React.memo(
|
|||||||
</Header>
|
</Header>
|
||||||
</Divider>
|
</Divider>
|
||||||
<div className={styles.action}>
|
<div className={styles.action}>
|
||||||
<UsernameEditPopup
|
<UserUsernameEditPopup
|
||||||
|
usePasswordConfirmation
|
||||||
defaultData={usernameUpdateForm.data}
|
defaultData={usernameUpdateForm.data}
|
||||||
username={username}
|
username={username}
|
||||||
isSubmitting={usernameUpdateForm.isSubmitting}
|
isSubmitting={usernameUpdateForm.isSubmitting}
|
||||||
@@ -81,10 +82,11 @@ const AccountPane = React.memo(
|
|||||||
context: 'title',
|
context: 'title',
|
||||||
})}
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
</UsernameEditPopup>
|
</UserUsernameEditPopup>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.action}>
|
<div className={styles.action}>
|
||||||
<EmailEditPopup
|
<UserEmailEditPopup
|
||||||
|
usePasswordConfirmation
|
||||||
defaultData={emailUpdateForm.data}
|
defaultData={emailUpdateForm.data}
|
||||||
email={email}
|
email={email}
|
||||||
isSubmitting={emailUpdateForm.isSubmitting}
|
isSubmitting={emailUpdateForm.isSubmitting}
|
||||||
@@ -97,10 +99,11 @@ const AccountPane = React.memo(
|
|||||||
context: 'title',
|
context: 'title',
|
||||||
})}
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
</EmailEditPopup>
|
</UserEmailEditPopup>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.action}>
|
<div className={styles.action}>
|
||||||
<PasswordEditPopup
|
<UserPasswordEditPopup
|
||||||
|
usePasswordConfirmation
|
||||||
defaultData={passwordUpdateForm.data}
|
defaultData={passwordUpdateForm.data}
|
||||||
isSubmitting={passwordUpdateForm.isSubmitting}
|
isSubmitting={passwordUpdateForm.isSubmitting}
|
||||||
error={passwordUpdateForm.error}
|
error={passwordUpdateForm.error}
|
||||||
@@ -112,7 +115,7 @@ const AccountPane = React.memo(
|
|||||||
context: 'title',
|
context: 'title',
|
||||||
})}
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
</PasswordEditPopup>
|
</UserPasswordEditPopup>
|
||||||
</div>
|
</div>
|
||||||
</Tab.Pane>
|
</Tab.Pane>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
:global(#app) {
|
|
||||||
.field {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { withPopup } from '../lib/popup';
|
||||||
|
|
||||||
|
import UserUsernameEditStep from './UserUsernameEditStep';
|
||||||
|
|
||||||
|
export default withPopup(UserUsernameEditStep);
|
||||||
+34
-16
@@ -1,15 +1,15 @@
|
|||||||
|
import omit from 'lodash/omit';
|
||||||
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Form, Message } from 'semantic-ui-react';
|
import { Button, Form, Message } from 'semantic-ui-react';
|
||||||
import { useDidUpdate, usePrevious, useToggle } from '../../../lib/hooks';
|
import { useDidUpdate, usePrevious, useToggle } from '../../lib/hooks';
|
||||||
import { withPopup } from '../../../lib/popup';
|
import { Input, Popup } from '../../lib/custom-ui';
|
||||||
import { Input, Popup } from '../../../lib/custom-ui';
|
|
||||||
|
|
||||||
import { useForm } from '../../../hooks';
|
import { useForm } from '../../hooks';
|
||||||
import { isUsername } from '../../../utils/validator';
|
import { isUsername } from '../../utils/validator';
|
||||||
|
|
||||||
import styles from './UsernameEditPopup.module.scss';
|
import styles from './UserUsernameEditStep.module.scss';
|
||||||
|
|
||||||
const createMessage = (error) => {
|
const createMessage = (error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@@ -35,8 +35,18 @@ const createMessage = (error) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const UsernameEditStep = React.memo(
|
const UserUsernameEditStep = React.memo(
|
||||||
({ defaultData, username, isSubmitting, error, onUpdate, onMessageDismiss, onClose }) => {
|
({
|
||||||
|
defaultData,
|
||||||
|
username,
|
||||||
|
isSubmitting,
|
||||||
|
error,
|
||||||
|
usePasswordConfirmation,
|
||||||
|
onUpdate,
|
||||||
|
onMessageDismiss,
|
||||||
|
onBack,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const wasSubmitting = usePrevious(isSubmitting);
|
const wasSubmitting = usePrevious(isSubmitting);
|
||||||
|
|
||||||
@@ -58,7 +68,7 @@ const UsernameEditStep = React.memo(
|
|||||||
username: data.username.trim() || null,
|
username: data.username.trim() || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (cleanData.username && !isUsername(cleanData.username)) {
|
if (!cleanData.username || !isUsername(cleanData.username)) {
|
||||||
usernameField.current.select();
|
usernameField.current.select();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -68,13 +78,13 @@ const UsernameEditStep = React.memo(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cleanData.currentPassword) {
|
if (usePasswordConfirmation && !cleanData.currentPassword) {
|
||||||
currentPasswordField.current.focus();
|
currentPasswordField.current.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate(cleanData);
|
onUpdate(usePasswordConfirmation ? cleanData : omit(cleanData, 'currentPassword'));
|
||||||
}, [username, onUpdate, onClose, data]);
|
}, [username, usePasswordConfirmation, onUpdate, onClose, data]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
usernameField.current.select();
|
usernameField.current.select();
|
||||||
@@ -110,7 +120,7 @@ const UsernameEditStep = React.memo(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Popup.Header>
|
<Popup.Header onBack={onBack}>
|
||||||
{t('common.editUsername', {
|
{t('common.editUsername', {
|
||||||
context: 'title',
|
context: 'title',
|
||||||
})}
|
})}
|
||||||
@@ -138,6 +148,8 @@ const UsernameEditStep = React.memo(
|
|||||||
className={styles.field}
|
className={styles.field}
|
||||||
onChange={handleFieldChange}
|
onChange={handleFieldChange}
|
||||||
/>
|
/>
|
||||||
|
{usePasswordConfirmation && (
|
||||||
|
<>
|
||||||
<div className={styles.text}>{t('common.currentPassword')}</div>
|
<div className={styles.text}>{t('common.currentPassword')}</div>
|
||||||
<Input.Password
|
<Input.Password
|
||||||
fluid
|
fluid
|
||||||
@@ -147,6 +159,8 @@ const UsernameEditStep = React.memo(
|
|||||||
className={styles.field}
|
className={styles.field}
|
||||||
onChange={handleFieldChange}
|
onChange={handleFieldChange}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
positive
|
positive
|
||||||
content={t('action.save')}
|
content={t('action.save')}
|
||||||
@@ -160,19 +174,23 @@ const UsernameEditStep = React.memo(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
UsernameEditStep.propTypes = {
|
UserUsernameEditStep.propTypes = {
|
||||||
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
defaultData: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
username: PropTypes.string,
|
username: PropTypes.string,
|
||||||
isSubmitting: PropTypes.bool.isRequired,
|
isSubmitting: PropTypes.bool.isRequired,
|
||||||
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
error: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
||||||
|
usePasswordConfirmation: PropTypes.bool,
|
||||||
onUpdate: PropTypes.func.isRequired,
|
onUpdate: PropTypes.func.isRequired,
|
||||||
onMessageDismiss: PropTypes.func.isRequired,
|
onMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onBack: PropTypes.func,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
UsernameEditStep.defaultProps = {
|
UserUsernameEditStep.defaultProps = {
|
||||||
username: undefined,
|
username: undefined,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
|
usePasswordConfirmation: false,
|
||||||
|
onBack: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withPopup(UsernameEditStep);
|
export default UserUsernameEditStep;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
:global(#app) {
|
||||||
|
.field {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
color: #444444;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import UserUsernameEditStep from './UserUsernameEditStep';
|
||||||
|
|
||||||
|
export default UserUsernameEditStep;
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
import React, { useCallback } from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Button, Radio, Table } from 'semantic-ui-react';
|
|
||||||
|
|
||||||
import DeletePopup from '../DeletePopup';
|
|
||||||
|
|
||||||
import styles from './Item.module.scss';
|
|
||||||
|
|
||||||
const Item = React.memo(({ name, username, email, isAdmin, onUpdate, onDelete }) => {
|
|
||||||
const [t] = useTranslation();
|
|
||||||
|
|
||||||
const handleIsAdminChange = useCallback(() => {
|
|
||||||
onUpdate({
|
|
||||||
isAdmin: !isAdmin,
|
|
||||||
});
|
|
||||||
}, [isAdmin, onUpdate]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Table.Row>
|
|
||||||
<Table.Cell>{name}</Table.Cell>
|
|
||||||
<Table.Cell>{username || '-'}</Table.Cell>
|
|
||||||
<Table.Cell>{email}</Table.Cell>
|
|
||||||
<Table.Cell collapsing>
|
|
||||||
<Radio toggle checked={isAdmin} onChange={handleIsAdminChange} />
|
|
||||||
</Table.Cell>
|
|
||||||
<Table.Cell collapsing>
|
|
||||||
<DeletePopup
|
|
||||||
title={t('common.deleteUser', {
|
|
||||||
context: 'title',
|
|
||||||
})}
|
|
||||||
content={t('common.areYouSureYouWantToDeleteThisUser')}
|
|
||||||
buttonContent={t('action.deleteUser')}
|
|
||||||
onConfirm={onDelete}
|
|
||||||
>
|
|
||||||
<Button content={t('action.delete')} className={styles.button} />
|
|
||||||
</DeletePopup>
|
|
||||||
</Table.Cell>
|
|
||||||
</Table.Row>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
Item.propTypes = {
|
|
||||||
name: PropTypes.string.isRequired,
|
|
||||||
username: PropTypes.string,
|
|
||||||
email: PropTypes.string.isRequired,
|
|
||||||
isAdmin: PropTypes.bool.isRequired,
|
|
||||||
onUpdate: PropTypes.func.isRequired,
|
|
||||||
onDelete: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
Item.defaultProps = {
|
|
||||||
username: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Item;
|
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
import pick from 'lodash/pick';
|
||||||
|
import React, { useCallback } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Menu } from 'semantic-ui-react';
|
||||||
|
import { withPopup } from '../../../lib/popup';
|
||||||
|
import { Popup } from '../../../lib/custom-ui';
|
||||||
|
|
||||||
|
import { useSteps } from '../../../hooks';
|
||||||
|
import UserInformationEditStep from '../../UserInformationEditStep';
|
||||||
|
import UserUsernameEditStep from '../../UserUsernameEditStep';
|
||||||
|
import UserEmailEditStep from '../../UserEmailEditStep';
|
||||||
|
import UserPasswordEditStep from '../../UserPasswordEditStep';
|
||||||
|
import DeleteStep from '../../DeleteStep';
|
||||||
|
|
||||||
|
import styles from './ActionsPopup.module.scss';
|
||||||
|
|
||||||
|
const StepTypes = {
|
||||||
|
EDIT_INFORMATION: 'EDIT_INFORMATION',
|
||||||
|
EDIT_USERNAME: 'EDIT_USERNAME',
|
||||||
|
EDIT_EMAIL: 'EDIT_EMAIL',
|
||||||
|
EDIT_PASSWORD: 'EDIT_PASSWORD',
|
||||||
|
DELETE: 'DELETE',
|
||||||
|
};
|
||||||
|
|
||||||
|
const ActionsStep = React.memo(
|
||||||
|
({
|
||||||
|
user,
|
||||||
|
onUpdate,
|
||||||
|
onUsernameUpdate,
|
||||||
|
onUsernameUpdateMessageDismiss,
|
||||||
|
onEmailUpdate,
|
||||||
|
onEmailUpdateMessageDismiss,
|
||||||
|
onPasswordUpdate,
|
||||||
|
onPasswordUpdateMessageDismiss,
|
||||||
|
onDelete,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
|
const [t] = useTranslation();
|
||||||
|
const [step, openStep, handleBack] = useSteps();
|
||||||
|
|
||||||
|
const handleEditInformationClick = useCallback(() => {
|
||||||
|
openStep(StepTypes.EDIT_INFORMATION);
|
||||||
|
}, [openStep]);
|
||||||
|
|
||||||
|
const handleEditUsernameClick = useCallback(() => {
|
||||||
|
openStep(StepTypes.EDIT_USERNAME);
|
||||||
|
}, [openStep]);
|
||||||
|
|
||||||
|
const handleEditEmailClick = useCallback(() => {
|
||||||
|
openStep(StepTypes.EDIT_EMAIL);
|
||||||
|
}, [openStep]);
|
||||||
|
|
||||||
|
const handleEditPasswordClick = useCallback(() => {
|
||||||
|
openStep(StepTypes.EDIT_PASSWORD);
|
||||||
|
}, [openStep]);
|
||||||
|
|
||||||
|
const handleDeleteClick = useCallback(() => {
|
||||||
|
openStep(StepTypes.DELETE);
|
||||||
|
}, [openStep]);
|
||||||
|
|
||||||
|
if (step) {
|
||||||
|
switch (step.type) {
|
||||||
|
case StepTypes.EDIT_INFORMATION:
|
||||||
|
return (
|
||||||
|
<UserInformationEditStep
|
||||||
|
defaultData={pick(user, ['name', 'phone', 'organization'])}
|
||||||
|
onUpdate={onUpdate}
|
||||||
|
onBack={handleBack}
|
||||||
|
onClose={onClose}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case StepTypes.EDIT_USERNAME:
|
||||||
|
return (
|
||||||
|
<UserUsernameEditStep
|
||||||
|
defaultData={user.usernameUpdateForm.data}
|
||||||
|
username={user.username}
|
||||||
|
isSubmitting={user.usernameUpdateForm.isSubmitting}
|
||||||
|
error={user.usernameUpdateForm.error}
|
||||||
|
onUpdate={onUsernameUpdate}
|
||||||
|
onMessageDismiss={onUsernameUpdateMessageDismiss}
|
||||||
|
onBack={handleBack}
|
||||||
|
onClose={onClose}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case StepTypes.EDIT_EMAIL:
|
||||||
|
return (
|
||||||
|
<UserEmailEditStep
|
||||||
|
defaultData={user.emailUpdateForm.data}
|
||||||
|
email={user.email}
|
||||||
|
isSubmitting={user.emailUpdateForm.isSubmitting}
|
||||||
|
error={user.emailUpdateForm.error}
|
||||||
|
onUpdate={onEmailUpdate}
|
||||||
|
onMessageDismiss={onEmailUpdateMessageDismiss}
|
||||||
|
onBack={handleBack}
|
||||||
|
onClose={onClose}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case StepTypes.EDIT_PASSWORD:
|
||||||
|
return (
|
||||||
|
<UserPasswordEditStep
|
||||||
|
defaultData={user.passwordUpdateForm.data}
|
||||||
|
isSubmitting={user.passwordUpdateForm.isSubmitting}
|
||||||
|
error={user.emailUpdateForm.error}
|
||||||
|
onUpdate={onPasswordUpdate}
|
||||||
|
onMessageDismiss={onPasswordUpdateMessageDismiss}
|
||||||
|
onBack={handleBack}
|
||||||
|
onClose={onClose}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case StepTypes.DELETE:
|
||||||
|
return (
|
||||||
|
<DeleteStep
|
||||||
|
title={t('common.deleteUser', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
content={t('common.areYouSureYouWantToDeleteThisUser')}
|
||||||
|
buttonContent={t('action.deleteUser')}
|
||||||
|
onConfirm={onDelete}
|
||||||
|
onBack={handleBack}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Popup.Header>
|
||||||
|
{t('common.userActions', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
</Popup.Header>
|
||||||
|
<Popup.Content>
|
||||||
|
<Menu secondary vertical className={styles.menu}>
|
||||||
|
<Menu.Item className={styles.menuItem} onClick={handleEditInformationClick}>
|
||||||
|
{t('action.editInformation', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item className={styles.menuItem} onClick={handleEditUsernameClick}>
|
||||||
|
{t('action.editUsername', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item className={styles.menuItem} onClick={handleEditEmailClick}>
|
||||||
|
{t('action.editEmail', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item className={styles.menuItem} onClick={handleEditPasswordClick}>
|
||||||
|
{t('action.editPassword', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item className={styles.menuItem} onClick={handleDeleteClick}>
|
||||||
|
{t('action.deleteUser', {
|
||||||
|
context: 'title',
|
||||||
|
})}
|
||||||
|
</Menu.Item>
|
||||||
|
</Menu>
|
||||||
|
</Popup.Content>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
ActionsStep.propTypes = {
|
||||||
|
user: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
|
onUpdate: PropTypes.func.isRequired,
|
||||||
|
onUsernameUpdate: PropTypes.func.isRequired,
|
||||||
|
onUsernameUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onEmailUpdate: PropTypes.func.isRequired,
|
||||||
|
onEmailUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onPasswordUpdate: PropTypes.func.isRequired,
|
||||||
|
onPasswordUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onDelete: PropTypes.func.isRequired,
|
||||||
|
onClose: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withPopup(ActionsStep);
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
:global(#app) {
|
||||||
|
.menu {
|
||||||
|
margin: -7px -12px -5px;
|
||||||
|
width: calc(100% + 24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem {
|
||||||
|
margin: 0;
|
||||||
|
padding-left: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
+103
@@ -0,0 +1,103 @@
|
|||||||
|
import React, { useCallback } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Button, Icon, Radio, Table } from 'semantic-ui-react';
|
||||||
|
|
||||||
|
import ActionsPopup from './ActionsPopup';
|
||||||
|
|
||||||
|
import styles from './Item.module.scss';
|
||||||
|
|
||||||
|
const Item = React.memo(
|
||||||
|
({
|
||||||
|
email,
|
||||||
|
username,
|
||||||
|
name,
|
||||||
|
organization,
|
||||||
|
phone,
|
||||||
|
isAdmin,
|
||||||
|
emailUpdateForm,
|
||||||
|
passwordUpdateForm,
|
||||||
|
usernameUpdateForm,
|
||||||
|
onUpdate,
|
||||||
|
onUsernameUpdate,
|
||||||
|
onUsernameUpdateMessageDismiss,
|
||||||
|
onEmailUpdate,
|
||||||
|
onEmailUpdateMessageDismiss,
|
||||||
|
onPasswordUpdate,
|
||||||
|
onPasswordUpdateMessageDismiss,
|
||||||
|
onDelete,
|
||||||
|
}) => {
|
||||||
|
const handleIsAdminChange = useCallback(() => {
|
||||||
|
onUpdate({
|
||||||
|
isAdmin: !isAdmin,
|
||||||
|
});
|
||||||
|
}, [isAdmin, onUpdate]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table.Row>
|
||||||
|
<Table.Cell>{name}</Table.Cell>
|
||||||
|
<Table.Cell>{username || '-'}</Table.Cell>
|
||||||
|
<Table.Cell>{email}</Table.Cell>
|
||||||
|
<Table.Cell collapsing>
|
||||||
|
<Radio toggle checked={isAdmin} onChange={handleIsAdminChange} />
|
||||||
|
</Table.Cell>
|
||||||
|
<Table.Cell collapsing>
|
||||||
|
<ActionsPopup
|
||||||
|
user={{
|
||||||
|
email,
|
||||||
|
username,
|
||||||
|
name,
|
||||||
|
organization,
|
||||||
|
phone,
|
||||||
|
isAdmin,
|
||||||
|
emailUpdateForm,
|
||||||
|
passwordUpdateForm,
|
||||||
|
usernameUpdateForm,
|
||||||
|
}}
|
||||||
|
onUpdate={onUpdate}
|
||||||
|
onUsernameUpdate={onUsernameUpdate}
|
||||||
|
onUsernameUpdateMessageDismiss={onUsernameUpdateMessageDismiss}
|
||||||
|
onEmailUpdate={onEmailUpdate}
|
||||||
|
onEmailUpdateMessageDismiss={onEmailUpdateMessageDismiss}
|
||||||
|
onPasswordUpdate={onPasswordUpdate}
|
||||||
|
onPasswordUpdateMessageDismiss={onPasswordUpdateMessageDismiss}
|
||||||
|
onDelete={onDelete}
|
||||||
|
>
|
||||||
|
<Button className={styles.button}>
|
||||||
|
<Icon fitted name="pencil" />
|
||||||
|
</Button>
|
||||||
|
</ActionsPopup>
|
||||||
|
</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
Item.propTypes = {
|
||||||
|
email: PropTypes.string.isRequired,
|
||||||
|
username: PropTypes.string,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
organization: PropTypes.string,
|
||||||
|
phone: PropTypes.string,
|
||||||
|
isAdmin: PropTypes.bool.isRequired,
|
||||||
|
/* eslint-disable react/forbid-prop-types */
|
||||||
|
emailUpdateForm: PropTypes.object.isRequired,
|
||||||
|
passwordUpdateForm: PropTypes.object.isRequired,
|
||||||
|
usernameUpdateForm: PropTypes.object.isRequired,
|
||||||
|
/* eslint-enable react/forbid-prop-types */
|
||||||
|
onUpdate: PropTypes.func.isRequired,
|
||||||
|
onUsernameUpdate: PropTypes.func.isRequired,
|
||||||
|
onUsernameUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onEmailUpdate: PropTypes.func.isRequired,
|
||||||
|
onEmailUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onPasswordUpdate: PropTypes.func.isRequired,
|
||||||
|
onPasswordUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onDelete: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
Item.defaultProps = {
|
||||||
|
username: undefined,
|
||||||
|
organization: undefined,
|
||||||
|
phone: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Item;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import Item from './Item';
|
||||||
|
|
||||||
|
export default Item;
|
||||||
@@ -6,7 +6,19 @@ import { Button, Modal, Table } from 'semantic-ui-react';
|
|||||||
import UserAddPopupContainer from '../../containers/UserAddPopupContainer';
|
import UserAddPopupContainer from '../../containers/UserAddPopupContainer';
|
||||||
import Item from './Item';
|
import Item from './Item';
|
||||||
|
|
||||||
const UsersModal = React.memo(({ items, onUpdate, onDelete, onClose }) => {
|
const UsersModal = React.memo(
|
||||||
|
({
|
||||||
|
items,
|
||||||
|
onUpdate,
|
||||||
|
onUsernameUpdate,
|
||||||
|
onUsernameUpdateMessageDismiss,
|
||||||
|
onEmailUpdate,
|
||||||
|
onEmailUpdateMessageDismiss,
|
||||||
|
onPasswordUpdate,
|
||||||
|
onPasswordUpdateMessageDismiss,
|
||||||
|
onDelete,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
||||||
const handleUpdate = useCallback(
|
const handleUpdate = useCallback(
|
||||||
@@ -16,6 +28,48 @@ const UsersModal = React.memo(({ items, onUpdate, onDelete, onClose }) => {
|
|||||||
[onUpdate],
|
[onUpdate],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleUsernameUpdate = useCallback(
|
||||||
|
(id, data) => {
|
||||||
|
onUsernameUpdate(id, data);
|
||||||
|
},
|
||||||
|
[onUsernameUpdate],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleUsernameUpdateMessageDismiss = useCallback(
|
||||||
|
(id) => {
|
||||||
|
onUsernameUpdateMessageDismiss(id);
|
||||||
|
},
|
||||||
|
[onUsernameUpdateMessageDismiss],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleEmailUpdate = useCallback(
|
||||||
|
(id, data) => {
|
||||||
|
onEmailUpdate(id, data);
|
||||||
|
},
|
||||||
|
[onEmailUpdate],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleEmailUpdateMessageDismiss = useCallback(
|
||||||
|
(id) => {
|
||||||
|
onEmailUpdateMessageDismiss(id);
|
||||||
|
},
|
||||||
|
[onEmailUpdateMessageDismiss],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePasswordUpdate = useCallback(
|
||||||
|
(id, data) => {
|
||||||
|
onPasswordUpdate(id, data);
|
||||||
|
},
|
||||||
|
[onPasswordUpdate],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePasswordUpdateMessageDismiss = useCallback(
|
||||||
|
(id) => {
|
||||||
|
onPasswordUpdateMessageDismiss(id);
|
||||||
|
},
|
||||||
|
[onPasswordUpdateMessageDismiss],
|
||||||
|
);
|
||||||
|
|
||||||
const handleDelete = useCallback(
|
const handleDelete = useCallback(
|
||||||
(id) => {
|
(id) => {
|
||||||
onDelete(id);
|
onDelete(id);
|
||||||
@@ -45,11 +99,22 @@ const UsersModal = React.memo(({ items, onUpdate, onDelete, onClose }) => {
|
|||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<Item
|
<Item
|
||||||
key={item.id}
|
key={item.id}
|
||||||
name={item.name}
|
|
||||||
username={item.username}
|
|
||||||
email={item.email}
|
email={item.email}
|
||||||
|
username={item.username}
|
||||||
|
name={item.name}
|
||||||
|
organization={item.organization}
|
||||||
|
phone={item.phone}
|
||||||
isAdmin={item.isAdmin}
|
isAdmin={item.isAdmin}
|
||||||
|
emailUpdateForm={item.emailUpdateForm}
|
||||||
|
passwordUpdateForm={item.passwordUpdateForm}
|
||||||
|
usernameUpdateForm={item.usernameUpdateForm}
|
||||||
onUpdate={(data) => handleUpdate(item.id, data)}
|
onUpdate={(data) => handleUpdate(item.id, data)}
|
||||||
|
onUsernameUpdate={(data) => handleUsernameUpdate(item.id, data)}
|
||||||
|
onUsernameUpdateMessageDismiss={() => handleUsernameUpdateMessageDismiss(item.id)}
|
||||||
|
onEmailUpdate={(data) => handleEmailUpdate(item.id, data)}
|
||||||
|
onEmailUpdateMessageDismiss={() => handleEmailUpdateMessageDismiss(item.id)}
|
||||||
|
onPasswordUpdate={(data) => handlePasswordUpdate(item.id, data)}
|
||||||
|
onPasswordUpdateMessageDismiss={() => handlePasswordUpdateMessageDismiss(item.id)}
|
||||||
onDelete={() => handleDelete(item.id)}
|
onDelete={() => handleDelete(item.id)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -63,11 +128,18 @@ const UsersModal = React.memo(({ items, onUpdate, onDelete, onClose }) => {
|
|||||||
</Modal.Actions>
|
</Modal.Actions>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
UsersModal.propTypes = {
|
UsersModal.propTypes = {
|
||||||
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
|
items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types
|
||||||
onUpdate: PropTypes.func.isRequired,
|
onUpdate: PropTypes.func.isRequired,
|
||||||
|
onUsernameUpdate: PropTypes.func.isRequired,
|
||||||
|
onUsernameUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onEmailUpdate: PropTypes.func.isRequired,
|
||||||
|
onEmailUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
|
onPasswordUpdate: PropTypes.func.isRequired,
|
||||||
|
onPasswordUpdateMessageDismiss: PropTypes.func.isRequired,
|
||||||
onDelete: PropTypes.func.isRequired,
|
onDelete: PropTypes.func.isRequired,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,11 +31,17 @@ export default {
|
|||||||
USER_UPDATE: `${PREFIX}/USER_UPDATE`,
|
USER_UPDATE: `${PREFIX}/USER_UPDATE`,
|
||||||
CURRENT_USER_UPDATE: `${PREFIX}/CURRENT_USER_UPDATE`,
|
CURRENT_USER_UPDATE: `${PREFIX}/CURRENT_USER_UPDATE`,
|
||||||
USER_UPDATE_HANDLE: `${PREFIX}/USER_UPDATE_HANDLE`,
|
USER_UPDATE_HANDLE: `${PREFIX}/USER_UPDATE_HANDLE`,
|
||||||
|
USER_EMAIL_UPDATE: `${PREFIX}/USER_EMAIL_UPDATE`,
|
||||||
CURRENT_USER_EMAIL_UPDATE: `${PREFIX}/CURRENT_USER_EMAIL_UPDATE`,
|
CURRENT_USER_EMAIL_UPDATE: `${PREFIX}/CURRENT_USER_EMAIL_UPDATE`,
|
||||||
|
USER_EMAIL_UPDATE_ERROR_CLEAR: `${PREFIX}/USER_EMAIL_UPDATE_ERROR_CLEAR`,
|
||||||
CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR: `${PREFIX}/CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR`,
|
CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR: `${PREFIX}/CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR`,
|
||||||
|
USER_PASSWORD_UPDATE: `${PREFIX}/USER_PASSWORD_UPDATE`,
|
||||||
CURRENT_USER_PASSWORD_UPDATE: `${PREFIX}/CURRENT_USER_PASSWORD_UPDATE`,
|
CURRENT_USER_PASSWORD_UPDATE: `${PREFIX}/CURRENT_USER_PASSWORD_UPDATE`,
|
||||||
|
USER_PASSWORD_UPDATE_ERROR_CLEAR: `${PREFIX}/USER_PASSWORD_UPDATE_ERROR_CLEAR`,
|
||||||
CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR: `${PREFIX}/CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR`,
|
CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR: `${PREFIX}/CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR`,
|
||||||
|
USER_USERNAME_UPDATE: `${PREFIX}/USER_USERNAME_UPDATE`,
|
||||||
CURRENT_USER_USERNAME_UPDATE: `${PREFIX}/CURRENT_USER_USERNAME_UPDATE`,
|
CURRENT_USER_USERNAME_UPDATE: `${PREFIX}/CURRENT_USER_USERNAME_UPDATE`,
|
||||||
|
USER_USERNAME_UPDATE_ERROR_CLEAR: `${PREFIX}/USER_USERNAME_UPDATE_ERROR_CLEAR`,
|
||||||
CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR: `${PREFIX}/CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR`,
|
CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR: `${PREFIX}/CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR`,
|
||||||
CURRENT_USER_AVATAR_UPDATE: `${PREFIX}/CURRENT_USER_AVATAR_UPDATE`,
|
CURRENT_USER_AVATAR_UPDATE: `${PREFIX}/CURRENT_USER_AVATAR_UPDATE`,
|
||||||
USER_DELETE: `${PREFIX}/USER_DELETE`,
|
USER_DELETE: `${PREFIX}/USER_DELETE`,
|
||||||
|
|||||||
@@ -2,7 +2,17 @@ import { bindActionCreators } from 'redux';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import { usersExceptCurrentSelector } from '../selectors';
|
import { usersExceptCurrentSelector } from '../selectors';
|
||||||
import { closeModal, deleteUser, updateUser } from '../actions/entry';
|
import {
|
||||||
|
clearUserEmailUpdateError,
|
||||||
|
clearUserPasswordUpdateError,
|
||||||
|
clearUserUsernameUpdateError,
|
||||||
|
closeModal,
|
||||||
|
deleteUser,
|
||||||
|
updateUser,
|
||||||
|
updateUserEmail,
|
||||||
|
updateUserPassword,
|
||||||
|
updateUserUsername,
|
||||||
|
} from '../actions/entry';
|
||||||
import UsersModal from '../components/UsersModal';
|
import UsersModal from '../components/UsersModal';
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
@@ -17,6 +27,12 @@ const mapDispatchToProps = (dispatch) =>
|
|||||||
bindActionCreators(
|
bindActionCreators(
|
||||||
{
|
{
|
||||||
onUpdate: updateUser,
|
onUpdate: updateUser,
|
||||||
|
onUsernameUpdate: updateUserUsername,
|
||||||
|
onUsernameUpdateMessageDismiss: clearUserUsernameUpdateError,
|
||||||
|
onEmailUpdate: updateUserEmail,
|
||||||
|
onEmailUpdateMessageDismiss: clearUserEmailUpdateError,
|
||||||
|
onPasswordUpdate: updateUserPassword,
|
||||||
|
onPasswordUpdateMessageDismiss: clearUserPasswordUpdateError,
|
||||||
onDelete: deleteUser,
|
onDelete: deleteUser,
|
||||||
onClose: closeModal,
|
onClose: closeModal,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
|
import remarkBreaks from 'remark-breaks';
|
||||||
|
|
||||||
import './Markdown.module.scss'; // FIXME: import as styles?
|
import './Markdown.module.scss'; // FIXME: import as styles?
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ const Markdown = React.memo(({ linkStopPropagation, ...props }) => {
|
|||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
{...props}
|
{...props}
|
||||||
components={components}
|
components={components}
|
||||||
remarkPlugins={[remarkGfm]}
|
remarkPlugins={[remarkGfm, remarkBreaks]}
|
||||||
className="markdown-body"
|
className="markdown-body"
|
||||||
/>
|
/>
|
||||||
/* eslint-enable react/jsx-props-no-spreading */
|
/* eslint-enable react/jsx-props-no-spreading */
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ export default {
|
|||||||
subscribeToMyOwnCardsByDefault: 'Standardmäßig meine eigenen Karten abonnieren',
|
subscribeToMyOwnCardsByDefault: 'Standardmäßig meine eigenen Karten abonnieren',
|
||||||
taskActions_title: 'Aufgabenaktionen',
|
taskActions_title: 'Aufgabenaktionen',
|
||||||
tasks: 'Aufgaben',
|
tasks: 'Aufgaben',
|
||||||
|
thereIsNoPreviewAvailableForThisAttachment: 'Für diesen Anhang ist keine Vorschau verfügbar',
|
||||||
time: 'Zeit',
|
time: 'Zeit',
|
||||||
timer: 'Timer',
|
timer: 'Timer',
|
||||||
title: 'Titel',
|
title: 'Titel',
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export default {
|
|||||||
editBoard_title: 'Edit Board',
|
editBoard_title: 'Edit Board',
|
||||||
editDueDate_title: 'Edit Due Date',
|
editDueDate_title: 'Edit Due Date',
|
||||||
editEmail_title: 'Edit E-mail',
|
editEmail_title: 'Edit E-mail',
|
||||||
|
editInformation_title: 'Edit Information',
|
||||||
editLabel_title: 'Edit Label',
|
editLabel_title: 'Edit Label',
|
||||||
editPassword_title: 'Edit Password',
|
editPassword_title: 'Edit Password',
|
||||||
editTimer_title: 'Edit Timer',
|
editTimer_title: 'Edit Timer',
|
||||||
@@ -126,6 +127,8 @@ export default {
|
|||||||
subscribeToMyOwnCardsByDefault: 'Subscribe to my own cards by default',
|
subscribeToMyOwnCardsByDefault: 'Subscribe to my own cards by default',
|
||||||
taskActions_title: 'Task Actions',
|
taskActions_title: 'Task Actions',
|
||||||
tasks: 'Tasks',
|
tasks: 'Tasks',
|
||||||
|
thereIsNoPreviewAvailableForThisAttachment:
|
||||||
|
'There is no preview available for this attachment',
|
||||||
time: 'Time',
|
time: 'Time',
|
||||||
timer: 'Timer',
|
timer: 'Timer',
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
@@ -178,6 +181,7 @@ export default {
|
|||||||
editDueDate_title: 'Edit Due Date',
|
editDueDate_title: 'Edit Due Date',
|
||||||
editDescription_title: 'Edit Description',
|
editDescription_title: 'Edit Description',
|
||||||
editEmail_title: 'Edit E-mail',
|
editEmail_title: 'Edit E-mail',
|
||||||
|
editInformation_title: 'Edit Information',
|
||||||
editPassword_title: 'Edit Password',
|
editPassword_title: 'Edit Password',
|
||||||
editTimer_title: 'Edit Timer',
|
editTimer_title: 'Edit Timer',
|
||||||
editTitle_title: 'Edit Title',
|
editTitle_title: 'Edit Title',
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import frLogin from './fr/login';
|
|||||||
import jaLogin from './ja/login';
|
import jaLogin from './ja/login';
|
||||||
import plLogin from './pl/login';
|
import plLogin from './pl/login';
|
||||||
import ruLogin from './ru/login';
|
import ruLogin from './ru/login';
|
||||||
import seLogin from './se/login';
|
import skLogin from './sk/login';
|
||||||
|
import svLogin from './sv/login';
|
||||||
import uzLogin from './uz/login';
|
import uzLogin from './uz/login';
|
||||||
import zhLogin from './zh/login';
|
import zhLogin from './zh/login';
|
||||||
|
|
||||||
@@ -25,7 +26,8 @@ const localePairs = [
|
|||||||
['ja', jaLogin],
|
['ja', jaLogin],
|
||||||
['pl', plLogin],
|
['pl', plLogin],
|
||||||
['ru', ruLogin],
|
['ru', ruLogin],
|
||||||
['se', seLogin],
|
['sk', skLogin],
|
||||||
|
['sv', svLogin],
|
||||||
['uz', uzLogin],
|
['uz', uzLogin],
|
||||||
['zh', zhLogin],
|
['zh', zhLogin],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ export default {
|
|||||||
subscribeToMyOwnCardsByDefault: 'По умолчанию подписаться на мои собственные карточки',
|
subscribeToMyOwnCardsByDefault: 'По умолчанию подписаться на мои собственные карточки',
|
||||||
taskActions: 'Действия с задачей',
|
taskActions: 'Действия с задачей',
|
||||||
tasks: 'Задачи',
|
tasks: 'Задачи',
|
||||||
|
thereIsNoPreviewAvailableForThisAttachment: 'Предпросмотр для этого вложения недоступен',
|
||||||
time: 'Время',
|
time: 'Время',
|
||||||
timer: 'Таймер',
|
timer: 'Таймер',
|
||||||
title: 'Название',
|
title: 'Название',
|
||||||
|
|||||||
@@ -0,0 +1,215 @@
|
|||||||
|
import dateFns from 'date-fns/locale/sk';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
dateFns,
|
||||||
|
|
||||||
|
format: {
|
||||||
|
date: 'd.M.yyyy',
|
||||||
|
time: 'p',
|
||||||
|
dateTime: '$t(format:date) $t(format:time)',
|
||||||
|
longDate: 'd MMM',
|
||||||
|
longDateTime: "d MMMM 'v' p",
|
||||||
|
},
|
||||||
|
|
||||||
|
translation: {
|
||||||
|
common: {
|
||||||
|
account: 'Účet',
|
||||||
|
actions: 'Akcia',
|
||||||
|
addAttachment_title: 'Pridať prílohu',
|
||||||
|
addComment: 'Pridať komentár',
|
||||||
|
addManager_title: 'Pridať správcu',
|
||||||
|
addMember_title: 'Pridať člena',
|
||||||
|
addUser_title: 'Pridať používateľa',
|
||||||
|
administrator: 'Administrátor',
|
||||||
|
all: 'Všetko',
|
||||||
|
allChangesWillBeAutomaticallySavedAfterConnectionRestored:
|
||||||
|
'Všetky zmeny budú automaticky uložené<br />po obnovení spojenia',
|
||||||
|
areYouSureYouWantToDeleteThisAttachment: 'Naozaj chcete zmazať túto prílohu?',
|
||||||
|
areYouSureYouWantToDeleteThisBoard: 'Naozaj chcete zmazať túto tabuľu?',
|
||||||
|
areYouSureYouWantToDeleteThisCard: 'Naozaj chcete zmazať túto kartu?',
|
||||||
|
areYouSureYouWantToDeleteThisComment: 'Naozaj chcete zmazať tento komentár?',
|
||||||
|
areYouSureYouWantToDeleteThisLabel: 'Naozaj chcete zmazať tento štítok?',
|
||||||
|
areYouSureYouWantToDeleteThisList: 'Naozaj chcete zmazať tento zoznam?',
|
||||||
|
areYouSureYouWantToDeleteThisProject: 'Naozaj chcete zmazať tento projekt?',
|
||||||
|
areYouSureYouWantToDeleteThisTask: 'Naozaj chcete zmazať túto úlohu?',
|
||||||
|
areYouSureYouWantToDeleteThisUser: 'Naozaj chcete zmazať tohoto používateľa?',
|
||||||
|
areYouSureYouWantToLeaveBoard: 'Naozaj chcete opustiť túto tabuľu?',
|
||||||
|
areYouSureYouWantToLeaveProject: 'Naozaj chcete opustiť tento projekt?',
|
||||||
|
areYouSureYouWantToRemoveThisManagerFromProject:
|
||||||
|
'Naozaj chcete zmazať daného správcu tohto projektu?',
|
||||||
|
areYouSureYouWantToRemoveThisMemberFromBoard:
|
||||||
|
'Naozaj chcete odstrániť tohoto člena z tabule?',
|
||||||
|
attachment: 'Príloha',
|
||||||
|
attachments: 'Prílohy',
|
||||||
|
authentication: 'Overenie',
|
||||||
|
background: 'Pozadie',
|
||||||
|
board: 'Tabuľa',
|
||||||
|
boardNotFound_title: 'Tabuľa neexistuje',
|
||||||
|
cardActions_title: 'Akcie na karte',
|
||||||
|
cardNotFound_title: 'Karta neexistuje',
|
||||||
|
cardOrActionAreDeleted: 'Karta alebo akcia sú zmazané',
|
||||||
|
color: 'Farba',
|
||||||
|
createBoard_title: 'Vytvoriť tabuľu',
|
||||||
|
createLabel_title: 'Vytvoriť štítok',
|
||||||
|
createNewOneOrSelectExistingOne: 'Vytvoriť nový alebo vyberte<br />už existujúci',
|
||||||
|
createProject_title: 'Vytvoriť projekt',
|
||||||
|
createTextFile_title: 'Vytvoriť textový súbor',
|
||||||
|
currentPassword: 'Aktuálne heslo',
|
||||||
|
dangerZone_title: 'Nebezpečná zóna',
|
||||||
|
date: 'Dátum',
|
||||||
|
dueDate_title: 'Termín do',
|
||||||
|
deleteAttachment_title: 'Zmazať prílohu',
|
||||||
|
deleteBoard_title: 'Zmazať tabuľu',
|
||||||
|
deleteCard_title: 'Zmazať kartu',
|
||||||
|
deleteComment_title: 'Zmazať komentár',
|
||||||
|
deleteLabel_title: 'Zmazať štítok',
|
||||||
|
deleteList_title: 'Zmazať zoznam',
|
||||||
|
deleteProject_title: 'Zmazať projekt',
|
||||||
|
deleteTask_title: 'Zmazať úlohu',
|
||||||
|
deleteUser_title: 'Zmazať používateľa',
|
||||||
|
description: 'Popis',
|
||||||
|
dropFileToUpload: 'Potiahnutím nahraj súbor',
|
||||||
|
editAttachment_title: 'Upraviť prílohu',
|
||||||
|
editAvatar_title: 'Upraviť avatar',
|
||||||
|
editBoard_title: 'Upraviť tabuľu',
|
||||||
|
editDueDate_title: 'Upraviť Termín do',
|
||||||
|
editEmail_title: 'Upraviť e-mail',
|
||||||
|
editInformation_title: 'Upraviť informácie',
|
||||||
|
editLabel_title: 'Upraviť štítok',
|
||||||
|
editPassword_title: 'Upraviť heslo',
|
||||||
|
editTimer_title: 'Upraviť časovač',
|
||||||
|
editUsername_title: 'Upraviť používateľské meno',
|
||||||
|
email: 'E-mail',
|
||||||
|
emailAlreadyInUse: 'E-mail je už použitý',
|
||||||
|
enterCardTitle: 'Vlož názov karty...',
|
||||||
|
enterDescription: 'Vlož popis...',
|
||||||
|
enterFilename: 'Vlož názov súboru',
|
||||||
|
enterListTitle: 'Vlož názov zoznamu...',
|
||||||
|
enterProjectTitle: 'Vlož názov projektu',
|
||||||
|
enterTaskDescription: 'Vlož popis úlohy...',
|
||||||
|
filterByLabels_title: 'Filtruj podľa štítku',
|
||||||
|
filterByMembers_title: 'Filtruj podľa člena',
|
||||||
|
fromComputer_title: 'Z počítača',
|
||||||
|
general: 'Všeobecné',
|
||||||
|
hours: 'Hodiny',
|
||||||
|
invalidCurrentPassword: 'Neplatné aktuálne heslo',
|
||||||
|
labels: 'Štítky',
|
||||||
|
leaveBoard_title: 'Opustiť tabuľu',
|
||||||
|
leaveProject_title: 'Opustiť projekt',
|
||||||
|
list: 'Zoznam',
|
||||||
|
listActions_title: 'Zoznam akcií',
|
||||||
|
managers: 'Správcovia',
|
||||||
|
members: 'Členovia',
|
||||||
|
minutes: 'Minúty',
|
||||||
|
moveCard_title: 'Presunúť kartu',
|
||||||
|
name: 'Meno',
|
||||||
|
newEmail: 'Nový e-mail',
|
||||||
|
newPassword: 'Nové heslo',
|
||||||
|
newUsername: 'Nové používateľské meno',
|
||||||
|
noConnectionToServer: 'Nie je spojenie k serveru',
|
||||||
|
noBoards: 'Žiadne tabule',
|
||||||
|
noLists: 'Žiadne zoznamy',
|
||||||
|
noProjects: 'Žiadne projekty',
|
||||||
|
notifications: 'Oznámenia',
|
||||||
|
noUnreadNotifications: 'Žiadne neprečítané oznámenia',
|
||||||
|
openBoard_title: 'Otvoriť tabuľu',
|
||||||
|
optional_inline: 'voliteľné',
|
||||||
|
organization: 'Spoločnosť',
|
||||||
|
phone: 'Telefón',
|
||||||
|
preferences: 'Voľby',
|
||||||
|
pressPasteShortcutToAddAttachmentFromClipboard:
|
||||||
|
'Tip: stlačte Ctrl-V (Cmd-V na Mac) pre vloženie prílohy zo schránky.',
|
||||||
|
project: 'Projekt',
|
||||||
|
projectNotFound_title: 'Projekt neexistuje',
|
||||||
|
removeManager_title: 'Odstrániť správcu',
|
||||||
|
removeMember_title: 'Odstrániť člena',
|
||||||
|
seconds: 'Sekúnd',
|
||||||
|
selectBoard: 'Vybrať tabuľu',
|
||||||
|
selectList: 'Vybrať zoznam',
|
||||||
|
selectProject: 'Vybrať projekt',
|
||||||
|
settings: 'Nastavenia',
|
||||||
|
subscribeToMyOwnCardsByDefault: 'Predvolene odoberať vlastné karty',
|
||||||
|
taskActions_title: 'Akcie na úlohe',
|
||||||
|
tasks: 'Úlohy',
|
||||||
|
time: 'Čas',
|
||||||
|
timer: 'Časovač',
|
||||||
|
title: 'Názov',
|
||||||
|
userActions_title: 'Akcie na používateľovi',
|
||||||
|
userAddedThisCardToList: '<0>{{user}}</0><1> pridal kartu do {{list}}</1>',
|
||||||
|
userLeftNewCommentToCard: '{{user}} zanechal nový komentár «{{comment}}» k <2>{{card}}</2>',
|
||||||
|
userMovedCardFromListToList: '{{user}} presunul <2>{{card}}</2> z {{fromList}} do {{toList}}',
|
||||||
|
userMovedThisCardFromListToList:
|
||||||
|
'<0>{{user}}</0><1> presunul túto kartu z {{fromList}} do {{toList}}</1>',
|
||||||
|
username: 'Používateľské meno',
|
||||||
|
usernameAlreadyInUse: 'Používateľské meno je zabrané',
|
||||||
|
users: 'Používatelia',
|
||||||
|
writeComment: 'Napísať komentár...',
|
||||||
|
},
|
||||||
|
|
||||||
|
action: {
|
||||||
|
addAnotherCard: 'Pridať ďalšiu kartu',
|
||||||
|
addAnotherList: 'Pridať ďalší zoznam',
|
||||||
|
addAnotherTask: 'Pridať ďalšiu úlohu',
|
||||||
|
addCard: 'Pridať kartu',
|
||||||
|
addCard_title: 'Pridať kartu',
|
||||||
|
addComment: 'Pridať komentár',
|
||||||
|
addList: 'Pridať zoznam',
|
||||||
|
addMoreDetailedDescription: 'Pridať ďalší detailný popis',
|
||||||
|
addTask: 'Pridať úlohu',
|
||||||
|
addToCard: 'Pridať na kartu',
|
||||||
|
addUser: 'Pridať používateľa',
|
||||||
|
createBoard: 'Vytvoriť tabuľu',
|
||||||
|
createFile: 'Vytvoriť súbor',
|
||||||
|
createLabel: 'Vytvoriť štítok',
|
||||||
|
createNewLabel: 'Vytvoriť nový štítok',
|
||||||
|
createProject: 'Vytvoriť projekt',
|
||||||
|
delete: 'Zmazať',
|
||||||
|
deleteAttachment: 'Zmazať prílohu',
|
||||||
|
deleteAvatar: 'Zmazať avatar',
|
||||||
|
deleteBoard: 'Zmazať tabuľu',
|
||||||
|
deleteCard: 'Zmazať kartu',
|
||||||
|
deleteCard_title: 'Zmazať kartu',
|
||||||
|
deleteComment: 'Zmazať komentár',
|
||||||
|
deleteImage: 'Zmazať obrázok',
|
||||||
|
deleteLabel: 'Zmazať štítok',
|
||||||
|
deleteList: 'Zmazať zoznam',
|
||||||
|
deleteList_title: 'Zmazať zoznam',
|
||||||
|
deleteProject: 'Zmazať projekt',
|
||||||
|
deleteProject_title: 'Zmazať projekt',
|
||||||
|
deleteTask: 'Zmazať úlohu',
|
||||||
|
deleteTask_title: 'Zmazať úlohu',
|
||||||
|
deleteUser: 'Zmazať používateľa',
|
||||||
|
edit: 'Upraviť',
|
||||||
|
editDueDate_title: 'Upraviť termín do',
|
||||||
|
editDescription_title: 'Upraviť popis',
|
||||||
|
editEmail_title: 'Upraviť e-mail',
|
||||||
|
editInformation_title: 'Upraviť informácie',
|
||||||
|
editPassword_title: 'Upraviť heslo',
|
||||||
|
editTimer_title: 'Upraviť časovač',
|
||||||
|
editTitle_title: 'Upraviť názov',
|
||||||
|
editUsername_title: 'Upraviť používateľské meno',
|
||||||
|
leaveBoard: 'Opustiť tabuľu',
|
||||||
|
leaveProject: 'Opustiť projekt',
|
||||||
|
logOut_title: 'Odhlásiť sa',
|
||||||
|
makeCover_title: 'Vytvoriť obal',
|
||||||
|
move: 'Presunúť',
|
||||||
|
moveCard_title: 'Presunúť kartu',
|
||||||
|
remove: 'Odstrániť',
|
||||||
|
removeBackground: 'Odstrániť pozadie',
|
||||||
|
removeCover_title: 'Odstrániť obal',
|
||||||
|
removeFromBoard: 'Odstrániť z tabule',
|
||||||
|
removeFromProject: 'Odstrániť z projektu',
|
||||||
|
removeManager: 'Odstrániť správcu',
|
||||||
|
removeMember: 'Odstrániť člena',
|
||||||
|
save: 'Uložiť',
|
||||||
|
showAllAttachments: 'Zozbraziť všetky prílohy ({{hidden}} skryté)',
|
||||||
|
showFewerAttachments: 'Zobraziť menej príloh',
|
||||||
|
start: 'Start',
|
||||||
|
stop: 'Stop',
|
||||||
|
subscribe: 'Odoberať',
|
||||||
|
unsubscribe: 'Neodoberať',
|
||||||
|
uploadNewAvatar: 'Nahrať nový avatar',
|
||||||
|
uploadNewImage: 'Nahrať nový obrázok',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
export default {
|
||||||
|
translation: {
|
||||||
|
common: {
|
||||||
|
emailOrUsername: 'E-mail alebo používateľské meno',
|
||||||
|
invalidEmailOrUsername: 'Nesprávny e-mail alebo používateľské meno',
|
||||||
|
invalidPassword: 'Nesprávne heslo',
|
||||||
|
logInToPlanka: 'Prihlásiť sa do Planka',
|
||||||
|
noInternetConnection: 'Bez pripojenia k internetu',
|
||||||
|
pageNotFound_title: 'Stránka neexistuje',
|
||||||
|
password: 'Heslo',
|
||||||
|
projectManagement: 'Správa projektu',
|
||||||
|
serverConnectionFailed: 'Pripojenie k serveru zlyhalo',
|
||||||
|
unknownError: 'Neznáma chyba, skúste to neskôr',
|
||||||
|
},
|
||||||
|
|
||||||
|
action: {
|
||||||
|
logIn: 'Prihlásiť sa',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import dateFns from 'date-fns/locale/se';
|
import dateFns from 'date-fns/locale/sv';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
dateFns,
|
dateFns,
|
||||||
@@ -24,10 +24,12 @@ export default {
|
|||||||
all: 'Alla',
|
all: 'Alla',
|
||||||
allChangesWillBeAutomaticallySavedAfterConnectionRestored:
|
allChangesWillBeAutomaticallySavedAfterConnectionRestored:
|
||||||
'Alla ändringar kommer att sparas automatiskt<br />så fort anslutningen är återställd',
|
'Alla ändringar kommer att sparas automatiskt<br />så fort anslutningen är återställd',
|
||||||
areYouSureYouWantToDeleteThisAttachment: 'Är du säker på att du vill ta bort den här bilagan?',
|
areYouSureYouWantToDeleteThisAttachment:
|
||||||
|
'Är du säker på att du vill ta bort den här bilagan?',
|
||||||
areYouSureYouWantToDeleteThisBoard: 'Är du säker på att du vill ta bort den här tavlan?',
|
areYouSureYouWantToDeleteThisBoard: 'Är du säker på att du vill ta bort den här tavlan?',
|
||||||
areYouSureYouWantToDeleteThisCard: 'Är du säker på att du vill ta bort det här kortet?',
|
areYouSureYouWantToDeleteThisCard: 'Är du säker på att du vill ta bort det här kortet?',
|
||||||
areYouSureYouWantToDeleteThisComment: 'Är du säker på att du vill ta bort den här kommentaren?',
|
areYouSureYouWantToDeleteThisComment:
|
||||||
|
'Är du säker på att du vill ta bort den här kommentaren?',
|
||||||
areYouSureYouWantToDeleteThisLabel: 'Är du säker på att du vill ta bort den här etiketten?',
|
areYouSureYouWantToDeleteThisLabel: 'Är du säker på att du vill ta bort den här etiketten?',
|
||||||
areYouSureYouWantToDeleteThisList: 'Är du säker på att du vill ta bort den här listan?',
|
areYouSureYouWantToDeleteThisList: 'Är du säker på att du vill ta bort den här listan?',
|
||||||
areYouSureYouWantToDeleteThisProject: 'Är du säker på att du vill ta bort det här projektet?',
|
areYouSureYouWantToDeleteThisProject: 'Är du säker på att du vill ta bort det här projektet?',
|
||||||
@@ -136,7 +138,8 @@ export default {
|
|||||||
userActions_title: 'Användaråtgärder',
|
userActions_title: 'Användaråtgärder',
|
||||||
userAddedThisCardToList: '<0>{{user}}</0><1> lade till detta kort i {{list}}</1>',
|
userAddedThisCardToList: '<0>{{user}}</0><1> lade till detta kort i {{list}}</1>',
|
||||||
userLeftNewCommentToCard: '{{user}} lämnade en ny kommentar «{{comment}}» på <2>{{card}}</2>',
|
userLeftNewCommentToCard: '{{user}} lämnade en ny kommentar «{{comment}}» på <2>{{card}}</2>',
|
||||||
userMovedCardFromListToList: '{{user}} flyttade <2>{{card}}</2> från {{fromList}} till {{toList}}',
|
userMovedCardFromListToList:
|
||||||
|
'{{user}} flyttade <2>{{card}}</2> från {{fromList}} till {{toList}}',
|
||||||
userMovedThisCardFromListToList:
|
userMovedThisCardFromListToList:
|
||||||
'<0>{{user}}</0><1> flyttade detta kort från {{fromList}} till {{toList}}</1>',
|
'<0>{{user}}</0><1> flyttade detta kort från {{fromList}} till {{toList}}</1>',
|
||||||
username: 'Användarnamn',
|
username: 'Användarnamn',
|
||||||
@@ -9,6 +9,7 @@ export default class extends Model {
|
|||||||
id: attr(),
|
id: attr(),
|
||||||
url: attr(),
|
url: attr(),
|
||||||
coverUrl: attr(),
|
coverUrl: attr(),
|
||||||
|
image: attr(),
|
||||||
name: attr(),
|
name: attr(),
|
||||||
cardId: fk({
|
cardId: fk({
|
||||||
to: 'Card',
|
to: 'Card',
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export default class extends Model {
|
|||||||
static fields = {
|
static fields = {
|
||||||
id: attr(),
|
id: attr(),
|
||||||
email: attr(),
|
email: attr(),
|
||||||
|
username: attr(),
|
||||||
name: attr(),
|
name: attr(),
|
||||||
avatarUrl: attr(),
|
avatarUrl: attr(),
|
||||||
phone: attr(),
|
phone: attr(),
|
||||||
@@ -140,6 +141,18 @@ export default class extends Model {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ActionTypes.USER_EMAIL_UPDATE_ERROR_CLEAR: {
|
||||||
|
const userModel = User.withId(payload.id);
|
||||||
|
|
||||||
|
userModel.update({
|
||||||
|
emailUpdateForm: {
|
||||||
|
...userModel.emailUpdateForm,
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ActionTypes.USER_PASSWORD_UPDATE: {
|
case ActionTypes.USER_PASSWORD_UPDATE: {
|
||||||
const userModel = User.withId(payload.id);
|
const userModel = User.withId(payload.id);
|
||||||
|
|
||||||
@@ -174,6 +187,18 @@ export default class extends Model {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ActionTypes.USER_PASSWORD_UPDATE_ERROR_CLEAR: {
|
||||||
|
const userModel = User.withId(payload.id);
|
||||||
|
|
||||||
|
userModel.update({
|
||||||
|
passwordUpdateForm: {
|
||||||
|
...userModel.passwordUpdateForm,
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ActionTypes.USER_USERNAME_UPDATE: {
|
case ActionTypes.USER_USERNAME_UPDATE: {
|
||||||
const userModel = User.withId(payload.id);
|
const userModel = User.withId(payload.id);
|
||||||
|
|
||||||
@@ -208,6 +233,18 @@ export default class extends Model {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ActionTypes.USER_USERNAME_UPDATE_ERROR_CLEAR: {
|
||||||
|
const userModel = User.withId(payload.id);
|
||||||
|
|
||||||
|
userModel.update({
|
||||||
|
usernameUpdateForm: {
|
||||||
|
...userModel.usernameUpdateForm,
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ActionTypes.USER_AVATAR_UPDATE:
|
case ActionTypes.USER_AVATAR_UPDATE:
|
||||||
User.withId(payload.id).update({
|
User.withId(payload.id).update({
|
||||||
isAvatarUpdating: true,
|
isAvatarUpdating: true,
|
||||||
|
|||||||
@@ -8,8 +8,16 @@ import {
|
|||||||
clearCurrentUserPasswordUpdateErrorService,
|
clearCurrentUserPasswordUpdateErrorService,
|
||||||
clearCurrentUserUsernameUpdateErrorService,
|
clearCurrentUserUsernameUpdateErrorService,
|
||||||
clearUserCreateErrorService,
|
clearUserCreateErrorService,
|
||||||
|
clearUserEmailUpdateErrorService,
|
||||||
|
clearUserPasswordUpdateErrorService,
|
||||||
|
clearUserUsernameUpdateErrorService,
|
||||||
createUserService,
|
createUserService,
|
||||||
deleteUserService,
|
deleteUserService,
|
||||||
|
handleUserCreateService,
|
||||||
|
handleUserDeleteService,
|
||||||
|
handleUserFromCardRemoveService,
|
||||||
|
handleUserToCardAddService,
|
||||||
|
handleUserUpdateService,
|
||||||
removeUserFromCardService,
|
removeUserFromCardService,
|
||||||
removeUserFromCurrentCardService,
|
removeUserFromCurrentCardService,
|
||||||
removeUserFromFilterInCurrentBoardService,
|
removeUserFromFilterInCurrentBoardService,
|
||||||
@@ -19,11 +27,9 @@ import {
|
|||||||
updateCurrentUserPasswordService,
|
updateCurrentUserPasswordService,
|
||||||
updateCurrentUserService,
|
updateCurrentUserService,
|
||||||
updateCurrentUserUsernameService,
|
updateCurrentUserUsernameService,
|
||||||
handleUserCreateService,
|
updateUserEmailService,
|
||||||
handleUserUpdateService,
|
updateUserPasswordService,
|
||||||
handleUserDeleteService,
|
updateUserUsernameService,
|
||||||
handleUserToCardAddService,
|
|
||||||
handleUserFromCardRemoveService,
|
|
||||||
} from '../services';
|
} from '../services';
|
||||||
import EntryActionTypes from '../../../constants/EntryActionTypes';
|
import EntryActionTypes from '../../../constants/EntryActionTypes';
|
||||||
|
|
||||||
@@ -43,21 +49,39 @@ export default function* userWatchers() {
|
|||||||
takeEvery(EntryActionTypes.USER_UPDATE_HANDLE, ({ payload: { user } }) =>
|
takeEvery(EntryActionTypes.USER_UPDATE_HANDLE, ({ payload: { user } }) =>
|
||||||
handleUserUpdateService(user),
|
handleUserUpdateService(user),
|
||||||
),
|
),
|
||||||
|
takeEvery(EntryActionTypes.USER_EMAIL_UPDATE, ({ payload: { id, data } }) =>
|
||||||
|
updateUserEmailService(id, data),
|
||||||
|
),
|
||||||
takeEvery(EntryActionTypes.CURRENT_USER_EMAIL_UPDATE, ({ payload: { data } }) =>
|
takeEvery(EntryActionTypes.CURRENT_USER_EMAIL_UPDATE, ({ payload: { data } }) =>
|
||||||
updateCurrentUserEmailService(data),
|
updateCurrentUserEmailService(data),
|
||||||
),
|
),
|
||||||
|
takeEvery(EntryActionTypes.USER_EMAIL_UPDATE_ERROR_CLEAR, ({ payload: { id } }) =>
|
||||||
|
clearUserEmailUpdateErrorService(id),
|
||||||
|
),
|
||||||
takeEvery(EntryActionTypes.CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR, () =>
|
takeEvery(EntryActionTypes.CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR, () =>
|
||||||
clearCurrentUserEmailUpdateErrorService(),
|
clearCurrentUserEmailUpdateErrorService(),
|
||||||
),
|
),
|
||||||
|
takeEvery(EntryActionTypes.USER_PASSWORD_UPDATE, ({ payload: { id, data } }) =>
|
||||||
|
updateUserPasswordService(id, data),
|
||||||
|
),
|
||||||
takeEvery(EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE, ({ payload: { data } }) =>
|
takeEvery(EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE, ({ payload: { data } }) =>
|
||||||
updateCurrentUserPasswordService(data),
|
updateCurrentUserPasswordService(data),
|
||||||
),
|
),
|
||||||
|
takeEvery(EntryActionTypes.USER_PASSWORD_UPDATE_ERROR_CLEAR, ({ payload: { id } }) =>
|
||||||
|
clearUserPasswordUpdateErrorService(id),
|
||||||
|
),
|
||||||
takeEvery(EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR, () =>
|
takeEvery(EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR, () =>
|
||||||
clearCurrentUserPasswordUpdateErrorService(),
|
clearCurrentUserPasswordUpdateErrorService(),
|
||||||
),
|
),
|
||||||
|
takeEvery(EntryActionTypes.USER_USERNAME_UPDATE, ({ payload: { id, data } }) =>
|
||||||
|
updateUserUsernameService(id, data),
|
||||||
|
),
|
||||||
takeEvery(EntryActionTypes.CURRENT_USER_USERNAME_UPDATE, ({ payload: { data } }) =>
|
takeEvery(EntryActionTypes.CURRENT_USER_USERNAME_UPDATE, ({ payload: { data } }) =>
|
||||||
updateCurrentUserUsernameService(data),
|
updateCurrentUserUsernameService(data),
|
||||||
),
|
),
|
||||||
|
takeEvery(EntryActionTypes.USER_USERNAME_UPDATE_ERROR_CLEAR, ({ payload: { id } }) =>
|
||||||
|
clearUserUsernameUpdateErrorService(id),
|
||||||
|
),
|
||||||
takeEvery(EntryActionTypes.CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR, () =>
|
takeEvery(EntryActionTypes.CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR, () =>
|
||||||
clearCurrentUserUsernameUpdateErrorService(),
|
clearCurrentUserUsernameUpdateErrorService(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -101,6 +101,10 @@
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pswp .pswp__img--placeholder {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "planka",
|
"name": "planka",
|
||||||
"version": "0.1.0",
|
"version": "1.2.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "planka",
|
"name": "planka",
|
||||||
"version": "0.1.0",
|
"version": "1.2.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "planka",
|
"name": "planka",
|
||||||
"version": "1.1.3",
|
"version": "1.2.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "https://plankanban.github.io/planka",
|
"homepage": "https://plankanban.github.io/planka",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -54,10 +54,8 @@ module.exports = {
|
|||||||
|
|
||||||
const attachment = await sails.helpers.attachments.createOne(
|
const attachment = await sails.helpers.attachments.createOne(
|
||||||
{
|
{
|
||||||
dirname: file.extra.dirname,
|
...file.extra,
|
||||||
filename: file.filename,
|
filename: file.filename,
|
||||||
isImage: file.extra.isImage,
|
|
||||||
name: file.extra.name,
|
|
||||||
},
|
},
|
||||||
currentUser,
|
currentUser,
|
||||||
card,
|
card,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attachment.isImage) {
|
if (!attachment.image) {
|
||||||
throw Errors.ATTACHMENT_NOT_FOUND;
|
throw Errors.ATTACHMENT_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.res.type(attachment.filename);
|
this.res.type(attachment.filename);
|
||||||
if (!attachment.isImage && path.extname(attachment.filename) !== '.pdf') {
|
if (!attachment.image && path.extname(attachment.filename) !== '.pdf') {
|
||||||
this.res.set('Content-Disposition', 'attachment');
|
this.res.set('Content-Disposition', 'attachment');
|
||||||
}
|
}
|
||||||
this.res.set('Cache-Control', 'private, max-age=900'); // TODO: move to config
|
this.res.set('Cache-Control', 'private, max-age=900'); // TODO: move to config
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ module.exports = {
|
|||||||
inputs.request,
|
inputs.request,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!inputs.card.coverAttachmentId && attachment.isImage) {
|
if (!inputs.card.coverAttachmentId && attachment.image) {
|
||||||
await sails.helpers.cards.updateOne(inputs.card, {
|
await sails.helpers.cards.updateOne(inputs.card, {
|
||||||
coverAttachmentId: attachment.id,
|
coverAttachmentId: attachment.id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -43,15 +43,20 @@ module.exports = {
|
|||||||
await writeFile(path.join(rootPath, filename), buffer);
|
await writeFile(path.join(rootPath, filename), buffer);
|
||||||
|
|
||||||
const image = sharp(buffer);
|
const image = sharp(buffer);
|
||||||
let imageMetadata;
|
let metadata;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
imageMetadata = await image.metadata();
|
metadata = await image.metadata();
|
||||||
} catch (error) {} // eslint-disable-line no-empty
|
} catch (error) {} // eslint-disable-line no-empty
|
||||||
|
|
||||||
if (imageMetadata) {
|
const extra = {
|
||||||
|
dirname,
|
||||||
|
name: file.filename,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (metadata && !['svg', 'pdf'].includes(metadata.format)) {
|
||||||
let cover256Buffer;
|
let cover256Buffer;
|
||||||
if (imageMetadata.height > imageMetadata.width) {
|
if (metadata.height > metadata.width) {
|
||||||
cover256Buffer = await image
|
cover256Buffer = await image
|
||||||
.resize(256, 320)
|
.resize(256, 320)
|
||||||
.jpeg({
|
.jpeg({
|
||||||
@@ -75,17 +80,16 @@ module.exports = {
|
|||||||
fs.mkdirSync(thumbnailsPath);
|
fs.mkdirSync(thumbnailsPath);
|
||||||
|
|
||||||
await writeFile(path.join(thumbnailsPath, 'cover-256.jpg'), cover256Buffer);
|
await writeFile(path.join(thumbnailsPath, 'cover-256.jpg'), cover256Buffer);
|
||||||
|
|
||||||
|
extra.image = _.pick(metadata, ['width', 'height']);
|
||||||
|
} else {
|
||||||
|
extra.image = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
Object.assign(file, {
|
||||||
file.extra = {
|
filename,
|
||||||
dirname,
|
extra,
|
||||||
isImage: !!imageMetadata,
|
});
|
||||||
name: file.filename,
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
file.filename = filename;
|
|
||||||
|
|
||||||
return done();
|
return done();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ module.exports = {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
isImage: {
|
image: {
|
||||||
type: 'boolean',
|
type: 'json',
|
||||||
required: true,
|
|
||||||
columnName: 'is_image',
|
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@@ -51,9 +49,9 @@ module.exports = {
|
|||||||
|
|
||||||
customToJSON() {
|
customToJSON() {
|
||||||
return {
|
return {
|
||||||
..._.omit(this, ['dirname', 'filename', 'isImage']),
|
..._.omit(this, ['dirname', 'filename']),
|
||||||
url: `${sails.config.custom.attachmentsUrl}/${this.id}/download/${this.filename}`,
|
url: `${sails.config.custom.attachmentsUrl}/${this.id}/download/${this.filename}`,
|
||||||
coverUrl: this.isImage
|
coverUrl: this.image
|
||||||
? `${sails.config.custom.attachmentsUrl}/${this.id}/download/thumbnails/cover-256.jpg`
|
? `${sails.config.custom.attachmentsUrl}/${this.id}/download/thumbnails/cover-256.jpg`
|
||||||
: null,
|
: null,
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-3
@@ -20,20 +20,24 @@
|
|||||||
* https://sailsjs.com/anatomy/app.js
|
* https://sailsjs.com/anatomy/app.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('dotenv').config();
|
const dotenv = require('dotenv');
|
||||||
|
|
||||||
// Ensure we're in the project directory, so cwd-relative paths work as expected
|
// Ensure we're in the project directory, so cwd-relative paths work as expected
|
||||||
// no matter where we actually lift from.
|
// no matter where we actually lift from.
|
||||||
// > Note: This is not required in order to lift, but it is a convenient default.
|
// > Note: This is not required in order to lift, but it is a convenient default.
|
||||||
process.chdir(__dirname);
|
process.chdir(__dirname);
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
// Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files).
|
// Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files).
|
||||||
let sails;
|
let sails;
|
||||||
let rc;
|
let rc;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sails = require('sails'); // eslint-disable-line global-require
|
/* eslint-disable global-require */
|
||||||
rc = require('sails/accessible/rc'); // eslint-disable-line global-require
|
sails = require('sails');
|
||||||
|
rc = require('sails/accessible/rc');
|
||||||
|
/* eslint-enable global-require */
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.error("Encountered an error when attempting to require('sails'):");
|
console.error("Encountered an error when attempting to require('sails'):");
|
||||||
|
|||||||
+5
-3
@@ -1,10 +1,12 @@
|
|||||||
const config = require('./knexfile');
|
const initKnex = require('knex');
|
||||||
|
|
||||||
const knex = require('knex')(config); // eslint-disable-line import/order
|
const knexfile = require('./knexfile');
|
||||||
|
|
||||||
|
const knex = initKnex(knexfile);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const isExists = await knex.schema.hasTable(config.migrations.tableName);
|
const isExists = await knex.schema.hasTable(knexfile.migrations.tableName);
|
||||||
|
|
||||||
await knex.migrate.latest();
|
await knex.migrate.latest();
|
||||||
if (!isExists) {
|
if (!isExists) {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const dotenv = require('dotenv');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
require('dotenv').config({
|
dotenv.config({
|
||||||
path: path.resolve(__dirname, '../.env'),
|
path: path.resolve(__dirname, '../.env'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module.exports.up = (knex) =>
|
module.exports.up = (knex) =>
|
||||||
knex.schema.createTable('card', (table) => {
|
knex.schema.createTable('card', async (table) => {
|
||||||
/* Columns */
|
/* Columns */
|
||||||
|
|
||||||
table.bigInteger('id').primary().defaultTo(knex.raw('next_id()'));
|
table.bigInteger('id').primary().defaultTo(knex.raw('next_id()'));
|
||||||
@@ -12,7 +12,7 @@ module.exports.up = (knex) =>
|
|||||||
table.specificType('position', 'double precision');
|
table.specificType('position', 'double precision');
|
||||||
table.text('name').notNullable();
|
table.text('name').notNullable();
|
||||||
table.text('description');
|
table.text('description');
|
||||||
table.timestamp('dueDate', true);
|
table.timestamp('due_date', true);
|
||||||
table.jsonb('timer');
|
table.jsonb('timer');
|
||||||
|
|
||||||
table.timestamp('created_at', true);
|
table.timestamp('created_at', true);
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const sharp = require('sharp');
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
const getConfig = require('../../get-config');
|
||||||
|
|
||||||
|
module.exports.up = async (knex) => {
|
||||||
|
await knex.schema.table('attachment', (table) => {
|
||||||
|
/* Columns */
|
||||||
|
|
||||||
|
table.jsonb('image');
|
||||||
|
});
|
||||||
|
|
||||||
|
const config = await getConfig();
|
||||||
|
const attachments = await knex('attachment');
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
for (attachment of attachments) {
|
||||||
|
if (attachment.is_image) {
|
||||||
|
const image = sharp(
|
||||||
|
path.join(config.custom.attachmentsPath, attachment.dirname, attachment.filename),
|
||||||
|
);
|
||||||
|
|
||||||
|
let metadata;
|
||||||
|
try {
|
||||||
|
metadata = await image.metadata(); // eslint-disable-line no-await-in-loop
|
||||||
|
} catch (error) {
|
||||||
|
continue; // eslint-disable-line no-continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!['svg', 'pdf'].includes(metadata.format)) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await knex('attachment')
|
||||||
|
.update({
|
||||||
|
image: _.pick(metadata, ['width', 'height']),
|
||||||
|
})
|
||||||
|
.where('id', attachment.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return knex.schema.table('attachment', (table) => {
|
||||||
|
table.dropColumn('is_image');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.down = async (knex) => {
|
||||||
|
await knex.schema.table('attachment', (table) => {
|
||||||
|
/* Columns */
|
||||||
|
|
||||||
|
table.boolean('is_image');
|
||||||
|
});
|
||||||
|
|
||||||
|
const attachments = await knex('attachment');
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
|
for (attachment of attachments) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await knex('attachment')
|
||||||
|
.update({
|
||||||
|
is_image: !!attachment.image,
|
||||||
|
})
|
||||||
|
.where('id', attachment.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
await knex.schema.table('attachment', (table) => {
|
||||||
|
table.dropColumn('image');
|
||||||
|
});
|
||||||
|
|
||||||
|
return knex.schema.alterTable('attachment', (table) => {
|
||||||
|
table.boolean('is_image').notNullable().alter();
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
const dotenv = require('dotenv');
|
||||||
|
const sails = require('sails');
|
||||||
|
const rc = require('sails/accessible/rc');
|
||||||
|
|
||||||
|
process.chdir(__dirname);
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
const config = rc('sails');
|
||||||
|
|
||||||
|
const getConfigPromise = new Promise((resolve) => {
|
||||||
|
sails.load(
|
||||||
|
{
|
||||||
|
...config,
|
||||||
|
hooks: {
|
||||||
|
...config.hooks,
|
||||||
|
logger: false,
|
||||||
|
request: false,
|
||||||
|
views: false,
|
||||||
|
blueprints: false,
|
||||||
|
responses: false,
|
||||||
|
helpers: false,
|
||||||
|
pubsub: false,
|
||||||
|
policies: false,
|
||||||
|
services: false,
|
||||||
|
security: false,
|
||||||
|
i18n: false,
|
||||||
|
session: false,
|
||||||
|
http: false,
|
||||||
|
userhooks: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
resolve(sails.config);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = () => getConfigPromise;
|
||||||
Reference in New Issue
Block a user