2020-05-27 02:53:31 +02:00
|
|
|
import React, { useState, useRef } from 'react';
|
2020-04-16 22:05:12 +02:00
|
|
|
import * as BoardStateUtils from 'shared/utils/boardState';
|
2020-05-27 02:53:31 +02:00
|
|
|
import GlobalTopNavbar from 'App/TopNavbar';
|
2020-04-10 04:40:22 +02:00
|
|
|
import styled from 'styled-components/macro';
|
2020-05-27 02:53:31 +02:00
|
|
|
import { Bolt, ToggleOn, Tags } from 'shared/icons';
|
|
|
|
import { usePopup, Popup } from 'shared/components/PopupMenu';
|
2020-04-16 22:05:12 +02:00
|
|
|
import { useParams, Route, useRouteMatch, useHistory, RouteComponentProps } from 'react-router-dom';
|
2020-04-10 05:27:57 +02:00
|
|
|
import {
|
|
|
|
useFindProjectQuery,
|
|
|
|
useUpdateTaskNameMutation,
|
|
|
|
useCreateTaskMutation,
|
|
|
|
useDeleteTaskMutation,
|
|
|
|
useUpdateTaskLocationMutation,
|
2020-04-11 04:53:03 +02:00
|
|
|
useUpdateTaskGroupLocationMutation,
|
2020-04-11 04:22:58 +02:00
|
|
|
useCreateTaskGroupMutation,
|
2020-04-11 21:24:45 +02:00
|
|
|
useDeleteTaskGroupMutation,
|
2020-04-20 05:02:55 +02:00
|
|
|
useUpdateTaskDescriptionMutation,
|
|
|
|
useAssignTaskMutation,
|
2020-05-27 02:53:31 +02:00
|
|
|
DeleteTaskDocument,
|
|
|
|
FindProjectDocument,
|
2020-05-27 23:18:50 +02:00
|
|
|
useCreateProjectLabelMutation,
|
2020-04-10 05:27:57 +02:00
|
|
|
} from 'shared/generated/graphql';
|
2020-04-10 04:40:22 +02:00
|
|
|
|
2020-05-27 23:18:50 +02:00
|
|
|
import TaskAssignee from 'shared/components/TaskAssignee';
|
2020-04-10 04:40:22 +02:00
|
|
|
import QuickCardEditor from 'shared/components/QuickCardEditor';
|
2020-04-11 04:22:58 +02:00
|
|
|
import ListActions from 'shared/components/ListActions';
|
2020-04-13 00:45:51 +02:00
|
|
|
import MemberManager from 'shared/components/MemberManager';
|
|
|
|
import { LabelsPopup } from 'shared/components/PopupMenu/PopupMenu.stories';
|
2020-04-16 22:05:12 +02:00
|
|
|
import KanbanBoard from 'Projects/Project/KanbanBoard';
|
2020-05-27 02:53:31 +02:00
|
|
|
import { mixin } from 'shared/utils/styles';
|
|
|
|
import LabelManager from 'shared/components/PopupMenu/LabelManager';
|
|
|
|
import LabelEditor from 'shared/components/PopupMenu/LabelEditor';
|
|
|
|
import produce from 'immer';
|
2020-04-20 05:02:55 +02:00
|
|
|
import Details from './Details';
|
2020-05-27 23:18:50 +02:00
|
|
|
import MiniProfile from 'shared/components/MiniProfile';
|
2020-04-10 04:40:22 +02:00
|
|
|
|
2020-04-16 22:05:12 +02:00
|
|
|
type TaskRouteProps = {
|
|
|
|
taskID: string;
|
|
|
|
};
|
2020-04-10 04:40:22 +02:00
|
|
|
|
|
|
|
interface QuickCardEditorState {
|
|
|
|
isOpen: boolean;
|
|
|
|
left: number;
|
|
|
|
top: number;
|
2020-04-10 05:27:57 +02:00
|
|
|
task?: Task;
|
2020-04-10 04:40:22 +02:00
|
|
|
}
|
|
|
|
|
2020-04-10 18:31:29 +02:00
|
|
|
const TitleWrapper = styled.div`
|
|
|
|
margin-left: 38px;
|
|
|
|
margin-bottom: 15px;
|
|
|
|
`;
|
|
|
|
|
2020-04-10 04:40:22 +02:00
|
|
|
const Title = styled.span`
|
|
|
|
text-align: center;
|
|
|
|
font-size: 24px;
|
|
|
|
color: #fff;
|
|
|
|
`;
|
2020-05-27 23:18:50 +02:00
|
|
|
const ProjectMembers = styled.div`
|
|
|
|
display: flex;
|
|
|
|
padding-left: 4px;
|
|
|
|
padding-top: 4px;
|
|
|
|
align-items: center;
|
|
|
|
`;
|
2020-04-10 04:40:22 +02:00
|
|
|
|
2020-05-27 02:53:31 +02:00
|
|
|
type LabelManagerEditorProps = {
|
|
|
|
labels: Array<Label>;
|
2020-05-27 23:18:50 +02:00
|
|
|
projectID: string;
|
|
|
|
labelColors: Array<LabelColor>;
|
2020-05-27 02:53:31 +02:00
|
|
|
};
|
|
|
|
|
2020-05-27 23:18:50 +02:00
|
|
|
const LabelManagerEditor: React.FC<LabelManagerEditorProps> = ({ labels: initialLabels, projectID, labelColors }) => {
|
2020-05-27 02:53:31 +02:00
|
|
|
const [labels, setLabels] = useState<Array<Label>>(initialLabels);
|
|
|
|
const [currentLabel, setCurrentLabel] = useState('');
|
2020-05-27 23:18:50 +02:00
|
|
|
const [createProjectLabel] = useCreateProjectLabelMutation();
|
2020-05-27 02:53:31 +02:00
|
|
|
const { setTab } = usePopup();
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Popup title="Labels" tab={0} onClose={() => {}}>
|
|
|
|
<LabelManager
|
|
|
|
labels={labels}
|
|
|
|
onLabelCreate={() => {
|
|
|
|
setTab(2);
|
|
|
|
}}
|
|
|
|
onLabelEdit={labelId => {
|
|
|
|
setCurrentLabel(labelId);
|
|
|
|
setTab(1);
|
|
|
|
}}
|
|
|
|
onLabelToggle={labelId => {
|
2020-05-27 23:18:50 +02:00
|
|
|
setCurrentLabel(labelId);
|
|
|
|
setTab(1);
|
2020-05-27 02:53:31 +02:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Popup>
|
|
|
|
<Popup onClose={() => {}} title="Edit label" tab={1}>
|
|
|
|
<LabelEditor
|
2020-05-27 23:18:50 +02:00
|
|
|
labelColors={labelColors}
|
2020-05-27 02:53:31 +02:00
|
|
|
label={labels.find(label => label.labelId === currentLabel) ?? null}
|
|
|
|
onLabelEdit={(_labelId, name, color) => {
|
|
|
|
setLabels(
|
|
|
|
produce(labels, draftState => {
|
|
|
|
const idx = labels.findIndex(label => label.labelId === currentLabel);
|
|
|
|
if (idx !== -1) {
|
2020-05-27 23:18:50 +02:00
|
|
|
draftState[idx] = { ...draftState[idx], name, labelColor: color };
|
2020-05-27 02:53:31 +02:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
setTab(0);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Popup>
|
|
|
|
<Popup onClose={() => {}} title="Create new label" tab={2}>
|
|
|
|
<LabelEditor
|
2020-05-27 23:18:50 +02:00
|
|
|
labelColors={labelColors}
|
2020-05-27 02:53:31 +02:00
|
|
|
label={null}
|
|
|
|
onLabelEdit={(_labelId, name, color) => {
|
2020-05-27 23:18:50 +02:00
|
|
|
console.log(name, color);
|
|
|
|
setLabels([...labels, { labelId: name, name, labelColor: color, active: false }]);
|
|
|
|
createProjectLabel({ variables: { projectID, labelColorID: color.id, name } });
|
2020-05-27 02:53:31 +02:00
|
|
|
setTab(0);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Popup>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-04-10 04:40:22 +02:00
|
|
|
interface ProjectParams {
|
|
|
|
projectId: string;
|
|
|
|
}
|
|
|
|
|
2020-04-16 22:05:12 +02:00
|
|
|
const initialState: BoardState = { tasks: {}, columns: {} };
|
2020-04-11 04:22:58 +02:00
|
|
|
const initialPopupState = { left: 0, top: 0, isOpen: false, taskGroupID: '' };
|
2020-04-10 04:40:22 +02:00
|
|
|
const initialQuickCardEditorState: QuickCardEditorState = { isOpen: false, top: 0, left: 0 };
|
2020-04-13 00:45:51 +02:00
|
|
|
const initialLabelsPopupState = { taskID: '', isOpen: false, top: 0, left: 0 };
|
|
|
|
const initialTaskDetailsState = { isOpen: false, taskID: '' };
|
2020-04-10 04:40:22 +02:00
|
|
|
|
2020-05-27 23:18:50 +02:00
|
|
|
const ProjectBar = styled.div`
|
2020-05-27 02:53:31 +02:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
|
|
|
height: 40px;
|
|
|
|
padding: 0 12px;
|
|
|
|
`;
|
|
|
|
|
2020-05-27 23:18:50 +02:00
|
|
|
const ProjectActions = styled.div`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
`;
|
|
|
|
|
2020-05-27 02:53:31 +02:00
|
|
|
const ProjectAction = styled.div`
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 15px;
|
|
|
|
color: #c2c6dc;
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: ${mixin.lighten('#c2c6dc', 0.25)};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ProjectActionText = styled.span`
|
|
|
|
padding-left: 4px;
|
|
|
|
`;
|
|
|
|
|
2020-04-10 04:40:22 +02:00
|
|
|
const Project = () => {
|
|
|
|
const { projectId } = useParams<ProjectParams>();
|
2020-04-16 22:05:12 +02:00
|
|
|
const match = useRouteMatch();
|
|
|
|
const history = useHistory();
|
|
|
|
|
2020-04-20 05:02:55 +02:00
|
|
|
const [updateTaskDescription] = useUpdateTaskDescriptionMutation();
|
2020-04-10 04:40:22 +02:00
|
|
|
const [listsData, setListsData] = useState(initialState);
|
2020-04-11 04:22:58 +02:00
|
|
|
const [popupData, setPopupData] = useState(initialPopupState);
|
2020-04-13 00:45:51 +02:00
|
|
|
const [taskDetails, setTaskDetails] = useState(initialTaskDetailsState);
|
2020-04-10 04:40:22 +02:00
|
|
|
const [quickCardEditor, setQuickCardEditor] = useState(initialQuickCardEditorState);
|
2020-04-10 05:27:57 +02:00
|
|
|
const [updateTaskLocation] = useUpdateTaskLocationMutation();
|
2020-04-11 04:53:03 +02:00
|
|
|
const [updateTaskGroupLocation] = useUpdateTaskGroupLocationMutation();
|
2020-04-16 22:05:12 +02:00
|
|
|
|
2020-04-11 21:24:45 +02:00
|
|
|
const [deleteTaskGroup] = useDeleteTaskGroupMutation({
|
|
|
|
onCompleted: deletedTaskGroupData => {
|
2020-05-27 02:53:31 +02:00
|
|
|
setListsData(BoardStateUtils.deleteTaskGroup(listsData, deletedTaskGroupData.deleteTaskGroup.taskGroup.id));
|
2020-04-11 21:24:45 +02:00
|
|
|
},
|
|
|
|
});
|
2020-04-16 22:05:12 +02:00
|
|
|
|
2020-04-11 04:22:58 +02:00
|
|
|
const [createTaskGroup] = useCreateTaskGroupMutation({
|
|
|
|
onCompleted: newTaskGroupData => {
|
2020-04-16 22:05:12 +02:00
|
|
|
const newTaskGroup = {
|
2020-05-27 02:53:31 +02:00
|
|
|
taskGroupID: newTaskGroupData.createTaskGroup.id,
|
2020-04-16 22:05:12 +02:00
|
|
|
tasks: [],
|
2020-05-27 02:53:31 +02:00
|
|
|
...newTaskGroupData.createTaskGroup,
|
2020-04-11 04:22:58 +02:00
|
|
|
};
|
2020-04-16 22:05:12 +02:00
|
|
|
setListsData(BoardStateUtils.addTaskGroup(listsData, newTaskGroup));
|
2020-04-11 04:22:58 +02:00
|
|
|
},
|
|
|
|
});
|
2020-04-16 22:05:12 +02:00
|
|
|
|
2020-04-10 05:27:57 +02:00
|
|
|
const [createTask] = useCreateTaskMutation({
|
2020-04-10 04:40:22 +02:00
|
|
|
onCompleted: newTaskData => {
|
2020-04-16 22:05:12 +02:00
|
|
|
const newTask = {
|
|
|
|
...newTaskData.createTask,
|
2020-05-27 02:53:31 +02:00
|
|
|
taskID: newTaskData.createTask.id,
|
|
|
|
taskGroup: { taskGroupID: newTaskData.createTask.taskGroup.id },
|
2020-04-16 22:05:12 +02:00
|
|
|
labels: [],
|
2020-04-10 04:40:22 +02:00
|
|
|
};
|
2020-04-16 22:05:12 +02:00
|
|
|
setListsData(BoardStateUtils.addTask(listsData, newTask));
|
2020-04-10 04:40:22 +02:00
|
|
|
},
|
2020-05-27 02:53:31 +02:00
|
|
|
update: (client, newTaskData) => {
|
|
|
|
const cacheData: any = client.readQuery({
|
|
|
|
query: FindProjectDocument,
|
|
|
|
variables: {
|
|
|
|
projectId: projectId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
console.log(cacheData);
|
|
|
|
console.log(newTaskData);
|
|
|
|
const newTaskGroups = produce(cacheData.findProject.taskGroups, (draftState: any) => {
|
|
|
|
const targetIndex = draftState.findIndex(
|
|
|
|
(taskGroup: any) => taskGroup.id === newTaskData.data.createTask.taskGroup.id,
|
|
|
|
);
|
|
|
|
draftState[targetIndex] = {
|
|
|
|
...draftState[targetIndex],
|
|
|
|
tasks: [...draftState[targetIndex].tasks, { ...newTaskData.data.createTask }],
|
|
|
|
};
|
|
|
|
});
|
|
|
|
console.log(newTaskGroups);
|
|
|
|
const newData = {
|
|
|
|
...cacheData.findProject,
|
|
|
|
taskGroups: newTaskGroups,
|
|
|
|
};
|
|
|
|
client.writeQuery({
|
|
|
|
query: FindProjectDocument,
|
|
|
|
variables: {
|
|
|
|
projectId: projectId,
|
|
|
|
},
|
|
|
|
data: { findProject: newData },
|
|
|
|
});
|
|
|
|
},
|
2020-04-10 04:40:22 +02:00
|
|
|
});
|
2020-04-16 22:05:12 +02:00
|
|
|
|
2020-04-10 05:27:57 +02:00
|
|
|
const [deleteTask] = useDeleteTaskMutation({
|
2020-04-10 04:40:22 +02:00
|
|
|
onCompleted: deletedTask => {
|
2020-04-16 22:05:12 +02:00
|
|
|
setListsData(BoardStateUtils.deleteTask(listsData, deletedTask.deleteTask.taskID));
|
2020-04-10 04:40:22 +02:00
|
|
|
},
|
|
|
|
});
|
2020-04-16 22:05:12 +02:00
|
|
|
|
2020-04-10 05:27:57 +02:00
|
|
|
const [updateTaskName] = useUpdateTaskNameMutation({
|
2020-04-10 04:40:22 +02:00
|
|
|
onCompleted: newTaskData => {
|
2020-04-16 22:05:12 +02:00
|
|
|
setListsData(
|
2020-05-27 02:53:31 +02:00
|
|
|
BoardStateUtils.updateTaskName(listsData, newTaskData.updateTaskName.id, newTaskData.updateTaskName.name),
|
2020-04-16 22:05:12 +02:00
|
|
|
);
|
2020-04-10 04:40:22 +02:00
|
|
|
},
|
|
|
|
});
|
2020-04-21 01:04:27 +02:00
|
|
|
const { loading, data, refetch } = useFindProjectQuery({
|
2020-04-10 04:40:22 +02:00
|
|
|
variables: { projectId },
|
|
|
|
});
|
2020-05-27 02:53:31 +02:00
|
|
|
console.log(`loading ${loading} - ${data}`);
|
2020-04-16 22:05:12 +02:00
|
|
|
|
2020-04-10 04:40:22 +02:00
|
|
|
const onCardCreate = (taskGroupID: string, name: string) => {
|
2020-04-11 04:22:58 +02:00
|
|
|
const taskGroupTasks = Object.values(listsData.tasks).filter(
|
|
|
|
(task: Task) => task.taskGroup.taskGroupID === taskGroupID,
|
|
|
|
);
|
2020-04-10 22:31:12 +02:00
|
|
|
let position = 65535;
|
2020-04-10 04:40:22 +02:00
|
|
|
if (taskGroupTasks.length !== 0) {
|
|
|
|
const [lastTask] = taskGroupTasks.sort((a: any, b: any) => a.position - b.position).slice(-1);
|
|
|
|
position = Math.ceil(lastTask.position) * 2 + 1;
|
|
|
|
}
|
|
|
|
|
2020-04-10 22:31:12 +02:00
|
|
|
createTask({ variables: { taskGroupID, name, position } });
|
2020-04-10 04:40:22 +02:00
|
|
|
};
|
2020-04-16 22:05:12 +02:00
|
|
|
|
|
|
|
const onCardDrop = (droppedTask: Task) => {
|
|
|
|
updateTaskLocation({
|
|
|
|
variables: {
|
|
|
|
taskID: droppedTask.taskID,
|
|
|
|
taskGroupID: droppedTask.taskGroup.taskGroupID,
|
|
|
|
position: droppedTask.position,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
setListsData(BoardStateUtils.updateTask(listsData, droppedTask));
|
|
|
|
};
|
|
|
|
const onListDrop = (droppedColumn: TaskGroup) => {
|
|
|
|
updateTaskGroupLocation({
|
|
|
|
variables: { taskGroupID: droppedColumn.taskGroupID, position: droppedColumn.position },
|
|
|
|
});
|
|
|
|
setListsData(BoardStateUtils.updateTaskGroup(listsData, droppedColumn));
|
|
|
|
};
|
|
|
|
|
|
|
|
const onCreateList = (listName: string) => {
|
|
|
|
const [lastColumn] = Object.values(listsData.columns)
|
|
|
|
.sort((a, b) => a.position - b.position)
|
|
|
|
.slice(-1);
|
|
|
|
let position = 65535;
|
|
|
|
if (lastColumn) {
|
|
|
|
position = lastColumn.position * 2 + 1;
|
|
|
|
}
|
|
|
|
createTaskGroup({ variables: { projectID: projectId, name: listName, position } });
|
|
|
|
};
|
2020-04-10 04:40:22 +02:00
|
|
|
|
2020-04-20 05:02:55 +02:00
|
|
|
const [assignTask] = useAssignTaskMutation();
|
|
|
|
|
2020-05-27 02:53:31 +02:00
|
|
|
const { showPopup } = usePopup();
|
|
|
|
const $labelsRef = useRef<HTMLDivElement>(null);
|
2020-04-10 04:40:22 +02:00
|
|
|
if (loading) {
|
2020-05-27 02:53:31 +02:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<GlobalTopNavbar name="Project" />
|
|
|
|
<Title>Error Loading</Title>
|
|
|
|
</>
|
|
|
|
);
|
2020-04-10 04:40:22 +02:00
|
|
|
}
|
|
|
|
if (data) {
|
2020-05-27 02:53:31 +02:00
|
|
|
const currentListsData: BoardState = { tasks: {}, columns: {} };
|
|
|
|
data.findProject.taskGroups.forEach(taskGroup => {
|
|
|
|
currentListsData.columns[taskGroup.id] = {
|
|
|
|
taskGroupID: taskGroup.id,
|
|
|
|
name: taskGroup.name,
|
|
|
|
position: taskGroup.position,
|
|
|
|
tasks: [],
|
|
|
|
};
|
|
|
|
taskGroup.tasks.forEach(task => {
|
|
|
|
const taskMembers = task.assigned.map(assigned => {
|
|
|
|
return {
|
|
|
|
userID: assigned.id,
|
|
|
|
displayName: `${assigned.firstName} ${assigned.lastName}`,
|
|
|
|
profileIcon: {
|
|
|
|
url: null,
|
|
|
|
initials: assigned.profileIcon.initials ?? '',
|
|
|
|
bgColor: assigned.profileIcon.bgColor ?? '#7367F0',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
currentListsData.tasks[task.id] = {
|
|
|
|
taskID: task.id,
|
|
|
|
taskGroup: {
|
|
|
|
taskGroupID: taskGroup.id,
|
|
|
|
},
|
|
|
|
name: task.name,
|
|
|
|
labels: [],
|
|
|
|
position: task.position,
|
|
|
|
description: task.description ?? undefined,
|
|
|
|
members: taskMembers,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
2020-04-20 05:02:55 +02:00
|
|
|
const availableMembers = data.findProject.members.map(member => {
|
|
|
|
return {
|
|
|
|
displayName: `${member.firstName} ${member.lastName}`,
|
2020-04-21 01:04:27 +02:00
|
|
|
profileIcon: {
|
|
|
|
url: null,
|
|
|
|
initials: member.profileIcon.initials ?? null,
|
|
|
|
bgColor: member.profileIcon.bgColor ?? null,
|
|
|
|
},
|
2020-05-27 02:53:31 +02:00
|
|
|
userID: member.id,
|
2020-04-20 05:02:55 +02:00
|
|
|
};
|
|
|
|
});
|
2020-05-27 02:53:31 +02:00
|
|
|
const onQuickEditorOpen = (e: ContextMenuEvent) => {
|
|
|
|
const currentTask = Object.values(currentListsData.tasks).find(task => task.taskID === e.taskID);
|
|
|
|
console.log(`currentTask: ${currentTask?.taskID}`);
|
|
|
|
setQuickCardEditor({
|
|
|
|
top: e.top,
|
|
|
|
left: e.left,
|
|
|
|
isOpen: true,
|
|
|
|
task: currentTask,
|
|
|
|
});
|
|
|
|
};
|
2020-05-27 23:18:50 +02:00
|
|
|
|
2020-04-10 04:40:22 +02:00
|
|
|
return (
|
|
|
|
<>
|
2020-05-27 23:18:50 +02:00
|
|
|
<GlobalTopNavbar projectMembers={availableMembers} name={data.findProject.name} />
|
|
|
|
<ProjectBar>
|
|
|
|
<ProjectActions>
|
|
|
|
<ProjectAction
|
|
|
|
ref={$labelsRef}
|
|
|
|
onClick={() => {
|
|
|
|
showPopup(
|
|
|
|
$labelsRef,
|
|
|
|
<LabelManagerEditor
|
|
|
|
labelColors={data.labelColors}
|
|
|
|
labels={data.findProject.labels.map(label => {
|
|
|
|
return {
|
|
|
|
labelId: label.id,
|
|
|
|
name: label.name ?? '',
|
|
|
|
labelColor: label.labelColor,
|
|
|
|
active: false,
|
|
|
|
};
|
|
|
|
})}
|
|
|
|
projectID={projectId}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tags size={13} color="#c2c6dc" />
|
|
|
|
<ProjectActionText>Labels</ProjectActionText>
|
|
|
|
</ProjectAction>
|
|
|
|
<ProjectAction>
|
|
|
|
<ToggleOn size={13} color="#c2c6dc" />
|
|
|
|
<ProjectActionText>Fields</ProjectActionText>
|
|
|
|
</ProjectAction>
|
|
|
|
<ProjectAction>
|
|
|
|
<Bolt size={13} color="#c2c6dc" />
|
|
|
|
<ProjectActionText>Rules</ProjectActionText>
|
|
|
|
</ProjectAction>
|
|
|
|
</ProjectActions>
|
|
|
|
</ProjectBar>
|
2020-04-20 05:02:55 +02:00
|
|
|
<KanbanBoard
|
2020-05-27 02:53:31 +02:00
|
|
|
listsData={currentListsData}
|
2020-04-20 05:02:55 +02:00
|
|
|
onCardDrop={onCardDrop}
|
|
|
|
onListDrop={onListDrop}
|
|
|
|
onCardCreate={onCardCreate}
|
|
|
|
onCreateList={onCreateList}
|
2020-05-27 23:18:50 +02:00
|
|
|
onCardMemberClick={($targetRef, taskID, memberID) => {
|
|
|
|
showPopup(
|
|
|
|
$targetRef,
|
|
|
|
<Popup title={null} onClose={() => {}} tab={0}>
|
|
|
|
<MiniProfile
|
|
|
|
profileIcon={availableMembers[0].profileIcon}
|
|
|
|
displayName="Jordan Knott"
|
|
|
|
username="@jordanthedev"
|
|
|
|
bio="None"
|
|
|
|
onRemoveFromTask={() => {
|
|
|
|
/* unassignTask({ variables: { taskID: data.findTask.id, userID: userID ?? '' } }); */
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Popup>,
|
|
|
|
);
|
|
|
|
}}
|
2020-04-20 05:02:55 +02:00
|
|
|
onQuickEditorOpen={onQuickEditorOpen}
|
2020-05-27 02:53:31 +02:00
|
|
|
onOpenListActionsPopup={($targetRef, taskGroupID) => {
|
|
|
|
showPopup(
|
|
|
|
$targetRef,
|
|
|
|
<Popup title="List actions" tab={0} onClose={() => {}}>
|
|
|
|
<ListActions
|
|
|
|
taskGroupID={taskGroupID}
|
|
|
|
onArchiveTaskGroup={tgID => {
|
|
|
|
deleteTaskGroup({ variables: { taskGroupID: tgID } });
|
|
|
|
setPopupData(initialPopupState);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Popup>,
|
|
|
|
);
|
2020-04-20 05:02:55 +02:00
|
|
|
}}
|
|
|
|
/>
|
2020-04-16 22:05:12 +02:00
|
|
|
{quickCardEditor.isOpen && (
|
|
|
|
<QuickCardEditor
|
|
|
|
isOpen
|
|
|
|
taskID={quickCardEditor.task ? quickCardEditor.task.taskID : ''}
|
|
|
|
taskGroupID={quickCardEditor.task ? quickCardEditor.task.taskGroup.taskGroupID : ''}
|
|
|
|
cardTitle={quickCardEditor.task ? quickCardEditor.task.name : ''}
|
|
|
|
onCloseEditor={() => setQuickCardEditor(initialQuickCardEditorState)}
|
|
|
|
onEditCard={(_listId: string, cardId: string, cardName: string) => {
|
|
|
|
updateTaskName({ variables: { taskID: cardId, name: cardName } });
|
2020-04-13 00:45:51 +02:00
|
|
|
}}
|
2020-04-16 22:05:12 +02:00
|
|
|
onOpenPopup={() => console.log()}
|
2020-05-27 02:53:31 +02:00
|
|
|
onArchiveCard={(_listId: string, cardId: string) =>
|
|
|
|
deleteTask({
|
|
|
|
variables: { taskID: cardId },
|
|
|
|
update: client => {
|
|
|
|
const cacheData: any = client.readQuery({
|
|
|
|
query: FindProjectDocument,
|
|
|
|
variables: {
|
|
|
|
projectId: projectId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const newData = {
|
|
|
|
...cacheData.findProject,
|
|
|
|
taskGroups: cacheData.findProject.taskGroups.map((taskGroup: any) => {
|
|
|
|
return {
|
|
|
|
...taskGroup,
|
|
|
|
tasks: taskGroup.tasks.filter((t: any) => t.id !== cardId),
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
client.writeQuery({
|
|
|
|
query: FindProjectDocument,
|
|
|
|
variables: {
|
|
|
|
projectId: projectId,
|
|
|
|
},
|
|
|
|
data: { findProject: newData },
|
|
|
|
});
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2020-04-16 22:05:12 +02:00
|
|
|
labels={[]}
|
|
|
|
top={quickCardEditor.top}
|
|
|
|
left={quickCardEditor.left}
|
2020-04-13 00:45:51 +02:00
|
|
|
/>
|
|
|
|
)}
|
2020-04-16 22:05:12 +02:00
|
|
|
<Route
|
|
|
|
path={`${match.path}/c/:taskID`}
|
|
|
|
render={(routeProps: RouteComponentProps<TaskRouteProps>) => (
|
2020-04-20 05:02:55 +02:00
|
|
|
<Details
|
2020-04-21 01:04:27 +02:00
|
|
|
refreshCache={() => {
|
|
|
|
console.log('beep 2!');
|
2020-05-27 02:53:31 +02:00
|
|
|
// refetch();
|
2020-04-21 01:04:27 +02:00
|
|
|
}}
|
2020-04-20 05:02:55 +02:00
|
|
|
availableMembers={availableMembers}
|
|
|
|
projectURL={match.url}
|
|
|
|
taskID={routeProps.match.params.taskID}
|
|
|
|
onTaskNameChange={(updatedTask, newName) => {
|
|
|
|
updateTaskName({ variables: { taskID: updatedTask.taskID, name: newName } });
|
|
|
|
}}
|
|
|
|
onTaskDescriptionChange={(updatedTask, newDescription) => {
|
|
|
|
updateTaskDescription({ variables: { taskID: updatedTask.taskID, description: newDescription } });
|
2020-04-16 22:05:12 +02:00
|
|
|
}}
|
2020-04-20 05:02:55 +02:00
|
|
|
onDeleteTask={deletedTask => {
|
|
|
|
setTaskDetails(initialTaskDetailsState);
|
|
|
|
deleteTask({ variables: { taskID: deletedTask.taskID } });
|
2020-04-16 22:05:12 +02:00
|
|
|
}}
|
2020-05-27 02:53:31 +02:00
|
|
|
onOpenAddLabelPopup={(task, $targetRef) => {}}
|
2020-04-16 22:05:12 +02:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
2020-04-10 04:40:22 +02:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2020-04-20 05:02:55 +02:00
|
|
|
return <div>Error</div>;
|
2020-04-10 04:40:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Project;
|