taskcafe/web/src/Projects/Project/index.tsx

703 lines
24 KiB
TypeScript
Raw Normal View History

import React, { useState, useRef, useContext } from 'react';
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';
import { useParams, Route, useRouteMatch, useHistory, RouteComponentProps } from 'react-router-dom';
import {
2020-05-31 06:11:19 +02:00
useToggleTaskLabelMutation,
useUpdateProjectNameMutation,
useFindProjectQuery,
useUpdateTaskNameMutation,
useUpdateProjectLabelMutation,
useCreateTaskMutation,
useDeleteProjectLabelMutation,
useDeleteTaskMutation,
useUpdateTaskLocationMutation,
useUpdateTaskGroupLocationMutation,
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,
useUnassignTaskMutation,
} 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';
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';
import KanbanBoard from 'Projects/Project/KanbanBoard';
2020-05-31 06:11:19 +02:00
import SimpleLists from 'shared/components/Lists';
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-05-27 23:18:50 +02:00
import MiniProfile from 'shared/components/MiniProfile';
import Details from './Details';
2020-05-31 06:11:19 +02:00
import { useApolloClient } from '@apollo/react-hooks';
import UserIDContext from 'App/context';
const getCacheData = (client: any, projectID: string) => {
const cacheData: any = client.readQuery({
query: FindProjectDocument,
variables: {
projectId: projectID,
},
});
return cacheData;
};
const writeCacheData = (client: any, projectID: string, cacheData: any, newData: any) => {
client.writeQuery({
query: FindProjectDocument,
variables: {
projectId: projectID,
},
data: { ...cacheData, findProject: newData },
});
};
2020-04-10 04:40:22 +02:00
type TaskRouteProps = {
taskID: string;
};
2020-04-10 04:40:22 +02:00
interface QuickCardEditorState {
isOpen: boolean;
left: number;
top: number;
2020-05-31 06:51:22 +02:00
taskID: string | null;
taskGroupID: string | null;
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 = {
2020-05-31 06:11:19 +02:00
labels: React.RefObject<Array<ProjectLabel>>;
taskLabels: null | React.RefObject<Array<TaskLabel>>;
2020-05-27 23:18:50 +02:00
projectID: string;
labelColors: Array<LabelColor>;
2020-05-31 06:11:19 +02:00
onLabelToggle?: (labelId: string) => void;
2020-05-27 02:53:31 +02:00
};
2020-05-31 06:11:19 +02:00
const LabelManagerEditor: React.FC<LabelManagerEditorProps> = ({
labels: labelsRef,
projectID,
labelColors,
onLabelToggle,
taskLabels: taskLabelsRef,
}) => {
2020-05-27 02:53:31 +02:00
const [currentLabel, setCurrentLabel] = useState('');
const [createProjectLabel] = useCreateProjectLabelMutation({
update: (client, newLabelData) => {
const cacheData = getCacheData(client, projectID);
const newData = {
...cacheData.findProject,
labels: [...cacheData.findProject.labels, { ...newLabelData.data.createProjectLabel }],
};
writeCacheData(client, projectID, cacheData, newData);
},
});
const [updateProjectLabel] = useUpdateProjectLabelMutation();
const [deleteProjectLabel] = useDeleteProjectLabelMutation({
update: (client, newLabelData) => {
const cacheData = getCacheData(client, projectID);
const newData = {
...cacheData.findProject,
labels: cacheData.findProject.labels.filter(
(label: any) => label.id !== newLabelData.data.deleteProjectLabel.id,
),
};
writeCacheData(client, projectID, cacheData, newData);
},
});
const labels = labelsRef.current ? labelsRef.current : [];
2020-05-31 06:11:19 +02:00
const taskLabels = taskLabelsRef && taskLabelsRef.current ? taskLabelsRef.current : [];
const [currentTaskLabels, setCurrentTaskLabels] = useState(taskLabels);
console.log(taskLabels);
2020-05-27 02:53:31 +02:00
const { setTab } = usePopup();
return (
<>
<Popup title="Labels" tab={0} onClose={() => {}}>
<LabelManager
labels={labels}
2020-05-31 06:11:19 +02:00
taskLabels={currentTaskLabels}
2020-05-27 02:53:31 +02:00
onLabelCreate={() => {
setTab(2);
}}
onLabelEdit={labelId => {
setCurrentLabel(labelId);
setTab(1);
}}
onLabelToggle={labelId => {
2020-05-31 06:11:19 +02:00
if (onLabelToggle) {
if (currentTaskLabels.find(t => t.projectLabel.id === labelId)) {
setCurrentTaskLabels(currentTaskLabels.filter(t => t.projectLabel.id !== labelId));
} else {
const newProjectLabel = labels.find(l => l.id === labelId);
if (newProjectLabel) {
setCurrentTaskLabels([
...currentTaskLabels,
{ id: '', assignedDate: '', projectLabel: { ...newProjectLabel } },
]);
}
}
setCurrentLabel(labelId);
onLabelToggle(labelId);
} else {
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-31 06:11:19 +02:00
label={labels.find(label => label.id === currentLabel) ?? null}
onLabelEdit={(projectLabelID, name, color) => {
if (projectLabelID) {
2020-05-31 06:11:19 +02:00
updateProjectLabel({ variables: { projectLabelID, labelColorID: color.id, name: name ?? '' } });
}
setTab(0);
}}
onLabelDelete={labelID => {
deleteProjectLabel({ variables: { projectLabelID: labelID } });
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-31 06:11:19 +02:00
createProjectLabel({ variables: { projectID, labelColorID: color.id, name: 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-10 04:40:22 +02:00
}
2020-05-31 06:51:22 +02:00
const initialQuickCardEditorState: QuickCardEditorState = {
taskID: null,
taskGroupID: null,
isOpen: false,
top: 0,
left: 0,
};
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-05-31 06:11:19 +02:00
const history = useHistory();
const match = useRouteMatch();
2020-04-20 05:02:55 +02:00
const [updateTaskDescription] = useUpdateTaskDescriptionMutation();
2020-04-10 04:40:22 +02:00
const [quickCardEditor, setQuickCardEditor] = useState(initialQuickCardEditorState);
const [updateTaskLocation] = useUpdateTaskLocationMutation({
update: (client, newTask) => {
const cacheData = getCacheData(client, projectID);
console.log(cacheData);
console.log(newTask);
const newTaskGroups = produce(cacheData.findProject.taskGroups, (draftState: Array<TaskGroup>) => {
const { previousTaskGroupID, task } = newTask.data.updateTaskLocation;
if (previousTaskGroupID !== task.taskGroup.id) {
const oldTaskGroupIdx = draftState.findIndex((t: TaskGroup) => t.id === previousTaskGroupID);
const newTaskGroupIdx = draftState.findIndex((t: TaskGroup) => t.id === task.taskGroup.id);
if (oldTaskGroupIdx !== -1 && newTaskGroupIdx !== -1) {
draftState[oldTaskGroupIdx].tasks = draftState[oldTaskGroupIdx].tasks.filter((t: Task) => t.id !== task.id);
draftState[newTaskGroupIdx].tasks = [...draftState[newTaskGroupIdx].tasks, { ...task }];
}
}
});
const newData = {
...cacheData.findProject,
taskGroups: newTaskGroups,
};
writeCacheData(client, projectID, cacheData, newData);
},
});
2020-05-31 06:11:19 +02:00
const [updateTaskGroupLocation] = useUpdateTaskGroupLocationMutation({});
2020-04-11 21:24:45 +02:00
const [deleteTaskGroup] = useDeleteTaskGroupMutation({
2020-05-31 06:11:19 +02:00
onCompleted: deletedTaskGroupData => {},
update: (client, deletedTaskGroupData) => {
const cacheData = getCacheData(client, projectID);
const newData = {
...cacheData.findProject,
taskGroups: cacheData.findProject.taskGroups.filter(
(taskGroup: any) => taskGroup.id !== deletedTaskGroupData.data.deleteTaskGroup.taskGroup.id,
),
};
writeCacheData(client, projectID, cacheData, newData);
},
2020-04-11 21:24:45 +02:00
});
const [createTaskGroup] = useCreateTaskGroupMutation({
2020-05-31 06:11:19 +02:00
onCompleted: newTaskGroupData => {},
update: (client, newTaskGroupData) => {
const cacheData = getCacheData(client, projectID);
const newData = {
...cacheData.findProject,
taskGroups: [...cacheData.findProject.taskGroups, { ...newTaskGroupData.data.createTaskGroup, tasks: [] }],
};
writeCacheData(client, projectID, cacheData, newData);
},
});
const [createTask] = useCreateTaskMutation({
2020-05-31 06:11:19 +02:00
onCompleted: newTaskData => {},
2020-05-27 02:53:31 +02:00
update: (client, newTaskData) => {
const cacheData = getCacheData(client, projectID);
2020-05-27 02:53:31 +02:00
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 }],
};
});
const newData = {
...cacheData.findProject,
taskGroups: newTaskGroups,
};
writeCacheData(client, projectID, cacheData, newData);
2020-05-27 02:53:31 +02:00
},
2020-04-10 04:40:22 +02:00
});
const [deleteTask] = useDeleteTaskMutation({
2020-05-31 06:11:19 +02:00
onCompleted: deletedTask => {},
2020-04-10 04:40:22 +02:00
});
const [updateTaskName] = useUpdateTaskNameMutation({
2020-05-31 06:11:19 +02:00
onCompleted: newTaskData => {},
});
const [toggleTaskLabel] = useToggleTaskLabelMutation({
onCompleted: newTaskLabel => {
taskLabelsRef.current = newTaskLabel.toggleTaskLabel.task.labels;
console.log(taskLabelsRef.current);
2020-04-10 04:40:22 +02:00
},
});
2020-04-21 01:04:27 +02:00
const { loading, data, refetch } = useFindProjectQuery({
variables: { projectId: projectID },
2020-05-31 06:11:19 +02:00
onCompleted: newData => {},
2020-04-10 04:40:22 +02:00
});
2020-04-10 04:40:22 +02:00
const onCardCreate = (taskGroupID: string, name: string) => {
2020-05-31 06:11:19 +02:00
if (data) {
const taskGroupTasks = data.findProject.taskGroups.filter(t => t.id === taskGroupID);
if (taskGroupTasks) {
let position = 65535;
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;
}
createTask({ variables: { taskGroupID, name, position } });
}
2020-04-10 04:40:22 +02:00
}
2020-05-31 06:11:19 +02:00
};
2020-04-10 04:40:22 +02:00
2020-05-31 06:11:19 +02:00
const onCreateTask = (taskGroupID: string, name: string) => {
if (data) {
const taskGroup = data.findProject.taskGroups.find(t => t.id === taskGroupID);
console.log(`taskGroup ${taskGroup}`);
if (taskGroup) {
let position = 65535;
if (taskGroup.tasks.length !== 0) {
const [lastTask] = taskGroup.tasks.sort((a: any, b: any) => a.position - b.position).slice(-1);
position = Math.ceil(lastTask.position) * 2 + 1;
}
console.log(`position ${position}`);
createTask({ variables: { taskGroupID, name, position } });
}
}
2020-04-10 04:40:22 +02:00
};
const onListDrop = (droppedColumn: TaskGroup) => {
2020-05-31 06:11:19 +02:00
console.log(`list drop ${droppedColumn.id}`);
const cacheData = getCacheData(client, projectID);
const newData = produce(cacheData, (draftState: any) => {
const taskGroupIdx = cacheData.findProject.taskGroups.findIndex((t: any) => t.id === droppedColumn.id);
cacheData.findProject.taskGroups[taskGroupIdx].position = droppedColumn.position;
});
writeCacheData(client, projectID, cacheData, newData);
updateTaskGroupLocation({
2020-05-31 06:11:19 +02:00
variables: { taskGroupID: droppedColumn.id, position: droppedColumn.position },
optimisticResponse: {
updateTaskGroupLocation: {
2020-05-31 06:11:19 +02:00
id: droppedColumn.id,
position: droppedColumn.position,
},
},
});
};
const onCreateList = (listName: string) => {
2020-05-31 06:11:19 +02:00
if (data) {
const [lastColumn] = data.findProject.taskGroups.sort((a, b) => a.position - b.position).slice(-1);
let position = 65535;
if (lastColumn) {
position = lastColumn.position * 2 + 1;
}
createTaskGroup({ variables: { projectID, name: listName, position } });
}
};
2020-04-10 04:40:22 +02:00
2020-04-20 05:02:55 +02:00
const [assignTask] = useAssignTaskMutation();
const [unassignTask] = useUnassignTaskMutation();
2020-04-20 05:02:55 +02:00
const [updateProjectName] = useUpdateProjectNameMutation({
update: (client, newName) => {
const cacheData = getCacheData(client, projectID);
const newData = {
...cacheData.findProject,
name: newName.data.updateProjectName.name,
};
writeCacheData(client, projectID, cacheData, newData);
},
});
2020-05-31 06:11:19 +02:00
const client = useApolloClient();
const { userID } = useContext(UserIDContext);
2020-05-31 06:11:19 +02:00
const { showPopup, hidePopup } = usePopup();
2020-05-27 02:53:31 +02:00
const $labelsRef = useRef<HTMLDivElement>(null);
2020-05-31 06:11:19 +02:00
const labelsRef = useRef<Array<ProjectLabel>>([]);
const taskLabelsRef = useRef<Array<TaskLabel>>([]);
2020-04-10 04:40:22 +02:00
if (loading) {
2020-05-27 02:53:31 +02:00
return (
<>
<GlobalTopNavbar onSaveProjectName={projectName => {}} name="" />
2020-05-27 02:53:31 +02:00
</>
);
2020-04-10 04:40:22 +02:00
}
if (data) {
2020-05-27 02:53:31 +02:00
const onQuickEditorOpen = (e: ContextMenuEvent) => {
2020-05-31 06:11:19 +02:00
const taskGroup = data.findProject.taskGroups.find(t => t.id === e.taskGroupID);
const currentTask = taskGroup ? taskGroup.tasks.find(t => t.id === e.taskID) : null;
if (currentTask) {
setQuickCardEditor({
top: e.top,
left: e.left,
isOpen: true,
2020-05-31 06:51:22 +02:00
taskID: currentTask.id,
taskGroupID: currentTask.taskGroup.id,
2020-05-31 06:11:19 +02:00
});
}
2020-05-27 02:53:31 +02:00
};
2020-05-27 23:18:50 +02:00
2020-05-31 06:11:19 +02:00
labelsRef.current = data.findProject.labels;
2020-05-31 06:51:22 +02:00
let currentQuickTask = null;
if (quickCardEditor.taskID && quickCardEditor.taskGroupID) {
const targetGroup = data.findProject.taskGroups.find(t => t.id === quickCardEditor.taskGroupID);
if (targetGroup) {
currentQuickTask = targetGroup.tasks.find(t => t.id === quickCardEditor.taskID);
}
}
2020-04-10 04:40:22 +02:00
return (
<>
2020-05-31 06:11:19 +02:00
<GlobalTopNavbar
onSaveProjectName={projectName => {
updateProjectName({ variables: { projectID, name: projectName } });
}}
projectMembers={data.findProject.members}
name={data.findProject.name}
/>
2020-05-27 23:18:50 +02:00
<ProjectBar>
<ProjectActions>
<ProjectAction
ref={$labelsRef}
onClick={() => {
showPopup(
$labelsRef,
2020-05-31 06:11:19 +02:00
<LabelManagerEditor
taskLabels={null}
labelColors={data.labelColors}
labels={labelsRef}
projectID={projectID}
/>,
2020-05-27 23:18:50 +02:00
);
}}
>
<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-05-31 06:11:19 +02:00
<SimpleLists
onTaskClick={task => {
history.push(`${match.url}/c/${task.id}`);
}}
onTaskDrop={(droppedTask, previousTaskGroupID) => {
2020-05-31 06:11:19 +02:00
updateTaskLocation({
variables: {
taskID: droppedTask.id,
taskGroupID: droppedTask.taskGroup.id,
position: droppedTask.position,
},
optimisticResponse: {
__typename: 'Mutation',
updateTaskLocation: {
previousTaskGroupID,
task: {
name: droppedTask.name,
id: droppedTask.id,
position: droppedTask.position,
taskGroup: {
id: droppedTask.taskGroup.id,
__typename: 'TaskGroup',
},
createdAt: '',
__typename: 'Task',
},
2020-05-31 06:11:19 +02:00
},
},
});
}}
onTaskGroupDrop={droppedTaskGroup => {
updateTaskGroupLocation({
variables: { taskGroupID: droppedTaskGroup.id, position: droppedTaskGroup.position },
optimisticResponse: {
__typename: 'Mutation',
updateTaskGroupLocation: {
id: droppedTaskGroup.id,
position: droppedTaskGroup.position,
__typename: 'TaskGroup',
},
},
});
}}
taskGroups={data.findProject.taskGroups}
onCreateTask={onCreateTask}
onCreateTaskGroup={onCreateList}
2020-05-27 23:18:50 +02:00
onCardMemberClick={($targetRef, taskID, memberID) => {
2020-05-31 06:11:19 +02:00
const member = data.findProject.members.find(m => m.id === memberID);
const profileIcon = member ? member.profileIcon : null;
2020-05-27 23:18:50 +02:00
showPopup(
$targetRef,
<Popup title={null} onClose={() => {}} tab={0}>
<MiniProfile
2020-05-31 06:11:19 +02:00
profileIcon={profileIcon}
2020-05-27 23:18:50 +02:00
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-31 06:11:19 +02:00
onExtraMenuOpen={(taskGroupID: string, $targetRef: any) => {
2020-05-27 02:53:31 +02:00
showPopup(
$targetRef,
<Popup title="List actions" tab={0} onClose={() => {}}>
<ListActions
taskGroupID={taskGroupID}
onArchiveTaskGroup={tgID => {
deleteTaskGroup({ variables: { taskGroupID: tgID } });
hidePopup();
2020-05-27 02:53:31 +02:00
}}
/>
</Popup>,
);
2020-04-20 05:02:55 +02:00
}}
/>
2020-05-31 06:51:22 +02:00
{quickCardEditor.isOpen && currentQuickTask && (
<QuickCardEditor
2020-05-31 06:51:22 +02:00
task={currentQuickTask}
onCloseEditor={() => setQuickCardEditor(initialQuickCardEditorState)}
onEditCard={(_listId: string, cardId: string, cardName: string) => {
updateTaskName({ variables: { taskID: cardId, name: cardName } });
2020-04-13 00:45:51 +02:00
}}
onOpenMembersPopup={($targetRef, task) => {
showPopup(
$targetRef,
<Popup title="Members" tab={0} onClose={() => {}}>
<MemberManager
availableMembers={data.findProject.members}
activeMembers={task.assigned ?? []}
onMemberChange={(member, isActive) => {
if (isActive) {
assignTask({ variables: { taskID: task.id, userID: userID ?? '' } });
} else {
unassignTask({ variables: { taskID: task.id, userID: userID ?? '' } });
}
}}
/>
</Popup>,
);
}}
onCardMemberClick={($targetRef, taskID, memberID) => {
const member = data.findProject.members.find(m => m.id === memberID);
const profileIcon = member ? member.profileIcon : null;
showPopup(
$targetRef,
<Popup title={null} onClose={() => {}} tab={0}>
<MiniProfile
profileIcon={profileIcon}
displayName="Jordan Knott"
username="@jordanthedev"
bio="None"
onRemoveFromTask={() => {
/* unassignTask({ variables: { taskID: data.findTask.id, userID: userID ?? '' } }); */
}}
/>
</Popup>,
);
}}
2020-05-31 06:51:22 +02:00
onOpenLabelsPopup={($targetRef, task) => {
taskLabelsRef.current = task.labels;
showPopup(
$targetRef,
<LabelManagerEditor
onLabelToggle={labelID => {
toggleTaskLabel({ variables: { taskID: task.id, projectLabelID: labelID } });
}}
labelColors={data.labelColors}
labels={labelsRef}
taskLabels={taskLabelsRef}
projectID={projectID}
/>,
);
}}
2020-05-27 02:53:31 +02:00
onArchiveCard={(_listId: string, cardId: string) =>
deleteTask({
variables: { taskID: cardId },
update: () => {
const cacheData = getCacheData(client, projectID);
2020-05-27 02:53:31 +02:00
const newData = {
...cacheData.findProject,
taskGroups: cacheData.findProject.taskGroups.map((taskGroup: any) => {
return {
...taskGroup,
tasks: taskGroup.tasks.filter((t: any) => t.id !== cardId),
};
}),
};
writeCacheData(client, projectID, cacheData, newData);
2020-05-27 02:53:31 +02:00
},
})
}
top={quickCardEditor.top}
left={quickCardEditor.left}
2020-04-13 00:45:51 +02:00
/>
)}
<Route
path={`${match.path}/c/:taskID`}
render={(routeProps: RouteComponentProps<TaskRouteProps>) => (
2020-04-20 05:02:55 +02:00
<Details
refreshCache={() => {}}
2020-05-31 06:11:19 +02:00
availableMembers={data.findProject.members}
2020-04-20 05:02:55 +02:00
projectURL={match.url}
taskID={routeProps.match.params.taskID}
onTaskNameChange={(updatedTask, newName) => {
2020-05-31 06:11:19 +02:00
updateTaskName({ variables: { taskID: updatedTask.id, name: newName } });
2020-04-20 05:02:55 +02:00
}}
onTaskDescriptionChange={(updatedTask, newDescription) => {
2020-05-31 06:11:19 +02:00
updateTaskDescription({ variables: { taskID: updatedTask.id, description: newDescription } });
}}
2020-04-20 05:02:55 +02:00
onDeleteTask={deletedTask => {
2020-05-31 06:11:19 +02:00
deleteTask({ variables: { taskID: deletedTask.id } });
}}
onOpenAddLabelPopup={(task, $targetRef) => {
taskLabelsRef.current = task.labels;
showPopup(
$targetRef,
<LabelManagerEditor
onLabelToggle={labelID => {
toggleTaskLabel({ variables: { taskID: task.id, projectLabelID: labelID } });
}}
labelColors={data.labelColors}
labels={labelsRef}
taskLabels={taskLabelsRef}
projectID={projectID}
/>,
);
}}
/>
)}
/>
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;