mirror of
https://github.com/plankanban/planka.git
synced 2025-07-30 02:29:46 +02:00
feat: fully rework 'move list to board' feature to match review requirements
- All async logic for moving lists between boards is now handled via Redux sagas, not in React components. - Removed direct API calls and sessionStorage usage from UI. - Added a unified action creator for moving lists between boards. - Saga watcher now uses the correct action type constant. - On the backend, the move-to-board helper now: - Detaches card members who are not present on the target board. - Converts board-wide custom fields to per-card fields when moving lists. - Added selector memoization in BoardSelectStep to prevent unnecessary rerenders. - All business logic is now outside of UI components. - The feature now fully handles: - Users (members/assignees) who do not exist on the target board. - Board-wide custom fields, which are now either copied or converted to per-card fields. - All review comments are addressed: no business logic in components, no sessionStorage, all edge cases handled, only sagas and request used for async actions.
This commit is contained in:
parent
9c08ce51f1
commit
869d9c1d11
7 changed files with 99 additions and 22 deletions
|
@ -8,7 +8,6 @@ import PropTypes from 'prop-types';
|
|||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Menu } from 'semantic-ui-react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Popup } from '../../../lib/custom-ui';
|
||||
|
||||
import selectors from '../../../selectors';
|
||||
|
@ -21,7 +20,6 @@ import SelectListTypeStep from '../SelectListTypeStep';
|
|||
import ConfirmationStep from '../../common/ConfirmationStep';
|
||||
import ArchiveCardsStep from '../../cards/ArchiveCardsStep';
|
||||
import BoardSelectStep from './BoardSelectStep';
|
||||
import api from '../../../api/lists';
|
||||
|
||||
import styles from './ActionsStep.module.scss';
|
||||
|
||||
|
@ -42,7 +40,6 @@ const ActionsStep = React.memo(({ listId, onNameEdit, onCardAdd, onClose }) => {
|
|||
const dispatch = useDispatch();
|
||||
const [t] = useTranslation();
|
||||
const [step, openStep, handleBack] = useSteps();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleTypeSelect = useCallback(
|
||||
(type) => {
|
||||
|
@ -90,22 +87,10 @@ const ActionsStep = React.memo(({ listId, onNameEdit, onCardAdd, onClose }) => {
|
|||
}, [openStep]);
|
||||
|
||||
const handleMoveToBoard = useCallback(
|
||||
async (targetBoardId) => {
|
||||
try {
|
||||
const { item: updatedList, included } = await api.moveToBoard(listId, { targetBoardId });
|
||||
dispatch(entryActions.handleListUpdate(updatedList));
|
||||
if (included && included.cards) {
|
||||
dispatch(entryActions.handleCardsUpdate(included.cards, []));
|
||||
}
|
||||
sessionStorage.setItem('movedListId', listId);
|
||||
onClose();
|
||||
navigate(`/boards/${targetBoardId}`);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
}
|
||||
(targetBoardId) => {
|
||||
dispatch(entryActions.moveListToBoardRequest(listId, targetBoardId));
|
||||
},
|
||||
[listId, onClose, dispatch, navigate],
|
||||
[listId, dispatch],
|
||||
);
|
||||
|
||||
if (step) {
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { createSelector } from 'reselect';
|
||||
import PopupHeader from '../../../lib/custom-ui/components/Popup/PopupHeader';
|
||||
import styles from './ActionsStep.module.scss';
|
||||
import selectors from '../../../selectors';
|
||||
|
||||
const makeSelectBoardsByIds = () =>
|
||||
createSelector(
|
||||
(state, boardIds) => boardIds,
|
||||
(state) => state,
|
||||
(boardIds, state) => boardIds.map((id) => selectors.selectBoardById(state, id)),
|
||||
);
|
||||
|
||||
function BoardSelectStep({ currentBoardId, onSelect, onBack, onClose }) {
|
||||
const [t] = useTranslation();
|
||||
const projectId = useSelector((state) => selectors.selectPath(state).projectId);
|
||||
const boardIds = useSelector((state) => selectors.selectBoardIdsByProjectId(state, projectId));
|
||||
const boards = useSelector((state) => boardIds.map((id) => selectors.selectBoardById(state, id)));
|
||||
const selectBoardsByIds = useMemo(makeSelectBoardsByIds, []);
|
||||
const boards = useSelector((state) => selectBoardsByIds(state, boardIds));
|
||||
|
||||
return (
|
||||
<div className={styles.boardSelectStep}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue