From 22ec8707ac6dea61f7a1a2cd6d9e882bac3d27a6 Mon Sep 17 00:00:00 2001 From: Maksim Eltyshev Date: Mon, 27 Feb 2023 19:09:51 +0100 Subject: [PATCH] fix: Rename timer to stopwatch Closes #392 --- client/src/api/cards.js | 20 +++---- client/src/components/Card/ActionsStep.jsx | 26 ++++----- client/src/components/Card/Card.jsx | 30 +++++------ client/src/components/CardModal/CardModal.jsx | 53 ++++++++++--------- .../Timer.jsx => Stopwatch/Stopwatch.jsx} | 14 ++--- .../Stopwatch.module.scss} | 0 client/src/components/Stopwatch/index.js | 3 ++ .../StopwatchEditStep.jsx} | 36 +++++++------ .../StopwatchEditStep.module.scss} | 0 .../src/components/StopwatchEditStep/index.js | 3 ++ client/src/components/Timer/index.js | 3 -- client/src/components/TimerEditStep/index.js | 3 -- client/src/containers/CardContainer.js | 4 +- client/src/containers/CardModalContainer.js | 4 +- client/src/locales/cs/core.js | 6 +-- client/src/locales/da/core.js | 6 +-- client/src/locales/de/core.js | 6 +-- client/src/locales/en/core.js | 6 +-- client/src/locales/es/core.js | 6 +-- client/src/locales/fr/core.js | 6 +-- client/src/locales/it/core.js | 6 +-- client/src/locales/ja/core.js | 6 +-- client/src/locales/ko/core.js | 6 +-- client/src/locales/pl/core.js | 6 +-- client/src/locales/ru/core.js | 6 +-- client/src/locales/sk/core.js | 6 +-- client/src/locales/sv/core.js | 6 +-- client/src/locales/uz/core.js | 6 +-- client/src/locales/zh/core.js | 6 +-- client/src/models/Card.js | 2 +- client/src/utils/{timer.js => stopwatch.js} | 22 ++++---- server/api/controllers/cards/create.js | 8 +-- server/api/controllers/cards/update.js | 8 +-- server/api/models/Card.js | 2 +- ...0230227170557_rename_timer_to_stopwatch.js | 9 ++++ 35 files changed, 179 insertions(+), 161 deletions(-) rename client/src/components/{Timer/Timer.jsx => Stopwatch/Stopwatch.jsx} (84%) rename client/src/components/{Timer/Timer.module.scss => Stopwatch/Stopwatch.module.scss} (100%) create mode 100644 client/src/components/Stopwatch/index.js rename client/src/components/{TimerEditStep/TimerEditStep.jsx => StopwatchEditStep/StopwatchEditStep.jsx} (85%) rename client/src/components/{TimerEditStep/TimerEditStep.module.scss => StopwatchEditStep/StopwatchEditStep.module.scss} (100%) create mode 100644 client/src/components/StopwatchEditStep/index.js delete mode 100644 client/src/components/Timer/index.js delete mode 100644 client/src/components/TimerEditStep/index.js rename client/src/utils/{timer.js => stopwatch.js} (55%) create mode 100644 server/db/migrations/20230227170557_rename_timer_to_stopwatch.js diff --git a/client/src/api/cards.js b/client/src/api/cards.js index 8781af93..5240038f 100755 --- a/client/src/api/cards.js +++ b/client/src/api/cards.js @@ -8,11 +8,11 @@ export const transformCard = (card) => ({ ...(card.dueDate && { dueDate: new Date(card.dueDate), }), - ...(card.timer && { - timer: { - ...card.timer, - ...(card.timer.startedAt && { - startedAt: new Date(card.timer.startedAt), + ...(card.stopwatch && { + stopwatch: { + ...card.stopwatch, + ...(card.stopwatch.startedAt && { + startedAt: new Date(card.stopwatch.startedAt), }), }, }), @@ -23,11 +23,11 @@ export const transformCardData = (data) => ({ ...(data.dueDate && { dueDate: data.dueDate.toISOString(), }), - ...(data.timer && { - timer: { - ...data.timer, - ...(data.timer.startedAt && { - startedAt: data.timer.startedAt.toISOString(), + ...(data.stopwatch && { + stopwatch: { + ...data.stopwatch, + ...(data.stopwatch.startedAt && { + startedAt: data.stopwatch.startedAt.toISOString(), }), }, }), diff --git a/client/src/components/Card/ActionsStep.jsx b/client/src/components/Card/ActionsStep.jsx index 559dc2c2..dbd349e7 100644 --- a/client/src/components/Card/ActionsStep.jsx +++ b/client/src/components/Card/ActionsStep.jsx @@ -9,7 +9,7 @@ import { useSteps } from '../../hooks'; import BoardMembershipsStep from '../BoardMembershipsStep'; import LabelsStep from '../LabelsStep'; import DueDateEditStep from '../DueDateEditStep'; -import TimerEditStep from '../TimerEditStep'; +import StopwatchEditStep from '../StopwatchEditStep'; import CardMoveStep from '../CardMoveStep'; import DeleteStep from '../DeleteStep'; @@ -19,7 +19,7 @@ const StepTypes = { USERS: 'USERS', LABELS: 'LABELS', EDIT_DUE_DATE: 'EDIT_DUE_DATE', - EDIT_TIMER: 'EDIT_TIMER', + EDIT_STOPWATCH: 'EDIT_STOPWATCH', MOVE: 'MOVE', DELETE: 'DELETE', }; @@ -68,8 +68,8 @@ const ActionsStep = React.memo( openStep(StepTypes.EDIT_DUE_DATE); }, [openStep]); - const handleEditTimerClick = useCallback(() => { - openStep(StepTypes.EDIT_TIMER); + const handleEditStopwatchClick = useCallback(() => { + openStep(StepTypes.EDIT_STOPWATCH); }, [openStep]); const handleMoveClick = useCallback(() => { @@ -89,10 +89,10 @@ const ActionsStep = React.memo( [onUpdate], ); - const handleTimerUpdate = useCallback( - (timer) => { + const handleStopwatchUpdate = useCallback( + (stopwatch) => { onUpdate({ - timer, + stopwatch, }); }, [onUpdate], @@ -133,11 +133,11 @@ const ActionsStep = React.memo( onClose={onClose} /> ); - case StepTypes.EDIT_TIMER: + case StepTypes.EDIT_STOPWATCH: return ( - @@ -197,8 +197,8 @@ const ActionsStep = React.memo( context: 'title', })} - - {t('action.editTimer', { + + {t('action.editStopwatch', { context: 'title', })} diff --git a/client/src/components/Card/Card.jsx b/client/src/components/Card/Card.jsx index 86e26d5f..37521a06 100755 --- a/client/src/components/Card/Card.jsx +++ b/client/src/components/Card/Card.jsx @@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'; import { Draggable } from 'react-beautiful-dnd'; import { usePopup } from '../../lib/popup'; -import { startTimer, stopTimer } from '../../utils/timer'; +import { startStopwatch, stopStopwatch } from '../../utils/stopwatch'; import Paths from '../../constants/Paths'; import Tasks from './Tasks'; import NameEdit from './NameEdit'; @@ -14,7 +14,7 @@ import ActionsStep from './ActionsStep'; import User from '../User'; import Label from '../Label'; import DueDate from '../DueDate'; -import Timer from '../Timer'; +import Stopwatch from '../Stopwatch'; import styles from './Card.module.scss'; @@ -24,7 +24,7 @@ const Card = React.memo( index, name, dueDate, - timer, + stopwatch, coverUrl, boardId, listId, @@ -60,15 +60,15 @@ const Card = React.memo( } }, []); - const handleToggleTimerClick = useCallback( + const handleToggleStopwatchClick = useCallback( (event) => { event.preventDefault(); onUpdate({ - timer: timer.startedAt ? stopTimer(timer) : startTimer(timer), + stopwatch: stopwatch.startedAt ? stopStopwatch(stopwatch) : startStopwatch(stopwatch), }); }, - [timer, onUpdate], + [stopwatch, onUpdate], ); const handleNameUpdate = useCallback( @@ -104,7 +104,7 @@ const Card = React.memo( )}
{name}
{tasks.length > 0 && } - {(dueDate || timer || notificationsTotal > 0) && ( + {(dueDate || stopwatch || notificationsTotal > 0) && ( {notificationsTotal > 0 && ( )} - {timer && ( + {stopwatch && ( - )} @@ -171,7 +171,7 @@ const Card = React.memo( { + const handleToggleStopwatchClick = useCallback(() => { onUpdate({ - timer: timer.startedAt ? stopTimer(timer) : startTimer(timer), + stopwatch: stopwatch.startedAt ? stopStopwatch(stopwatch) : startStopwatch(stopwatch), }); - }, [timer, onUpdate]); + }, [stopwatch, onUpdate]); const handleNameUpdate = useCallback( (newName) => { @@ -116,10 +116,10 @@ const CardModal = React.memo( [onUpdate], ); - const handleTimerUpdate = useCallback( - (newTimer) => { + const handleStopwatchUpdate = useCallback( + (newStopwatch) => { onUpdate({ - timer: newTimer, + stopwatch: newStopwatch, }); }, [onUpdate], @@ -160,7 +160,7 @@ const CardModal = React.memo( const BoardMembershipsPopup = usePopup(BoardMembershipsStep); const LabelsPopup = usePopup(LabelsStep); const DueDateEditPopup = usePopup(DueDateEditStep); - const TimerEditPopup = usePopup(TimerEditStep); + const StopwatchEditPopup = usePopup(StopwatchEditStep); const CardMovePopup = usePopup(CardMoveStep); const DeletePopup = usePopup(DeleteStep); @@ -185,7 +185,7 @@ const CardModal = React.memo( - {(users.length > 0 || labels.length > 0 || dueDate || timer) && ( + {(users.length > 0 || labels.length > 0 || dueDate || stopwatch) && (
{users.length > 0 && (
@@ -294,30 +294,33 @@ const CardModal = React.memo(
)} - {timer && ( + {stopwatch && (
- {t('common.timer', { + {t('common.stopwatch', { context: 'title', })}
{canEdit ? ( - - - + + + ) : ( - + )} {canEdit && ( - + - +