Compare commits
27 Commits
0.2.0
...
feat/publi
Author | SHA1 | Date | |
---|---|---|---|
33f06c1035 | |||
eff2044a6b | |||
451581e934 | |||
0a48b578fd | |||
262f9cbdda | |||
737d2b640f | |||
36f25391b4 | |||
696a9aeee7 | |||
6c7203a4aa | |||
86f2d90668 | |||
92493deedf | |||
a288e06123 | |||
ed4775faa5 | |||
0c7d2e2c9f | |||
4277b7b2a8 | |||
28a53f14ad | |||
0d4fb6a0d0 | |||
0366b4c7f7 | |||
058749cb17 | |||
3d95c6b600 | |||
c7538a98e5 | |||
fe84f97f18 | |||
52c60abcd7 | |||
9fdb3008db | |||
e2ef8a1a19 | |||
61cd376bfd | |||
ba9fc64fd9 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -18,6 +18,8 @@ If applicable, add screenshots to help explain your problem.
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
Please send the Taskcafe web service logs if applicable.
|
||||
|
||||
<!--
|
||||
|
||||
Please read the contributing guide before working on any new pull requests!
|
||||
|
@ -32,6 +32,10 @@ The `description` is a decriptive summary of the change the PR will make.
|
||||
- One PR per fix or feature
|
||||
- Setup & install [pre-commit hooks](https://pre-commit.com/#install) then install the hooks `pre-commit install && pre-commit install --hook-type commit-msg`
|
||||
|
||||
### Unwanted PRs
|
||||
|
||||
- Please do not submit pull requests containing only typo fixes, fixed spelling mistakes, or minor wording changes.
|
||||
|
||||
### Git Commit Message Style
|
||||
|
||||
This project uses the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) format.
|
||||
|
@ -9,11 +9,14 @@
|
||||
<img alt="Releases" src="https://img.shields.io/github/v/release/JordanKnott/taskcafe" />
|
||||
</a>
|
||||
<a href="https://hub.docker.com/repository/docker/taskcafe/taskcafe">
|
||||
<img alt="Dockerhub" src="https://img.shields.io/docker/v/taskcafe/taskcafe?label=docker" />
|
||||
<img alt="Dockerhub" src="https://img.shields.io/docker/v/taskcafe/taskcafe?label=docker&sort=semver" />
|
||||
</a>
|
||||
<a href="https://goreportcard.com/report/github.com/JordanKnott/taskcafe">
|
||||
<img alt="Go Report Card" src="https://goreportcard.com/badge/github.com/JordanKnott/taskcafe" />
|
||||
</a>
|
||||
<a href="">
|
||||
<img alt="Docker pulls" src="https://img.shields.io/docker/pulls/taskcafe/taskcafe" />
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
Was this project useful? Please consider <a href="https://www.buymeacoffee.com/jordanknott">donating</a> to help me improve it!
|
||||
|
47
conf/air.toml
Normal file
47
conf/air.toml
Normal file
@ -0,0 +1,47 @@
|
||||
# Config file for [Air](https://github.com/cosmtrek/air) in TOML format
|
||||
|
||||
# Working directory
|
||||
# . or absolute path, please note that the directories following must be under root.
|
||||
root = "."
|
||||
tmp_dir = "tmp"
|
||||
|
||||
[build]
|
||||
# Just plain old shell command. You could use `make` as well.
|
||||
cmd = "go build -o ./dist/taskcafe cmd/taskcafe/main.go"
|
||||
# Binary file yields from `cmd`.
|
||||
bin = "dist/taskcafe"
|
||||
# Customize binary.
|
||||
full_bin = "./dist/taskcafe web"
|
||||
# Watch these filename extensions.
|
||||
include_ext = ["go"]
|
||||
# Ignore these filename extensions or directories.
|
||||
exclude_dir = ["dist", "frontend"]
|
||||
# Watch these directories if you specified.
|
||||
include_dir = []
|
||||
# Exclude files.
|
||||
exclude_file = []
|
||||
# This log file places in your tmp_dir.
|
||||
log = "air.log"
|
||||
# It's not necessary to trigger build each time file changes if it's too frequent.
|
||||
delay = 1000 # ms
|
||||
# Stop running old binary when build errors occur.
|
||||
stop_on_error = true
|
||||
# Send Interrupt signal before killing process (windows does not support this feature)
|
||||
send_interrupt = false
|
||||
# Delay after sending Interrupt signal
|
||||
kill_delay = 500 # ms
|
||||
|
||||
[log]
|
||||
# Show log time
|
||||
time = false
|
||||
|
||||
[color]
|
||||
# Customize each part's color. If no color found, use the raw app log.
|
||||
main = "magenta"
|
||||
watcher = "cyan"
|
||||
build = "yellow"
|
||||
runner = "green"
|
||||
|
||||
[misc]
|
||||
# Delete tmp directory on exit
|
||||
clean_on_exit = true
|
@ -1,5 +1,5 @@
|
||||
[general]
|
||||
host = '0.0.0.0:3333'
|
||||
[server]
|
||||
hostname = '0.0.0.0:3333'
|
||||
|
||||
[email_notifications]
|
||||
enabled = true
|
||||
|
@ -12,7 +12,7 @@ services:
|
||||
volumes:
|
||||
- taskcafe-postgres:/var/lib/postgresql/data
|
||||
ports:
|
||||
- 5432:5432
|
||||
- 8855:5432
|
||||
mailhog:
|
||||
image: mailhog/mailhog:latest
|
||||
restart: always
|
||||
|
@ -31,7 +31,9 @@
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
"react/jsx-filename-extension": [2, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
|
||||
"no-case-declarations": "off",
|
||||
"no-plusplus": "off",
|
||||
"react/prop-types": 0,
|
||||
"no-continue": "off",
|
||||
"react/jsx-props-no-spreading": "off",
|
||||
"no-param-reassign": "off",
|
||||
"import/extensions": [
|
||||
|
@ -33,13 +33,13 @@
|
||||
"axios-auth-refresh": "^2.2.7",
|
||||
"color": "^3.1.2",
|
||||
"date-fns": "^2.14.0",
|
||||
"dayjs": "^1.9.1",
|
||||
"graphql": "^15.0.0",
|
||||
"graphql-tag": "^2.10.3",
|
||||
"history": "^4.10.1",
|
||||
"immer": "^6.0.3",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"lodash": "^4.17.15",
|
||||
"moment": "^2.24.0",
|
||||
"lodash": "^4.17.20",
|
||||
"prop-types": "^15.7.2",
|
||||
"react": "^16.12.0",
|
||||
"react-autosize-textarea": "^7.0.0",
|
||||
@ -52,9 +52,9 @@
|
||||
"react-router-dom": "^5.1.2",
|
||||
"react-scripts": "3.4.0",
|
||||
"react-select": "^3.1.0",
|
||||
"rich-markdown-editor": "^10.6.5",
|
||||
"react-timeago": "^4.4.0",
|
||||
"react-toastify": "^6.0.8",
|
||||
"rich-markdown-editor": "^10.6.5",
|
||||
"styled-components": "^5.0.1",
|
||||
"typescript": "~3.7.2"
|
||||
},
|
||||
|
@ -5,6 +5,7 @@ import GlobalTopNavbar from 'App/TopNavbar';
|
||||
import {
|
||||
useUsersQuery,
|
||||
useDeleteUserAccountMutation,
|
||||
useDeleteInvitedUserAccountMutation,
|
||||
useCreateUserAccountMutation,
|
||||
UsersDocument,
|
||||
UsersQuery,
|
||||
@ -176,6 +177,17 @@ const AdminRoute = () => {
|
||||
const { loading, data } = useUsersQuery();
|
||||
const { showPopup, hidePopup } = usePopup();
|
||||
const { user } = useCurrentUser();
|
||||
const [deleteInvitedUser] = useDeleteInvitedUserAccountMutation({
|
||||
update: (client, response) => {
|
||||
updateApolloCache<UsersQuery>(client, UsersDocument, cache =>
|
||||
produce(cache, draftCache => {
|
||||
draftCache.invitedUsers = cache.invitedUsers.filter(
|
||||
u => u.id !== response.data.deleteInvitedUserAccount.invitedUser.id,
|
||||
);
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
const [deleteUser] = useDeleteUserAccountMutation({
|
||||
update: (client, response) => {
|
||||
updateApolloCache<UsersQuery>(client, UsersDocument, cache =>
|
||||
@ -215,11 +227,16 @@ const AdminRoute = () => {
|
||||
<Admin
|
||||
initialTab={0}
|
||||
users={data.users}
|
||||
invitedUsers={data.invitedUsers}
|
||||
canInviteUser={user.roles.org === 'admin'}
|
||||
onInviteUser={NOOP}
|
||||
onUpdateUserPassword={() => {
|
||||
hidePopup();
|
||||
}}
|
||||
onDeleteInvitedUser={invitedUserID => {
|
||||
deleteInvitedUser({ variables: { invitedUserID } });
|
||||
hidePopup();
|
||||
}}
|
||||
onDeleteUser={(userID, newOwnerID) => {
|
||||
deleteUser({ variables: { userID, newOwnerID } });
|
||||
hidePopup();
|
||||
|
@ -5,6 +5,7 @@ import * as H from 'history';
|
||||
import Dashboard from 'Dashboard';
|
||||
import Admin from 'Admin';
|
||||
import Projects from 'Projects';
|
||||
import Outline from 'Outline';
|
||||
import Project from 'Projects/Project';
|
||||
import Teams from 'Teams';
|
||||
import Login from 'Auth';
|
||||
@ -36,6 +37,7 @@ const Routes: React.FC<RoutesProps> = () => (
|
||||
<Route path="/teams/:teamID" component={Teams} />
|
||||
<Route path="/profile" component={Profile} />
|
||||
<Route path="/admin" component={Admin} />
|
||||
<Route path="/outline" component={Outline} />
|
||||
</MainContent>
|
||||
</Switch>
|
||||
);
|
||||
|
@ -137,7 +137,7 @@ const ProjectFinder = () => {
|
||||
return {
|
||||
id: team.id,
|
||||
name: team.name,
|
||||
projects: projects.filter(project => project.team.id === team.id),
|
||||
projects: projects.filter(project => project.team && project.team.id === team.id),
|
||||
};
|
||||
});
|
||||
return (
|
||||
@ -230,10 +230,12 @@ type GlobalTopNavbarProps = {
|
||||
menuType?: Array<MenuItem>;
|
||||
onChangeRole?: (userID: string, roleCode: RoleCode) => void;
|
||||
projectMembers?: null | Array<TaskUser>;
|
||||
projectInvitedMembers?: null | Array<InvitedUser>;
|
||||
onSaveProjectName?: (projectName: string) => void;
|
||||
onInviteUser?: ($target: React.RefObject<HTMLElement>) => void;
|
||||
onSetTab?: (tab: number) => void;
|
||||
onRemoveFromBoard?: (userID: string) => void;
|
||||
onRemoveInvitedFromBoard?: (email: string) => void;
|
||||
};
|
||||
|
||||
const GlobalTopNavbar: React.FC<GlobalTopNavbarProps> = ({
|
||||
@ -246,8 +248,10 @@ const GlobalTopNavbar: React.FC<GlobalTopNavbarProps> = ({
|
||||
name,
|
||||
popupContent,
|
||||
projectMembers,
|
||||
projectInvitedMembers,
|
||||
onInviteUser,
|
||||
onSaveProjectName,
|
||||
onRemoveInvitedFromBoard,
|
||||
onRemoveFromBoard,
|
||||
}) => {
|
||||
const { user, setUserRoles, setUser } = useCurrentUser();
|
||||
@ -333,6 +337,34 @@ const GlobalTopNavbar: React.FC<GlobalTopNavbarProps> = ({
|
||||
return null;
|
||||
}
|
||||
const userIsTeamOrProjectAdmin = user.isAdmin(PermissionLevel.TEAM, PermissionObjectType.TEAM, teamID);
|
||||
const onInvitedMemberProfile = ($targetRef: React.RefObject<HTMLElement>, email: string) => {
|
||||
const member = projectInvitedMembers ? projectInvitedMembers.find(u => u.email === email) : null;
|
||||
if (member) {
|
||||
showPopup(
|
||||
$targetRef,
|
||||
<MiniProfile
|
||||
onRemoveFromBoard={() => {
|
||||
if (onRemoveInvitedFromBoard) {
|
||||
onRemoveInvitedFromBoard(member.email);
|
||||
}
|
||||
}}
|
||||
invited
|
||||
user={{
|
||||
id: member.email,
|
||||
fullName: member.email,
|
||||
bio: 'Invited',
|
||||
profileIcon: {
|
||||
bgColor: '#000',
|
||||
url: null,
|
||||
initials: member.email.charAt(0),
|
||||
},
|
||||
}}
|
||||
bio=""
|
||||
/>,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const onMemberProfile = ($targetRef: React.RefObject<HTMLElement>, memberID: string) => {
|
||||
const member = projectMembers ? projectMembers.find(u => u.id === memberID) : null;
|
||||
const warning =
|
||||
@ -382,6 +414,7 @@ const GlobalTopNavbar: React.FC<GlobalTopNavbarProps> = ({
|
||||
canEditProjectName={userIsTeamOrProjectAdmin}
|
||||
canInviteUser={userIsTeamOrProjectAdmin}
|
||||
onMemberProfile={onMemberProfile}
|
||||
onInvitedMemberProfile={onInvitedMemberProfile}
|
||||
onInviteUser={onInviteUser}
|
||||
onChangeRole={onChangeRole}
|
||||
onChangeProjectOwner={onChangeProjectOwner}
|
||||
@ -392,6 +425,7 @@ const GlobalTopNavbar: React.FC<GlobalTopNavbarProps> = ({
|
||||
history.push('/');
|
||||
}}
|
||||
projectMembers={projectMembers}
|
||||
projectInvitedMembers={projectInvitedMembers}
|
||||
onProfileClick={onProfileClick}
|
||||
onSaveName={onSaveProjectName}
|
||||
onOpenSettings={onOpenSettings}
|
||||
|
@ -59,7 +59,7 @@ const Install = () => {
|
||||
} else {
|
||||
const response: RefreshTokenResponse = await x.data;
|
||||
const { accessToken: newToken, isInstalled } = response;
|
||||
const claims: JWTToken = jwtDecode(accessToken);
|
||||
const claims: JWTToken = jwtDecode(newToken);
|
||||
const currentUser = {
|
||||
id: claims.userId,
|
||||
roles: {
|
||||
@ -69,7 +69,7 @@ const Install = () => {
|
||||
},
|
||||
};
|
||||
setUser(currentUser);
|
||||
setAccessToken(accessToken);
|
||||
setAccessToken(newToken);
|
||||
if (!isInstalled) {
|
||||
history.replace('/install');
|
||||
}
|
||||
|
24
frontend/src/Outline/DragDebug.tsx
Normal file
24
frontend/src/Outline/DragDebug.tsx
Normal file
@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { DragDebugWrapper } from './Styles';
|
||||
|
||||
type DragDebugProps = {
|
||||
zone: ImpactZone | null;
|
||||
depthTarget: number;
|
||||
draggedNodes: Array<string> | null;
|
||||
};
|
||||
|
||||
const DragDebug: React.FC<DragDebugProps> = ({ zone, depthTarget, draggedNodes }) => {
|
||||
let aboveID = null;
|
||||
let belowID = null;
|
||||
if (zone) {
|
||||
aboveID = zone.above ? zone.above.node.id : null;
|
||||
belowID = zone.below ? zone.below.node.id : null;
|
||||
}
|
||||
return (
|
||||
<DragDebugWrapper>{`aboveID=${aboveID} / belowID=${belowID} / depthTarget=${depthTarget} draggedNodes=${
|
||||
draggedNodes ? draggedNodes.toString() : null
|
||||
}`}</DragDebugWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default DragDebug;
|
41
frontend/src/Outline/DragIndicator.tsx
Normal file
41
frontend/src/Outline/DragIndicator.tsx
Normal file
@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
import { getDimensions } from './utils';
|
||||
import { DragIndicatorBar } from './Styles';
|
||||
|
||||
type DragIndicatorProps = {
|
||||
container: React.RefObject<HTMLDivElement>;
|
||||
zone: ImpactZone;
|
||||
depthTarget: number;
|
||||
};
|
||||
|
||||
const DragIndicator: React.FC<DragIndicatorProps> = ({ container, zone, depthTarget }) => {
|
||||
let top = 0;
|
||||
let width = 0;
|
||||
if (zone.below === null) {
|
||||
if (zone.above) {
|
||||
const entry = getDimensions(zone.above.dimensions.entry);
|
||||
const children = getDimensions(zone.above.dimensions.children);
|
||||
if (children) {
|
||||
top = children.top;
|
||||
width = children.width - depthTarget * 35;
|
||||
} else if (entry) {
|
||||
top = entry.bottom;
|
||||
width = entry.width - depthTarget * 35;
|
||||
}
|
||||
}
|
||||
} else if (zone.below) {
|
||||
const entry = getDimensions(zone.below.dimensions.entry);
|
||||
if (entry) {
|
||||
top = entry.top;
|
||||
width = entry.width - depthTarget * 35;
|
||||
}
|
||||
}
|
||||
let left = 0;
|
||||
if (container && container.current) {
|
||||
left = container.current.getBoundingClientRect().left + (depthTarget - 1) * 35;
|
||||
width = container.current.getBoundingClientRect().width - depthTarget * 35;
|
||||
}
|
||||
return <DragIndicatorBar top={top} left={left} width={width} />;
|
||||
};
|
||||
|
||||
export default DragIndicator;
|
242
frontend/src/Outline/Dragger.tsx
Normal file
242
frontend/src/Outline/Dragger.tsx
Normal file
@ -0,0 +1,242 @@
|
||||
import React, { useRef, useCallback, useState, useMemo, useEffect } from 'react';
|
||||
import { Dot } from 'shared/icons';
|
||||
import styled from 'styled-components';
|
||||
import {
|
||||
findNextDraggable,
|
||||
getDimensions,
|
||||
getTargetDepth,
|
||||
getNodeAbove,
|
||||
getBelowParent,
|
||||
findNodeAbove,
|
||||
getNodeOver,
|
||||
getLastChildInBranch,
|
||||
findNodeDepth,
|
||||
} from './utils';
|
||||
import { useDrag } from './useDrag';
|
||||
|
||||
const Container = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 9px;
|
||||
background: rgba(${p => p.theme.colors.primary});
|
||||
svg {
|
||||
fill: rgba(${p => p.theme.colors.text.primary});
|
||||
stroke: rgba(${p => p.theme.colors.text.primary});
|
||||
}
|
||||
`;
|
||||
|
||||
type DraggerProps = {
|
||||
container: React.RefObject<HTMLDivElement>;
|
||||
draggedNodes: { nodes: Array<string>; first?: OutlineNode | null };
|
||||
isDragging: boolean;
|
||||
onDragEnd: (zone: ImpactZone) => void;
|
||||
initialPos: { x: number; y: number };
|
||||
};
|
||||
|
||||
const Dragger: React.FC<DraggerProps> = ({ draggedNodes, container, onDragEnd, isDragging, initialPos }) => {
|
||||
const [pos, setPos] = useState<{ x: number; y: number }>(initialPos);
|
||||
const { outline, impact, setImpact } = useDrag();
|
||||
const $handle = useRef<HTMLDivElement>(null);
|
||||
const handleMouseUp = useCallback(() => {
|
||||
onDragEnd(impact ? impact.zone : { below: null, above: null });
|
||||
}, [impact]);
|
||||
const handleMouseMove = useCallback(
|
||||
e => {
|
||||
e.preventDefault();
|
||||
const { clientX, clientY, pageX, pageY } = e;
|
||||
setPos({ x: clientX, y: clientY });
|
||||
const { curDepth, curPosition, curDraggable } = getNodeOver({ x: clientX, y: clientY }, outline.current);
|
||||
let depthTarget: number = 0;
|
||||
let aboveNode: null | OutlineNode = null;
|
||||
let belowNode: null | OutlineNode = null;
|
||||
|
||||
if (curPosition === 'before') {
|
||||
belowNode = curDraggable;
|
||||
} else {
|
||||
aboveNode = curDraggable;
|
||||
}
|
||||
|
||||
// if belowNode has the depth of 1, then the above element will be a part of a different branch
|
||||
|
||||
const { relationships, nodes } = outline.current;
|
||||
if (!belowNode || !aboveNode) {
|
||||
if (belowNode) {
|
||||
aboveNode = findNodeAbove(outline.current, curDepth, belowNode);
|
||||
} else if (aboveNode) {
|
||||
let targetBelowNode: RelationshipChild | null = null;
|
||||
const parent = relationships.get(aboveNode.parent);
|
||||
if (aboveNode.children !== 0 && !aboveNode.collapsed) {
|
||||
const abr = relationships.get(aboveNode.id);
|
||||
if (abr) {
|
||||
const newTarget = abr.children[0];
|
||||
if (newTarget) {
|
||||
targetBelowNode = newTarget;
|
||||
}
|
||||
}
|
||||
} else if (parent) {
|
||||
const aboveNodeIndex = parent.children.findIndex(c => aboveNode && c.id === aboveNode.id);
|
||||
if (aboveNodeIndex !== -1) {
|
||||
if (aboveNodeIndex === parent.children.length - 1) {
|
||||
targetBelowNode = getBelowParent(aboveNode, outline.current);
|
||||
} else {
|
||||
const nextChild = parent.children[aboveNodeIndex + 1];
|
||||
targetBelowNode = nextChild ?? null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetBelowNode) {
|
||||
const depthNodes = nodes.get(targetBelowNode.depth);
|
||||
if (depthNodes) {
|
||||
belowNode = depthNodes.get(targetBelowNode.id) ?? null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if outside outline, get either first or last item in list based on mouse Y
|
||||
if (!aboveNode && !belowNode) {
|
||||
if (container && container.current) {
|
||||
const bounds = container.current.getBoundingClientRect();
|
||||
if (clientY < bounds.top + bounds.height / 2) {
|
||||
const rootChildren = outline.current.relationships.get('root');
|
||||
const rootDepth = outline.current.nodes.get(1);
|
||||
if (rootChildren && rootDepth) {
|
||||
const firstChild = rootChildren.children[0];
|
||||
belowNode = rootDepth.get(firstChild.id) ?? null;
|
||||
aboveNode = null;
|
||||
}
|
||||
} else {
|
||||
// TODO: enhance to actually get last child item, not last top level branch
|
||||
const rootChildren = outline.current.relationships.get('root');
|
||||
const rootDepth = outline.current.nodes.get(1);
|
||||
if (rootChildren && rootDepth) {
|
||||
const lastChild = rootChildren.children[rootChildren.children.length - 1];
|
||||
const lastParentNode = rootDepth.get(lastChild.id) ?? null;
|
||||
|
||||
if (lastParentNode) {
|
||||
const lastBranchChild = getLastChildInBranch(outline.current, lastParentNode);
|
||||
if (lastBranchChild) {
|
||||
const lastChildDepth = outline.current.nodes.get(lastBranchChild.depth);
|
||||
if (lastChildDepth) {
|
||||
aboveNode = lastChildDepth.get(lastBranchChild.id) ?? null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aboveNode) {
|
||||
const { ancestors } = findNodeDepth(outline.current.published, aboveNode.id);
|
||||
for (let i = 0; i < draggedNodes.nodes.length; i++) {
|
||||
const nodeID = draggedNodes.nodes[i];
|
||||
if (ancestors.find(c => c === nodeID)) {
|
||||
if (draggedNodes.first) {
|
||||
belowNode = draggedNodes.first;
|
||||
aboveNode = findNodeAbove(outline.current, aboveNode ? aboveNode.depth : 1, draggedNodes.first);
|
||||
} else {
|
||||
const { depth } = findNodeDepth(outline.current.published, nodeID);
|
||||
const nodeDepth = outline.current.nodes.get(depth);
|
||||
const targetNode = nodeDepth ? nodeDepth.get(nodeID) : null;
|
||||
if (targetNode) {
|
||||
belowNode = targetNode;
|
||||
|
||||
aboveNode = findNodeAbove(outline.current, depth, targetNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calculate available depths
|
||||
|
||||
let minDepth = 1;
|
||||
let maxDepth = 2;
|
||||
if (aboveNode) {
|
||||
const aboveParent = relationships.get(aboveNode.parent);
|
||||
if (aboveNode.children !== 0 && !aboveNode.collapsed) {
|
||||
minDepth = aboveNode.depth + 1;
|
||||
maxDepth = aboveNode.depth + 1;
|
||||
} else if (aboveParent) {
|
||||
minDepth = aboveNode.depth;
|
||||
maxDepth = aboveNode.depth + 1;
|
||||
const aboveNodeIndex = aboveParent.children.findIndex(c => aboveNode && c.id === aboveNode.id);
|
||||
if (aboveNodeIndex === aboveParent.children.length - 1) {
|
||||
minDepth = belowNode ? belowNode.depth : minDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aboveNode) {
|
||||
const dimensions = outline.current.dimensions.get(aboveNode.id);
|
||||
const entry = getDimensions(dimensions?.entry);
|
||||
if (entry) {
|
||||
depthTarget = getTargetDepth(clientX, entry.left, { min: minDepth, max: maxDepth });
|
||||
}
|
||||
}
|
||||
|
||||
let aboveImpact: null | ImpactZoneData = null;
|
||||
let belowImpact: null | ImpactZoneData = null;
|
||||
if (aboveNode) {
|
||||
const aboveDim = outline.current.dimensions.get(aboveNode.id);
|
||||
if (aboveDim) {
|
||||
aboveImpact = {
|
||||
node: aboveNode,
|
||||
dimensions: aboveDim,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (belowNode) {
|
||||
const belowDim = outline.current.dimensions.get(belowNode.id);
|
||||
if (belowDim) {
|
||||
belowImpact = {
|
||||
node: belowNode,
|
||||
dimensions: belowDim,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
setImpact({
|
||||
zone: {
|
||||
above: aboveImpact,
|
||||
below: belowImpact,
|
||||
},
|
||||
depth: depthTarget,
|
||||
});
|
||||
},
|
||||
[outline.current.nodes],
|
||||
);
|
||||
useEffect(() => {
|
||||
document.addEventListener('mouseup', handleMouseUp);
|
||||
document.addEventListener('mousemove', handleMouseMove);
|
||||
return () => {
|
||||
document.removeEventListener('mouseup', handleMouseUp);
|
||||
document.removeEventListener('mousemove', handleMouseMove);
|
||||
};
|
||||
}, []);
|
||||
const styles = useMemo(() => {
|
||||
const position: 'absolute' | 'relative' = isDragging ? 'absolute' : 'relative';
|
||||
return {
|
||||
cursor: isDragging ? '-webkit-grabbing' : '-webkit-grab',
|
||||
transform: `translate(${pos.x - 10}px, ${pos.y - 4}px)`,
|
||||
transition: isDragging ? 'none' : 'transform 500ms',
|
||||
zIndex: isDragging ? 2 : 1,
|
||||
position,
|
||||
};
|
||||
}, [isDragging, pos]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{pos && (
|
||||
<Container ref={$handle} style={styles}>
|
||||
<Dot width={18} height={18} />
|
||||
</Container>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Dragger;
|
155
frontend/src/Outline/Entry.tsx
Normal file
155
frontend/src/Outline/Entry.tsx
Normal file
@ -0,0 +1,155 @@
|
||||
import React, { useRef, useEffect } from 'react';
|
||||
import { Dot, CaretDown, CaretRight } from 'shared/icons';
|
||||
|
||||
import { EntryChildren, EntryWrapper, EntryContent, EntryInnerContent, EntryHandle, ExpandButton } from './Styles';
|
||||
import { useDrag } from './useDrag';
|
||||
|
||||
function getCaretPosition(editableDiv: any) {
|
||||
let caretPos = 0;
|
||||
let sel: any = null;
|
||||
let range: any = null;
|
||||
if (window.getSelection) {
|
||||
sel = window.getSelection();
|
||||
if (sel && sel.rangeCount) {
|
||||
range = sel.getRangeAt(0);
|
||||
if (range.commonAncestorContainer.parentNode === editableDiv) {
|
||||
caretPos = range.endOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
return caretPos;
|
||||
}
|
||||
|
||||
type EntryProps = {
|
||||
id: string;
|
||||
collapsed?: boolean;
|
||||
onToggleCollapse: (id: string, collapsed: boolean) => void;
|
||||
parentID: string;
|
||||
onStartDrag: (e: { id: string; clientX: number; clientY: number }) => void;
|
||||
onStartSelect: (e: { id: string; depth: number }) => void;
|
||||
isRoot?: boolean;
|
||||
selection: null | Array<{ id: string }>;
|
||||
draggedNodes: null | Array<string>;
|
||||
entries: Array<ItemElement>;
|
||||
onCancelDrag: () => void;
|
||||
position: number;
|
||||
chain?: Array<string>;
|
||||
depth?: number;
|
||||
};
|
||||
|
||||
const Entry: React.FC<EntryProps> = ({
|
||||
id,
|
||||
parentID,
|
||||
isRoot = false,
|
||||
selection,
|
||||
onToggleCollapse,
|
||||
onStartSelect,
|
||||
position,
|
||||
onCancelDrag,
|
||||
onStartDrag,
|
||||
collapsed = false,
|
||||
draggedNodes,
|
||||
entries,
|
||||
chain = [],
|
||||
depth = 0,
|
||||
}) => {
|
||||
const $entry = useRef<HTMLDivElement>(null);
|
||||
const $children = useRef<HTMLDivElement>(null);
|
||||
const { setNodeDimensions, clearNodeDimensions } = useDrag();
|
||||
useEffect(() => {
|
||||
if (isRoot) return;
|
||||
if ($entry && $entry.current) {
|
||||
setNodeDimensions(id, {
|
||||
entry: $entry,
|
||||
children: entries.length !== 0 ? $children : null,
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
clearNodeDimensions(id);
|
||||
};
|
||||
}, [position, depth, entries]);
|
||||
let showHandle = true;
|
||||
if (draggedNodes && draggedNodes.length === 1 && draggedNodes.find(c => c === id)) {
|
||||
showHandle = false;
|
||||
}
|
||||
let isSelected = false;
|
||||
if (selection && selection.find(c => c.id === id)) {
|
||||
isSelected = true;
|
||||
}
|
||||
let onSaveTimer: any = null;
|
||||
const onSaveTimeout = 300;
|
||||
return (
|
||||
<EntryWrapper isSelected={isSelected} isDragging={!showHandle}>
|
||||
{!isRoot && (
|
||||
<EntryContent>
|
||||
{entries.length !== 0 && (
|
||||
<ExpandButton onClick={() => onToggleCollapse(id, !collapsed)}>
|
||||
{collapsed ? <CaretRight width={20} height={20} /> : <CaretDown width={20} height={20} />}
|
||||
</ExpandButton>
|
||||
)}
|
||||
{showHandle && (
|
||||
<EntryHandle
|
||||
onMouseUp={() => onCancelDrag()}
|
||||
onMouseDown={e => {
|
||||
onStartDrag({ id, clientX: e.clientX, clientY: e.clientY });
|
||||
}}
|
||||
>
|
||||
<Dot width={18} height={18} />
|
||||
</EntryHandle>
|
||||
)}
|
||||
<EntryInnerContent
|
||||
onMouseDown={() => {
|
||||
onStartSelect({ id, depth });
|
||||
}}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'z' && e.ctrlKey) {
|
||||
if ($entry && $entry.current) {
|
||||
console.log(getCaretPosition($entry.current));
|
||||
}
|
||||
} else {
|
||||
clearTimeout(onSaveTimer);
|
||||
if ($entry && $entry.current) {
|
||||
onSaveTimer = setTimeout(() => {
|
||||
if ($entry && $entry.current) {
|
||||
console.log($entry.current.textContent);
|
||||
}
|
||||
}, onSaveTimeout);
|
||||
}
|
||||
}
|
||||
}}
|
||||
contentEditable
|
||||
ref={$entry}
|
||||
>
|
||||
{`${id.toString()} - ${position}`}
|
||||
</EntryInnerContent>
|
||||
</EntryContent>
|
||||
)}
|
||||
{entries.length !== 0 && !collapsed && (
|
||||
<EntryChildren ref={$children} isRoot={isRoot}>
|
||||
{entries
|
||||
.sort((a, b) => a.position - b.position)
|
||||
.map(entry => (
|
||||
<Entry
|
||||
parentID={id}
|
||||
key={entry.id}
|
||||
position={entry.position}
|
||||
depth={depth + 1}
|
||||
draggedNodes={draggedNodes}
|
||||
collapsed={entry.collapsed}
|
||||
id={entry.id}
|
||||
onStartSelect={onStartSelect}
|
||||
onStartDrag={onStartDrag}
|
||||
onCancelDrag={onCancelDrag}
|
||||
entries={entry.children ?? []}
|
||||
chain={[...chain, id]}
|
||||
selection={selection}
|
||||
onToggleCollapse={onToggleCollapse}
|
||||
/>
|
||||
))}
|
||||
</EntryChildren>
|
||||
)}
|
||||
</EntryWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default Entry;
|
164
frontend/src/Outline/Styles.ts
Normal file
164
frontend/src/Outline/Styles.ts
Normal file
@ -0,0 +1,164 @@
|
||||
import styled, { css } from 'styled-components';
|
||||
import { mixin } from 'shared/utils/styles';
|
||||
|
||||
export const EntryWrapper = styled.div<{ isDragging: boolean; isSelected: boolean }>`
|
||||
position: relative;
|
||||
${props =>
|
||||
props.isDragging &&
|
||||
css`
|
||||
&:before {
|
||||
border-radius: 3px;
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: -5px;
|
||||
left: -5px;
|
||||
bottom: -2px;
|
||||
background-color: #eceef0;
|
||||
}
|
||||
`}
|
||||
${props =>
|
||||
props.isSelected &&
|
||||
css`
|
||||
&:before {
|
||||
border-radius: 3px;
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: -5px;
|
||||
bottom: -2px;
|
||||
left: -5px;
|
||||
background-color: rgba(${props.theme.colors.primary}, 0.75);
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
export const EntryChildren = styled.div<{ isRoot: boolean }>`
|
||||
position: relative;
|
||||
${props =>
|
||||
!props.isRoot &&
|
||||
css`
|
||||
margin-left: 10px;
|
||||
padding-left: 25px;
|
||||
border-left: 1px solid rgba(${props.theme.colors.text.primary}, 0.6);
|
||||
`}
|
||||
`;
|
||||
|
||||
export const PageContent = styled.div`
|
||||
min-height: calc(100vh - 146px);
|
||||
width: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: none;
|
||||
user-select: none;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 700px;
|
||||
padding-left: 56px;
|
||||
padding-right: 56px;
|
||||
padding-top: 24px;
|
||||
padding-bottom: 24px;
|
||||
text-size-adjust: none;
|
||||
`;
|
||||
|
||||
export const DragHandle = styled.div<{ top: number; left: number }>`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
transform: translate3d(${props => props.left}px, ${props => props.top}px, 0);
|
||||
transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
color: rgb(75, 81, 85);
|
||||
border-radius: 9px;
|
||||
`;
|
||||
export const RootWrapper = styled.div``;
|
||||
|
||||
export const EntryHandle = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
left: 501px;
|
||||
top: 7px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
color: rgba(${p => p.theme.colors.text.primary});
|
||||
border-radius: 9px;
|
||||
&:hover {
|
||||
background: rgba(${p => p.theme.colors.primary});
|
||||
}
|
||||
svg {
|
||||
fill: rgba(${p => p.theme.colors.text.primary});
|
||||
stroke: rgba(${p => p.theme.colors.text.primary});
|
||||
}
|
||||
`;
|
||||
|
||||
export const EntryInnerContent = styled.div`
|
||||
padding-top: 4px;
|
||||
font-size: 15px;
|
||||
white-space: pre-wrap;
|
||||
line-height: 24px;
|
||||
min-height: 24px;
|
||||
overflow-wrap: break-word;
|
||||
position: relative;
|
||||
user-select: text;
|
||||
color: rgba(${p => p.theme.colors.text.primary});
|
||||
&::selection {
|
||||
background: #a49de8;
|
||||
}
|
||||
&:focus {
|
||||
outline: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
export const DragDebugWrapper = styled.div`
|
||||
position: absolute;
|
||||
left: 42px;
|
||||
bottom: 24px;
|
||||
color: #fff;
|
||||
`;
|
||||
|
||||
export const DragIndicatorBar = styled.div<{ left: number; top: number; width: number }>`
|
||||
position: absolute;
|
||||
width: ${props => props.width}px;
|
||||
top: ${props => props.top}px;
|
||||
left: ${props => props.left}px;
|
||||
height: 4px;
|
||||
border-radius: 3px;
|
||||
background: rgb(204, 204, 204);
|
||||
`;
|
||||
|
||||
export const ExpandButton = styled.div`
|
||||
top: 6px;
|
||||
cursor: default;
|
||||
color: transparent;
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
left: 478px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
svg {
|
||||
fill: transparent;
|
||||
}
|
||||
`;
|
||||
export const EntryContent = styled.div`
|
||||
position: relative;
|
||||
margin-left: -500px;
|
||||
padding-left: 524px;
|
||||
|
||||
&:hover ${ExpandButton} svg {
|
||||
fill: rgb(${props => props.theme.colors.text.primary});
|
||||
}
|
||||
`;
|
||||
|
||||
export const PageContainer = styled.div`
|
||||
overflow: scroll;
|
||||
`;
|
504
frontend/src/Outline/index.tsx
Normal file
504
frontend/src/Outline/index.tsx
Normal file
@ -0,0 +1,504 @@
|
||||
import React, { useState, useRef, useEffect, useMemo, useCallback, useContext, memo, createRef } from 'react';
|
||||
import { DotCircle } from 'shared/icons';
|
||||
import styled from 'styled-components/macro';
|
||||
import GlobalTopNavbar from 'App/TopNavbar';
|
||||
import _ from 'lodash';
|
||||
import produce from 'immer';
|
||||
import Entry from './Entry';
|
||||
import DragIndicator from './DragIndicator';
|
||||
import Dragger from './Dragger';
|
||||
import DragDebug from './DragDebug';
|
||||
import { DragContext } from './useDrag';
|
||||
|
||||
import {
|
||||
PageContainer,
|
||||
DragDebugWrapper,
|
||||
DragIndicatorBar,
|
||||
PageContent,
|
||||
EntryChildren,
|
||||
EntryInnerContent,
|
||||
EntryWrapper,
|
||||
EntryContent,
|
||||
RootWrapper,
|
||||
EntryHandle,
|
||||
} from './Styles';
|
||||
import {
|
||||
transformToTree,
|
||||
findNode,
|
||||
findNodeDepth,
|
||||
getNumberOfChildren,
|
||||
validateDepth,
|
||||
getDimensions,
|
||||
findNextDraggable,
|
||||
getNodeOver,
|
||||
getCorrectNode,
|
||||
findCommonParent,
|
||||
} from './utils';
|
||||
import NOOP from 'shared/utils/noop';
|
||||
|
||||
type OutlineCommand = {
|
||||
nodes: Array<{
|
||||
id: string;
|
||||
prev: { position: number; parent: string | null };
|
||||
next: { position: number; parent: string | null };
|
||||
}>;
|
||||
};
|
||||
|
||||
type ItemCollapsed = {
|
||||
id: string;
|
||||
collapsed: boolean;
|
||||
};
|
||||
|
||||
const listItems: Array<ItemElement> = [
|
||||
{ id: 'root', position: 4096, parent: null, collapsed: false },
|
||||
{ id: 'entry-1', position: 4096, parent: 'root', collapsed: false },
|
||||
{ id: 'entry-1_3', position: 4096 * 3, parent: 'entry-1', collapsed: false },
|
||||
{ id: 'entry-1_3_1', position: 4096, parent: 'entry-1_3', collapsed: false },
|
||||
{ id: 'entry-1_3_2', position: 4096 * 2, parent: 'entry-1_3', collapsed: false },
|
||||
{ id: 'entry-1_3_3', position: 4096 * 3, parent: 'entry-1_3', collapsed: false },
|
||||
{ id: 'entry-1_3_3_1', position: 4096 * 1, parent: 'entry-1_3_3', collapsed: false },
|
||||
{ id: 'entry-1_3_3_1_1', position: 4096 * 1, parent: 'entry-1_3_3_1', collapsed: false },
|
||||
{ id: 'entry-2', position: 4096 * 2, parent: 'root', collapsed: false },
|
||||
{ id: 'entry-3', position: 4096 * 3, parent: 'root', collapsed: false },
|
||||
{ id: 'entry-4', position: 4096 * 4, parent: 'root', collapsed: false },
|
||||
{ id: 'entry-5', position: 4096 * 5, parent: 'root', collapsed: false },
|
||||
];
|
||||
|
||||
const Outline: React.FC = () => {
|
||||
const [items, setItems] = useState(listItems);
|
||||
const [selecting, setSelecting] = useState<{
|
||||
isSelecting: boolean;
|
||||
node: { id: string; depth: number } | null;
|
||||
}>({ isSelecting: false, node: null });
|
||||
const [selection, setSelection] = useState<null | { nodes: Array<{ id: string }>; first?: OutlineNode | null }>(null);
|
||||
const [dragging, setDragging] = useState<{
|
||||
show: boolean;
|
||||
draggedNodes: null | Array<string>;
|
||||
initialPos: { x: number; y: number };
|
||||
}>({ show: false, draggedNodes: null, initialPos: { x: 0, y: 0 } });
|
||||
const [impact, setImpact] = useState<null | {
|
||||
listPosition: number;
|
||||
zone: ImpactZone;
|
||||
depthTarget: number;
|
||||
}>(null);
|
||||
const selectRef = useRef<{ isSelecting: boolean; hasSelection: boolean; node: { id: string; depth: number } | null }>(
|
||||
{
|
||||
isSelecting: false,
|
||||
node: null,
|
||||
hasSelection: false,
|
||||
},
|
||||
);
|
||||
const impactRef = useRef<null | { listPosition: number; depth: number; zone: ImpactZone }>(null);
|
||||
useEffect(() => {
|
||||
if (impact) {
|
||||
impactRef.current = { zone: impact.zone, depth: impact.depthTarget, listPosition: impact.listPosition };
|
||||
}
|
||||
}, [impact]);
|
||||
useEffect(() => {
|
||||
selectRef.current.isSelecting = selecting.isSelecting;
|
||||
selectRef.current.node = selecting.node;
|
||||
}, [selecting]);
|
||||
|
||||
const $content = useRef<HTMLDivElement>(null);
|
||||
const outline = useRef<OutlineData>({
|
||||
published: new Map<string, string>(),
|
||||
dimensions: new Map<string, NodeDimensions>(),
|
||||
nodes: new Map<number, Map<string, OutlineNode>>(),
|
||||
relationships: new Map<string, NodeRelationships>(),
|
||||
});
|
||||
|
||||
const tree = transformToTree(_.cloneDeep(items));
|
||||
let root: any = null;
|
||||
if (tree.length === 1) {
|
||||
root = tree[0];
|
||||
}
|
||||
const outlineHistory = useRef<{ commands: Array<OutlineCommand>; current: number }>({ current: -1, commands: [] });
|
||||
|
||||
useEffect(() => {
|
||||
outline.current.relationships = new Map<string, NodeRelationships>();
|
||||
outline.current.published = new Map<string, string>();
|
||||
outline.current.nodes = new Map<number, Map<string, OutlineNode>>();
|
||||
const collapsedMap = items.reduce((map, next) => {
|
||||
if (next.collapsed) {
|
||||
map.set(next.id, true);
|
||||
}
|
||||
return map;
|
||||
}, new Map<string, boolean>());
|
||||
items.forEach(item => outline.current.published.set(item.id, item.parent ?? 'root'));
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const { collapsed, position, id, parent: curParent } = items[i];
|
||||
if (id === 'root') {
|
||||
continue;
|
||||
}
|
||||
const parent = curParent ?? 'root';
|
||||
outline.current.published.set(id, parent ?? 'root');
|
||||
const { depth, ancestors } = findNodeDepth(outline.current.published, id);
|
||||
const collapsedParent = ancestors.slice(0, -1).find(a => collapsedMap.get(a));
|
||||
if (collapsedParent) {
|
||||
continue;
|
||||
}
|
||||
const children = getNumberOfChildren(root, ancestors);
|
||||
if (!outline.current.nodes.has(depth)) {
|
||||
outline.current.nodes.set(depth, new Map<string, OutlineNode>());
|
||||
}
|
||||
const targetDepthNodes = outline.current.nodes.get(depth);
|
||||
if (targetDepthNodes) {
|
||||
targetDepthNodes.set(id, {
|
||||
id,
|
||||
children,
|
||||
position,
|
||||
depth,
|
||||
ancestors,
|
||||
collapsed,
|
||||
parent,
|
||||
});
|
||||
}
|
||||
if (!outline.current.relationships.has(parent)) {
|
||||
outline.current.relationships.set(parent, {
|
||||
self: {
|
||||
depth: depth - 1,
|
||||
id: parent,
|
||||
},
|
||||
children: [],
|
||||
numberOfSubChildren: 0,
|
||||
});
|
||||
}
|
||||
const nodeRelations = outline.current.relationships.get(parent);
|
||||
if (nodeRelations) {
|
||||
outline.current.relationships.set(parent, {
|
||||
self: nodeRelations.self,
|
||||
numberOfSubChildren: nodeRelations.numberOfSubChildren + children,
|
||||
children: [...nodeRelations.children, { id, position, depth, children }].sort(
|
||||
(a, b) => a.position - b.position,
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [items]);
|
||||
const handleKeyDown = useCallback(e => {
|
||||
if (e.code === 'KeyZ' && e.ctrlKey) {
|
||||
const currentCommand = outlineHistory.current.commands[outlineHistory.current.current];
|
||||
if (currentCommand) {
|
||||
setItems(prevItems =>
|
||||
produce(prevItems, draftItems => {
|
||||
currentCommand.nodes.forEach(node => {
|
||||
const idx = prevItems.findIndex(c => c.id === node.id);
|
||||
if (idx !== -1) {
|
||||
draftItems[idx].parent = node.prev.parent;
|
||||
draftItems[idx].position = node.prev.position;
|
||||
}
|
||||
});
|
||||
outlineHistory.current.current--;
|
||||
}),
|
||||
);
|
||||
}
|
||||
} else if (e.code === 'KeyY' && e.ctrlKey) {
|
||||
const currentCommand = outlineHistory.current.commands[outlineHistory.current.current + 1];
|
||||
if (currentCommand) {
|
||||
setItems(prevItems =>
|
||||
produce(prevItems, draftItems => {
|
||||
currentCommand.nodes.forEach(node => {
|
||||
const idx = prevItems.findIndex(c => c.id === node.id);
|
||||
if (idx !== -1) {
|
||||
draftItems[idx].parent = node.next.parent;
|
||||
draftItems[idx].position = node.next.position;
|
||||
}
|
||||
});
|
||||
outlineHistory.current.current++;
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleMouseUp = useCallback(
|
||||
e => {
|
||||
if (selectRef.current.hasSelection && !selectRef.current.isSelecting) {
|
||||
setSelection(null);
|
||||
}
|
||||
if (selectRef.current.isSelecting) {
|
||||
setSelecting({ isSelecting: false, node: null });
|
||||
}
|
||||
},
|
||||
[dragging, selecting],
|
||||
);
|
||||
const handleMouseMove = useCallback(e => {
|
||||
if (selectRef.current.isSelecting && selectRef.current.node) {
|
||||
const { clientX, clientY } = e;
|
||||
const dimensions = outline.current.dimensions.get(selectRef.current.node.id);
|
||||
if (dimensions) {
|
||||
const entry = getDimensions(dimensions.entry);
|
||||
if (entry) {
|
||||
const isAbove = clientY < entry.top;
|
||||
const isBelow = clientY > entry.bottom;
|
||||
if (!isAbove && !isBelow && selectRef.current.hasSelection) {
|
||||
const nodeDepth = outline.current.nodes.get(selectRef.current.node.depth);
|
||||
const aboveNode = nodeDepth ? nodeDepth.get(selectRef.current.node.id) : null;
|
||||
if (aboveNode) {
|
||||
setSelection({ nodes: [{ id: selectRef.current.node.id }], first: aboveNode });
|
||||
selectRef.current.hasSelection = false;
|
||||
}
|
||||
}
|
||||
if (isAbove || isBelow) {
|
||||
e.preventDefault();
|
||||
const { curDraggable } = getNodeOver({ x: clientX, y: clientY }, outline.current);
|
||||
const nodeDepth = outline.current.nodes.get(selectRef.current.node.depth);
|
||||
const selectedNode = nodeDepth ? nodeDepth.get(selectRef.current.node.id) : null;
|
||||
let aboveNode: OutlineNode | undefined | null = null;
|
||||
let belowNode: OutlineNode | undefined | null = null;
|
||||
if (isBelow) {
|
||||
aboveNode = selectedNode;
|
||||
belowNode = curDraggable;
|
||||
} else {
|
||||
aboveNode = curDraggable;
|
||||
belowNode = selectedNode;
|
||||
}
|
||||
if (aboveNode && belowNode) {
|
||||
const aboveDim = outline.current.dimensions.get(aboveNode.id);
|
||||
const belowDim = outline.current.dimensions.get(belowNode.id);
|
||||
if (aboveDim && belowDim) {
|
||||
const aboveDimBounds = getDimensions(aboveDim.entry);
|
||||
const belowDimBounds = getDimensions(belowDim.children ? belowDim.children : belowDim.entry);
|
||||
const aboveDimY = aboveDimBounds ? aboveDimBounds.bottom : 0;
|
||||
const belowDimY = belowDimBounds ? belowDimBounds.top : 0;
|
||||
const inbetweenNodes: Array<{ id: string }> = [];
|
||||
for (const [id, dimension] of outline.current.dimensions.entries()) {
|
||||
if (id === aboveNode.id || id === belowNode.id) {
|
||||
inbetweenNodes.push({ id });
|
||||
continue;
|
||||
}
|
||||
const targetNodeBounds = getDimensions(dimension.entry);
|
||||
if (targetNodeBounds) {
|
||||
if (
|
||||
Math.round(aboveDimY) <= Math.round(targetNodeBounds.top) &&
|
||||
Math.round(belowDimY) >= Math.round(targetNodeBounds.bottom)
|
||||
) {
|
||||
inbetweenNodes.push({ id });
|
||||
}
|
||||
}
|
||||
}
|
||||
const filteredNodes = inbetweenNodes.filter(n => {
|
||||
const parent = outline.current.published.get(n.id);
|
||||
if (parent) {
|
||||
const foundParent = inbetweenNodes.find(c => c.id === parent);
|
||||
if (foundParent) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
selectRef.current.hasSelection = true;
|
||||
setSelection({ nodes: filteredNodes, first: aboveNode });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
document.addEventListener('mouseup', handleMouseUp);
|
||||
document.addEventListener('mousemove', handleMouseMove);
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
return () => {
|
||||
document.removeEventListener('mouseup', handleMouseUp);
|
||||
document.removeEventListener('mousemove', handleMouseMove);
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!root) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<GlobalTopNavbar onSaveProjectName={NOOP} projectID={null} name={null} />
|
||||
<DragContext.Provider
|
||||
value={{
|
||||
outline,
|
||||
impact,
|
||||
setImpact: data => {
|
||||
if (data) {
|
||||
const { zone, depth } = data;
|
||||
let listPosition = 65535;
|
||||
if (zone.above && zone.above.node.depth + 1 <= depth && zone.above.node.collapsed) {
|
||||
const aboveChildren = items
|
||||
.filter(i => (zone.above ? i.parent === zone.above.node.id : false))
|
||||
.sort((a, b) => a.position - b.position);
|
||||
const lastChild = aboveChildren[aboveChildren.length - 1];
|
||||
if (lastChild) {
|
||||
listPosition = lastChild.position * 2.0;
|
||||
}
|
||||
} else {
|
||||
console.log(zone.above);
|
||||
console.log(zone.below);
|
||||
const correctNode = getCorrectNode(outline.current, zone.above ? zone.above.node : null, depth);
|
||||
console.log(correctNode);
|
||||
const listAbove = validateDepth(correctNode, depth);
|
||||
const listBelow = validateDepth(zone.below ? zone.below.node : null, depth);
|
||||
console.log(listAbove, listBelow);
|
||||
if (listAbove && listBelow) {
|
||||
listPosition = (listAbove.position + listBelow.position) / 2.0;
|
||||
} else if (listAbove && !listBelow) {
|
||||
listPosition = listAbove.position * 2.0;
|
||||
} else if (!listAbove && listBelow) {
|
||||
listPosition = listBelow.position / 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!zone.above && zone.below) {
|
||||
const newPosition = zone.below.node.position / 2.0;
|
||||
setImpact(() => ({
|
||||
zone,
|
||||
listPosition: newPosition,
|
||||
depthTarget: depth,
|
||||
}));
|
||||
}
|
||||
if (zone.above) {
|
||||
// console.log(`prev=${prev} next=${next} targetPosition=${targetPosition}`);
|
||||
// let targetID = depthTarget === 1 ? 'root' : node.ancestors[depthTarget - 1];
|
||||
// targetID = targetID ?? node.id;
|
||||
setImpact(() => ({
|
||||
zone,
|
||||
listPosition,
|
||||
depthTarget: depth,
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
setImpact(null);
|
||||
}
|
||||
},
|
||||
setNodeDimensions: (nodeID, ref) => {
|
||||
outline.current.dimensions.set(nodeID, ref);
|
||||
},
|
||||
clearNodeDimensions: nodeID => {
|
||||
outline.current.dimensions.delete(nodeID);
|
||||
},
|
||||
}}
|
||||
>
|
||||
<>
|
||||
<PageContainer>
|
||||
<PageContent>
|
||||
<RootWrapper ref={$content}>
|
||||
<Entry
|
||||
onStartSelect={({ id, depth }) => {
|
||||
setSelection(null);
|
||||
setSelecting({ isSelecting: true, node: { id, depth } });
|
||||
}}
|
||||
onToggleCollapse={(id, collapsed) => {
|
||||
setItems(prevItems =>
|
||||
produce(prevItems, draftItems => {
|
||||
const idx = prevItems.findIndex(c => c.id === id);
|
||||
if (idx !== -1) {
|
||||
draftItems[idx].collapsed = collapsed;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}}
|
||||
id="root"
|
||||
parentID="root"
|
||||
isRoot
|
||||
selection={selection ? selection.nodes : null}
|
||||
draggedNodes={dragging.draggedNodes}
|
||||
position={root.position}
|
||||
entries={root.children}
|
||||
onCancelDrag={() => {
|
||||
setImpact(null);
|
||||
setDragging({ show: false, draggedNodes: null, initialPos: { x: 0, y: 0 } });
|
||||
}}
|
||||
onStartDrag={e => {
|
||||
if (e.id !== 'root') {
|
||||
if (selectRef.current.hasSelection && selection && selection.nodes.find(c => c.id === e.id)) {
|
||||
setImpact(null);
|
||||
setDragging({
|
||||
show: true,
|
||||
draggedNodes: [...selection.nodes.map(c => c.id)],
|
||||
initialPos: { x: e.clientX, y: e.clientY },
|
||||
});
|
||||
} else {
|
||||
setImpact(null);
|
||||
setDragging({ show: true, draggedNodes: [e.id], initialPos: { x: e.clientX, y: e.clientY } });
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</RootWrapper>
|
||||
</PageContent>
|
||||
</PageContainer>
|
||||
{dragging.show && dragging.draggedNodes && (
|
||||
<Dragger
|
||||
container={$content}
|
||||
initialPos={dragging.initialPos}
|
||||
draggedNodes={{ nodes: dragging.draggedNodes, first: selection ? selection.first : null }}
|
||||
isDragging={dragging.show}
|
||||
onDragEnd={() => {
|
||||
if (dragging.draggedNodes && impactRef.current) {
|
||||
const { zone, depth, listPosition } = impactRef.current;
|
||||
const noZone = !zone.above && !zone.below;
|
||||
if (!noZone) {
|
||||
let parentID = 'root';
|
||||
if (zone.above) {
|
||||
parentID = zone.above.node.ancestors[depth - 1];
|
||||
}
|
||||
let reparent = true;
|
||||
for (let i = 0; i < dragging.draggedNodes.length; i++) {
|
||||
const draggedID = dragging.draggedNodes[i];
|
||||
const prevItem = items.find(i => i.id === draggedID);
|
||||
if (prevItem && prevItem.position === listPosition && prevItem.parent === parentID) {
|
||||
reparent = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: set reparent if list position changed but parent did not
|
||||
//
|
||||
|
||||
if (reparent) {
|
||||
// UPDATE OUTLINE DATA AFTER NODE MOVE
|
||||
setItems(itemsPrev =>
|
||||
produce(itemsPrev, draftItems => {
|
||||
if (dragging.draggedNodes) {
|
||||
const command: OutlineCommand = { nodes: [] };
|
||||
outlineHistory.current.current += 1;
|
||||
dragging.draggedNodes.forEach(n => {
|
||||
const curDragging = itemsPrev.findIndex(i => i.id === n);
|
||||
command.nodes.push({
|
||||
id: n,
|
||||
prev: {
|
||||
parent: draftItems[curDragging].parent,
|
||||
position: draftItems[curDragging].position,
|
||||
},
|
||||
next: {
|
||||
parent: parentID,
|
||||
position: listPosition,
|
||||
},
|
||||
});
|
||||
draftItems[curDragging].parent = parentID;
|
||||
draftItems[curDragging].position = listPosition;
|
||||
});
|
||||
outlineHistory.current.commands[outlineHistory.current.current] = command;
|
||||
if (outlineHistory.current.commands[outlineHistory.current.current + 1]) {
|
||||
outlineHistory.current.commands.splice(outlineHistory.current.current + 1);
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
setImpact(null);
|
||||
setDragging({ show: false, draggedNodes: null, initialPos: { x: 0, y: 0 } });
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
</DragContext.Provider>
|
||||
{impact && <DragIndicator depthTarget={impact.depthTarget} container={$content} zone={impact.zone} />}
|
||||
{impact && (
|
||||
<DragDebug zone={impact.zone ?? null} draggedNodes={dragging.draggedNodes} depthTarget={impact.depthTarget} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Outline;
|
22
frontend/src/Outline/useDrag.ts
Normal file
22
frontend/src/Outline/useDrag.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import React, { useContext } from 'react';
|
||||
|
||||
type DragContextData = {
|
||||
impact: null | { zone: ImpactZone; depthTarget: number };
|
||||
outline: React.MutableRefObject<OutlineData>;
|
||||
setNodeDimensions: (
|
||||
nodeID: string,
|
||||
ref: { entry: React.RefObject<HTMLElement>; children: React.RefObject<HTMLElement> | null },
|
||||
) => void;
|
||||
clearNodeDimensions: (nodeID: string) => void;
|
||||
setImpact: (data: ImpactData | null) => void;
|
||||
};
|
||||
|
||||
export const DragContext = React.createContext<DragContextData | null>(null);
|
||||
|
||||
export const useDrag = () => {
|
||||
const ctx = useContext(DragContext);
|
||||
if (ctx) {
|
||||
return ctx;
|
||||
}
|
||||
throw new Error('context is null');
|
||||
};
|
361
frontend/src/Outline/utils.ts
Normal file
361
frontend/src/Outline/utils.ts
Normal file
@ -0,0 +1,361 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export function getCorrectNode(data: OutlineData, node: OutlineNode | null, depth: number) {
|
||||
if (node) {
|
||||
console.log(depth, node);
|
||||
if (depth === node.depth) {
|
||||
return node;
|
||||
}
|
||||
const parent = node.ancestors[depth];
|
||||
console.log('parent', parent);
|
||||
if (parent) {
|
||||
const parentNode = data.relationships.get(parent);
|
||||
if (parentNode) {
|
||||
const parentDepth = parentNode.self.depth;
|
||||
const nodeDepth = data.nodes.get(parentDepth);
|
||||
return nodeDepth ? nodeDepth.get(parent) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
export function validateDepth(node: OutlineNode | null | undefined, depth: number) {
|
||||
if (node) {
|
||||
return node.depth === depth ? node : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getNodeAbove(node: OutlineNode, startingParent: RelationshipChild, outline: OutlineData) {
|
||||
let hasChildren = true;
|
||||
let nodeAbove: null | RelationshipChild = null;
|
||||
let aboveTargetID = startingParent.id;
|
||||
while (hasChildren) {
|
||||
const targetParent = outline.relationships.get(aboveTargetID);
|
||||
if (targetParent) {
|
||||
const parentNodes = outline.nodes.get(targetParent.self.depth);
|
||||
const parentNode = parentNodes ? parentNodes.get(targetParent.self.id) : null;
|
||||
if (targetParent.children.length === 0) {
|
||||
if (parentNode) {
|
||||
nodeAbove = {
|
||||
id: parentNode.id,
|
||||
depth: parentNode.depth,
|
||||
position: parentNode.position,
|
||||
children: parentNode.children,
|
||||
};
|
||||
console.log('node above', nodeAbove);
|
||||
}
|
||||
hasChildren = false;
|
||||
continue;
|
||||
}
|
||||
nodeAbove = targetParent.children[targetParent.children.length - 1];
|
||||
if (targetParent.numberOfSubChildren === 0) {
|
||||
hasChildren = false;
|
||||
} else {
|
||||
aboveTargetID = nodeAbove.id;
|
||||
}
|
||||
} else {
|
||||
const target = outline.relationships.get(node.ancestors[0]);
|
||||
if (target) {
|
||||
const targetChild = target.children.find(i => i.id === aboveTargetID);
|
||||
if (targetChild) {
|
||||
nodeAbove = targetChild;
|
||||
}
|
||||
hasChildren = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('final node above', nodeAbove);
|
||||
return nodeAbove;
|
||||
}
|
||||
|
||||
export function getBelowParent(node: OutlineNode, outline: OutlineData) {
|
||||
const { relationships, nodes } = outline;
|
||||
const parentDepth = nodes.get(node.depth - 1);
|
||||
const parent = parentDepth ? parentDepth.get(node.parent) : null;
|
||||
if (parent) {
|
||||
const grandfather = relationships.get(parent.parent);
|
||||
if (grandfather) {
|
||||
const parentIndex = grandfather.children.findIndex(c => c.id === parent.id);
|
||||
if (parentIndex !== -1) {
|
||||
if (parentIndex === grandfather.children.length - 1) {
|
||||
const root = relationships.get(node.ancestors[0]);
|
||||
if (root) {
|
||||
const ancestorIndex = root.children.findIndex(c => c.id === node.ancestors[1]);
|
||||
if (ancestorIndex !== -1) {
|
||||
const nextAncestor = root.children[ancestorIndex + 1];
|
||||
if (nextAncestor) {
|
||||
return nextAncestor;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const nextChild = grandfather.children[parentIndex + 1];
|
||||
if (nextChild) {
|
||||
return nextChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getDimensions(ref: React.RefObject<HTMLElement> | null | undefined) {
|
||||
if (ref && ref.current) {
|
||||
return ref.current.getBoundingClientRect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getTargetDepth(mouseX: number, handleLeft: number, availableDepths: { min: number; max: number }) {
|
||||
if (mouseX > handleLeft) {
|
||||
return availableDepths.max;
|
||||
}
|
||||
let curDepth = availableDepths.max - 1;
|
||||
for (let x = availableDepths.min; x < availableDepths.max; x++) {
|
||||
const breakpoint = handleLeft - x * 35;
|
||||
// console.log(`mouseX=${mouseX} breakpoint=${breakpoint} x=${x} curDepth=${curDepth}`);
|
||||
if (mouseX > breakpoint) {
|
||||
return curDepth;
|
||||
}
|
||||
curDepth -= 1;
|
||||
}
|
||||
|
||||
return availableDepths.min;
|
||||
}
|
||||
|
||||
export function findNextDraggable(pos: { x: number; y: number }, outline: OutlineData, curDepth: number) {
|
||||
let index = 0;
|
||||
const currentDepthNodes = outline.nodes.get(curDepth);
|
||||
let nodeAbove: null | RelationshipChild = null;
|
||||
if (!currentDepthNodes) {
|
||||
return null;
|
||||
}
|
||||
for (const [id, node] of currentDepthNodes) {
|
||||
const dimensions = outline.dimensions.get(id);
|
||||
const target = dimensions ? getDimensions(dimensions.entry) : null;
|
||||
const children = dimensions ? getDimensions(dimensions.children) : null;
|
||||
if (target) {
|
||||
console.log(
|
||||
`[${id}] ${pos.y} <= ${target.bottom} = ${pos.y <= target.bottom} / ${pos.y} >= ${target.top} = ${pos.y >=
|
||||
target.top}`,
|
||||
);
|
||||
if (pos.y <= target.bottom && pos.y >= target.top) {
|
||||
const middlePoint = target.top + target.height / 2;
|
||||
const position: ImpactPosition = pos.y > middlePoint ? 'after' : 'before';
|
||||
return {
|
||||
found: true,
|
||||
node,
|
||||
position,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (children) {
|
||||
console.log(
|
||||
`[${id}] ${pos.y} <= ${children.bottom} = ${pos.y <= children.bottom} / ${pos.y} >= ${children.top} = ${pos.y >=
|
||||
children.top}`,
|
||||
);
|
||||
if (pos.y <= children.bottom && pos.y >= children.top) {
|
||||
const position: ImpactPosition = 'after';
|
||||
return { found: false, node, position };
|
||||
}
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function transformToTree(arr: any) {
|
||||
const nodes: any = {};
|
||||
return arr.filter(function(obj: any) {
|
||||
var id = obj['id'],
|
||||
parentId = obj['parent'];
|
||||
|
||||
nodes[id] = _.defaults(obj, nodes[id], { children: [] });
|
||||
parentId && (nodes[parentId] = nodes[parentId] || { children: [] })['children'].push(obj);
|
||||
|
||||
return !parentId;
|
||||
});
|
||||
}
|
||||
|
||||
export function findNode(parentID: string, nodeID: string, data: OutlineData) {
|
||||
const nodeRelations = data.relationships.get(parentID);
|
||||
if (nodeRelations) {
|
||||
const nodeDepth = data.nodes.get(nodeRelations.self.depth + 1);
|
||||
if (nodeDepth) {
|
||||
const node = nodeDepth.get(nodeID);
|
||||
return node ?? null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function findNodeDepth(published: Map<string, string>, id: string) {
|
||||
let currentID = id;
|
||||
let breaker = 0;
|
||||
let depth = 0;
|
||||
let ancestors = [id];
|
||||
while (currentID !== 'root') {
|
||||
const nextID = published.get(currentID);
|
||||
if (nextID) {
|
||||
ancestors = [nextID, ...ancestors];
|
||||
currentID = nextID;
|
||||
depth += 1;
|
||||
breaker += 1;
|
||||
if (breaker > 100) {
|
||||
throw new Error('node depth breaker was thrown');
|
||||
}
|
||||
} else {
|
||||
throw new Error('unable to find nextID');
|
||||
}
|
||||
}
|
||||
return { depth, ancestors };
|
||||
}
|
||||
|
||||
export function getNumberOfChildren(root: ItemElement, ancestors: Array<string>) {
|
||||
let currentBranch = root;
|
||||
for (let i = 1; i < ancestors.length; i++) {
|
||||
const nextBranch = currentBranch.children ? currentBranch.children.find(c => c.id === ancestors[i]) : null;
|
||||
if (nextBranch) {
|
||||
currentBranch = nextBranch;
|
||||
} else {
|
||||
throw new Error('unable to find next branch');
|
||||
}
|
||||
}
|
||||
return currentBranch.children ? currentBranch.children.length : 0;
|
||||
}
|
||||
|
||||
export function findNodeAbove(outline: OutlineData, curDepth: number, belowNode: OutlineNode) {
|
||||
let targetAboveNode: null | RelationshipChild = null;
|
||||
if (curDepth === 1) {
|
||||
const relations = outline.relationships.get(belowNode.ancestors[0]);
|
||||
if (relations) {
|
||||
const parentIndex = relations.children.findIndex(n => belowNode && n.id === belowNode.ancestors[1]);
|
||||
if (parentIndex !== -1) {
|
||||
const aboveParent = relations.children[parentIndex - 1];
|
||||
if (parentIndex === 0) {
|
||||
targetAboveNode = null;
|
||||
} else {
|
||||
targetAboveNode = getNodeAbove(belowNode, aboveParent, outline);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const relations = outline.relationships.get(belowNode.parent);
|
||||
if (relations) {
|
||||
const currentIndex = relations.children.findIndex(n => belowNode && n.id === belowNode.id);
|
||||
// is first child, so use parent
|
||||
if (currentIndex === 0) {
|
||||
const parentNodes = outline.nodes.get(belowNode.depth - 1);
|
||||
const parentNode = parentNodes ? parentNodes.get(belowNode.parent) : null;
|
||||
if (parentNode) {
|
||||
targetAboveNode = {
|
||||
id: belowNode.parent,
|
||||
depth: belowNode.depth - 1,
|
||||
position: parentNode.position,
|
||||
children: parentNode.children,
|
||||
};
|
||||
}
|
||||
} else if (currentIndex !== -1) {
|
||||
// is not first child, so first prev sibling
|
||||
const aboveParentNode = relations.children[currentIndex - 1];
|
||||
if (aboveParentNode) {
|
||||
targetAboveNode = getNodeAbove(belowNode, aboveParentNode, outline);
|
||||
if (targetAboveNode === null) {
|
||||
targetAboveNode = aboveParentNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetAboveNode) {
|
||||
const depthNodes = outline.nodes.get(targetAboveNode.depth);
|
||||
if (depthNodes) {
|
||||
return depthNodes.get(targetAboveNode.id) ?? null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getNodeOver(mouse: { x: number; y: number }, outline: OutlineData) {
|
||||
let curDepth = 1;
|
||||
let curDraggables: any;
|
||||
let curDraggable: any;
|
||||
let curPosition: ImpactPosition = 'after';
|
||||
while (outline.nodes.size + 1 > curDepth) {
|
||||
curDraggables = outline.nodes.get(curDepth);
|
||||
if (curDraggables) {
|
||||
const nextDraggable = findNextDraggable(mouse, outline, curDepth);
|
||||
if (nextDraggable) {
|
||||
curDraggable = nextDraggable.node;
|
||||
curPosition = nextDraggable.position;
|
||||
if (nextDraggable.found) {
|
||||
break;
|
||||
}
|
||||
curDepth += 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
curDepth,
|
||||
curDraggable,
|
||||
curPosition,
|
||||
};
|
||||
}
|
||||
|
||||
export function findCommonParent(outline: OutlineData, aboveNode: OutlineNode, belowNode: OutlineNode) {
|
||||
let aboveParentID = null;
|
||||
let depth = 0;
|
||||
for (let aIdx = aboveNode.ancestors.length - 1; aIdx !== 0; aIdx--) {
|
||||
depth = aIdx;
|
||||
const aboveNodeParent = aboveNode.ancestors[aIdx];
|
||||
for (let bIdx = belowNode.ancestors.length - 1; bIdx !== 0; bIdx--) {
|
||||
if (belowNode.ancestors[bIdx] === aboveNodeParent) {
|
||||
aboveParentID = aboveNodeParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aboveParentID) {
|
||||
const parent = outline.relationships.get(aboveParentID) ?? null;
|
||||
if (parent) {
|
||||
return {
|
||||
parent,
|
||||
depth,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getLastChildInBranch(outline: OutlineData, lastParentNode: OutlineNode) {
|
||||
let curParentRelation = outline.relationships.get(lastParentNode.id);
|
||||
if (!curParentRelation) {
|
||||
return { id: lastParentNode.id, depth: 1 };
|
||||
}
|
||||
let hasChildren = lastParentNode.children !== 0;
|
||||
let depth = 1;
|
||||
let finalID: null | string = null;
|
||||
while (hasChildren) {
|
||||
if (curParentRelation) {
|
||||
const lastChild = curParentRelation.children.sort((a, b) => a.position - b.position)[
|
||||
curParentRelation.children.length - 1
|
||||
];
|
||||
depth += 1;
|
||||
if (lastChild.children === 0) {
|
||||
finalID = lastChild.id;
|
||||
break;
|
||||
}
|
||||
curParentRelation = outline.relationships.get(lastChild.id);
|
||||
} else {
|
||||
hasChildren = false;
|
||||
}
|
||||
}
|
||||
if (finalID !== null) {
|
||||
return { id: finalID, depth };
|
||||
}
|
||||
return null;
|
||||
}
|
@ -5,7 +5,6 @@ import { TaskMetaFilters, TaskMeta, TaskMetaMatch, DueDateFilterType } from 'sha
|
||||
import Input from 'shared/components/ControlledInput';
|
||||
import { Popup, usePopup } from 'shared/components/PopupMenu';
|
||||
import produce from 'immer';
|
||||
import moment from 'moment';
|
||||
import { mixin } from 'shared/utils/styles';
|
||||
import Member from 'shared/components/Member';
|
||||
|
||||
|
@ -73,6 +73,11 @@ const SortPopup: React.FC<SortPopupProps> = ({ sorting, onChangeTaskSorting }) =
|
||||
>
|
||||
<ActionTitle>Task title</ActionTitle>
|
||||
</ActionItem>
|
||||
<ActionItem
|
||||
onClick={() => handleSetSorting({ type: TaskSortingType.COMPLETE, direction: TaskSortingDirection.ASC })}
|
||||
>
|
||||
<ActionTitle>Complete</ActionTitle>
|
||||
</ActionItem>
|
||||
</ActionsList>
|
||||
);
|
||||
};
|
||||
|
@ -309,7 +309,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||
task={data.findTask}
|
||||
onChecklistDrop={checklist => {
|
||||
updateTaskChecklistLocation({
|
||||
variables: { checklistID: checklist.id, position: checklist.position },
|
||||
variables: { taskChecklistID: checklist.id, position: checklist.position },
|
||||
|
||||
optimisticResponse: {
|
||||
__typename: 'Mutation',
|
||||
@ -324,20 +324,24 @@ const Details: React.FC<DetailsProps> = ({
|
||||
},
|
||||
});
|
||||
}}
|
||||
onChecklistItemDrop={(prevChecklistID, checklistID, checklistItem) => {
|
||||
onChecklistItemDrop={(prevChecklistID, taskChecklistID, checklistItem) => {
|
||||
updateTaskChecklistItemLocation({
|
||||
variables: { checklistID, checklistItemID: checklistItem.id, position: checklistItem.position },
|
||||
variables: {
|
||||
taskChecklistID,
|
||||
taskChecklistItemID: checklistItem.id,
|
||||
position: checklistItem.position,
|
||||
},
|
||||
optimisticResponse: {
|
||||
__typename: 'Mutation',
|
||||
updateTaskChecklistItemLocation: {
|
||||
__typename: 'UpdateTaskChecklistItemLocationPayload',
|
||||
prevChecklistID,
|
||||
checklistID,
|
||||
taskChecklistID,
|
||||
checklistItem: {
|
||||
__typename: 'TaskChecklistItem',
|
||||
position: checklistItem.position,
|
||||
id: checklistItem.id,
|
||||
taskChecklistID: checklistID,
|
||||
taskChecklistID,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -3,32 +3,11 @@ import updateApolloCache from 'shared/utils/cache';
|
||||
import { usePopup, Popup } from 'shared/components/PopupMenu';
|
||||
import produce from 'immer';
|
||||
import {
|
||||
useUpdateProjectMemberRoleMutation,
|
||||
useCreateProjectMemberMutation,
|
||||
useDeleteProjectMemberMutation,
|
||||
useSetTaskCompleteMutation,
|
||||
useToggleTaskLabelMutation,
|
||||
useUpdateProjectNameMutation,
|
||||
useFindProjectQuery,
|
||||
useUpdateTaskGroupNameMutation,
|
||||
useUpdateTaskNameMutation,
|
||||
useUpdateProjectLabelMutation,
|
||||
useCreateTaskMutation,
|
||||
useDeleteProjectLabelMutation,
|
||||
useDeleteTaskMutation,
|
||||
useUpdateTaskLocationMutation,
|
||||
useUpdateTaskGroupLocationMutation,
|
||||
useCreateTaskGroupMutation,
|
||||
useDeleteTaskGroupMutation,
|
||||
useUpdateTaskDescriptionMutation,
|
||||
useAssignTaskMutation,
|
||||
DeleteTaskDocument,
|
||||
FindProjectDocument,
|
||||
useCreateProjectLabelMutation,
|
||||
useUnassignTaskMutation,
|
||||
useUpdateTaskDueDateMutation,
|
||||
FindProjectQuery,
|
||||
useUsersQuery,
|
||||
} from 'shared/generated/graphql';
|
||||
import LabelManager from 'shared/components/PopupMenu/LabelManager';
|
||||
import LabelEditor from 'shared/components/PopupMenu/LabelEditor';
|
||||
|
@ -3,6 +3,7 @@ import React, { useState, useRef, useEffect, useContext } from 'react';
|
||||
import updateApolloCache from 'shared/utils/cache';
|
||||
import GlobalTopNavbar, { ProjectPopup } from 'App/TopNavbar';
|
||||
import styled from 'styled-components/macro';
|
||||
import AsyncSelect from 'react-select/async';
|
||||
import { usePopup, Popup } from 'shared/components/PopupMenu';
|
||||
import {
|
||||
useParams,
|
||||
@ -15,11 +16,12 @@ import {
|
||||
} from 'react-router-dom';
|
||||
import {
|
||||
useUpdateProjectMemberRoleMutation,
|
||||
useCreateProjectMemberMutation,
|
||||
useInviteProjectMembersMutation,
|
||||
useDeleteProjectMemberMutation,
|
||||
useToggleTaskLabelMutation,
|
||||
useUpdateProjectNameMutation,
|
||||
useFindProjectQuery,
|
||||
useDeleteInvitedProjectMemberMutation,
|
||||
useUpdateTaskNameMutation,
|
||||
useCreateTaskMutation,
|
||||
useDeleteTaskMutation,
|
||||
@ -37,12 +39,20 @@ import Input from 'shared/components/Input';
|
||||
import Member from 'shared/components/Member';
|
||||
import EmptyBoard from 'shared/components/EmptyBoard';
|
||||
import NOOP from 'shared/utils/noop';
|
||||
import { Lock, Cross } from 'shared/icons';
|
||||
import Button from 'shared/components/Button';
|
||||
import { useApolloClient } from '@apollo/react-hooks';
|
||||
import TaskAssignee from 'shared/components/TaskAssignee';
|
||||
import gql from 'graphql-tag';
|
||||
import { colourStyles } from 'shared/components/Select';
|
||||
import Board, { BoardLoading } from './Board';
|
||||
import Details from './Details';
|
||||
import LabelManagerEditor from './LabelManagerEditor';
|
||||
|
||||
const CARD_LABEL_VARIANT_STORAGE_KEY = 'card_label_variant';
|
||||
|
||||
const RFC2822_EMAIL = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
||||
|
||||
const useStateWithLocalStorage = (localStorageKey: string): [string, React.Dispatch<React.SetStateAction<string>>] => {
|
||||
const [value, setValue] = React.useState<string>(localStorage.getItem(localStorageKey) || '');
|
||||
|
||||
@ -70,29 +80,299 @@ const MemberList = styled.div`
|
||||
margin: 8px 0;
|
||||
`;
|
||||
|
||||
type InviteUserData = {
|
||||
email?: string;
|
||||
suerID?: string;
|
||||
};
|
||||
type UserManagementPopupProps = {
|
||||
projectID: string;
|
||||
users: Array<User>;
|
||||
projectMembers: Array<TaskUser>;
|
||||
onAddProjectMember: (userID: string) => void;
|
||||
onInviteProjectMembers: (data: Array<InviteUserData>) => void;
|
||||
};
|
||||
|
||||
const UserManagementPopup: React.FC<UserManagementPopupProps> = ({ users, projectMembers, onAddProjectMember }) => {
|
||||
const VisibiltyPrivateIcon = styled(Lock)`
|
||||
padding-right: 4px;
|
||||
`;
|
||||
|
||||
const VisibiltyButtonText = styled.span`
|
||||
color: rgba(${props => props.theme.colors.text.primary});
|
||||
`;
|
||||
|
||||
const ShareActions = styled.div`
|
||||
border-top: 1px solid #414561;
|
||||
margin-top: 8px;
|
||||
padding-top: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
`;
|
||||
|
||||
const VisibiltyButton = styled.button`
|
||||
cursor: pointer;
|
||||
margin: 2px 4px;
|
||||
padding: 2px 4px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-bottom: 1px solid transparent;
|
||||
&:hover ${VisibiltyButtonText} {
|
||||
color: rgba(${props => props.theme.colors.text.secondary});
|
||||
}
|
||||
&:hover ${VisibiltyPrivateIcon} {
|
||||
fill: rgba(${props => props.theme.colors.text.secondary});
|
||||
stroke: rgba(${props => props.theme.colors.text.secondary});
|
||||
}
|
||||
&:hover {
|
||||
border-bottom: 1px solid rgba(${props => props.theme.colors.primary});
|
||||
}
|
||||
`;
|
||||
|
||||
type MemberFilterOptions = {
|
||||
projectID?: null | string;
|
||||
teamID?: null | string;
|
||||
organization?: boolean;
|
||||
};
|
||||
|
||||
const fetchMembers = async (client: any, projectID: string, options: MemberFilterOptions, input: string, cb: any) => {
|
||||
console.log(input.trim().length < 3);
|
||||
if (input && input.trim().length < 3) {
|
||||
return [];
|
||||
}
|
||||
const res = await client.query({
|
||||
query: gql`
|
||||
query {
|
||||
searchMembers(input: {searchFilter:"${input}", projectID:"${projectID}"}) {
|
||||
id
|
||||
similarity
|
||||
status
|
||||
user {
|
||||
id
|
||||
fullName
|
||||
email
|
||||
profileIcon {
|
||||
url
|
||||
initials
|
||||
bgColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
});
|
||||
|
||||
let results: any = [];
|
||||
const emails: Array<string> = [];
|
||||
console.log(res.data && res.data.searchMembers);
|
||||
if (res.data && res.data.searchMembers) {
|
||||
results = [
|
||||
...res.data.searchMembers.map((m: any) => {
|
||||
if (m.status === 'INVITED') {
|
||||
console.log(`${m.id} is added`);
|
||||
return {
|
||||
label: m.id,
|
||||
value: {
|
||||
id: m.id,
|
||||
type: 2,
|
||||
profileIcon: {
|
||||
bgColor: '#ccc',
|
||||
initials: m.id.charAt(0),
|
||||
},
|
||||
},
|
||||
};
|
||||
} else {
|
||||
console.log(`${m.user.email} is added`);
|
||||
emails.push(m.user.email);
|
||||
return {
|
||||
label: m.user.fullName,
|
||||
value: { id: m.user.id, type: 0, profileIcon: m.user.profileIcon },
|
||||
};
|
||||
}
|
||||
}),
|
||||
];
|
||||
console.log(results);
|
||||
}
|
||||
|
||||
if (RFC2822_EMAIL.test(input) && !emails.find(e => e === input)) {
|
||||
results = [
|
||||
...results,
|
||||
{
|
||||
label: input,
|
||||
value: {
|
||||
id: input,
|
||||
type: 1,
|
||||
profileIcon: {
|
||||
bgColor: '#ccc',
|
||||
initials: input.charAt(0),
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
type UserOptionProps = {
|
||||
innerProps: any;
|
||||
isDisabled: boolean;
|
||||
isFocused: boolean;
|
||||
label: string;
|
||||
data: any;
|
||||
getValue: any;
|
||||
};
|
||||
|
||||
const OptionWrapper = styled.div<{ isFocused: boolean }>`
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
${props => props.isFocused && `background: rgba(${props.theme.colors.primary});`}
|
||||
display: flex;
|
||||
align-items: center;
|
||||
`;
|
||||
const OptionContent = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-left: 12px;
|
||||
`;
|
||||
|
||||
const OptionLabel = styled.span<{ fontSize: number; quiet: boolean }>`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: ${p => p.fontSize}px;
|
||||
color: rgba(${p => (p.quiet ? p.theme.colors.text.primary : p.theme.colors.text.primary)});
|
||||
`;
|
||||
|
||||
const UserOption: React.FC<UserOptionProps> = ({ isDisabled, isFocused, innerProps, label, data }) => {
|
||||
console.log(data);
|
||||
return !isDisabled ? (
|
||||
<OptionWrapper {...innerProps} isFocused={isFocused}>
|
||||
<TaskAssignee
|
||||
size={32}
|
||||
member={{
|
||||
id: '',
|
||||
fullName: data.value.label,
|
||||
profileIcon: data.value.profileIcon,
|
||||
}}
|
||||
/>
|
||||
<OptionContent>
|
||||
<OptionLabel fontSize={16} quiet={false}>
|
||||
{label}
|
||||
</OptionLabel>
|
||||
{data.value.type === 2 && (
|
||||
<OptionLabel fontSize={14} quiet>
|
||||
Joined
|
||||
</OptionLabel>
|
||||
)}
|
||||
</OptionContent>
|
||||
</OptionWrapper>
|
||||
) : null;
|
||||
};
|
||||
|
||||
const OptionValueWrapper = styled.div`
|
||||
background: rgba(${props => props.theme.colors.bg.primary});
|
||||
border-radius: 4px;
|
||||
margin: 2px;
|
||||
padding: 3px 6px 3px 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
const OptionValueLabel = styled.span`
|
||||
font-size: 12px;
|
||||
color: rgba(${props => props.theme.colors.text.secondary});
|
||||
`;
|
||||
|
||||
const OptionValueRemove = styled.button`
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
margin-left: 4px;
|
||||
`;
|
||||
const OptionValue = ({ data, removeProps }: any) => {
|
||||
return (
|
||||
<OptionValueWrapper>
|
||||
<OptionValueLabel>{data.label}</OptionValueLabel>
|
||||
<OptionValueRemove {...removeProps}>
|
||||
<Cross width={14} height={14} />
|
||||
</OptionValueRemove>
|
||||
</OptionValueWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
const InviteButton = styled(Button)`
|
||||
margin-top: 12px;
|
||||
height: 32px;
|
||||
padding: 4px 12px;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
`;
|
||||
|
||||
const InviteContainer = styled.div`
|
||||
min-height: 300px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
`;
|
||||
|
||||
const UserManagementPopup: React.FC<UserManagementPopupProps> = ({
|
||||
projectID,
|
||||
users,
|
||||
projectMembers,
|
||||
onInviteProjectMembers,
|
||||
}) => {
|
||||
const client = useApolloClient();
|
||||
const [invitedUsers, setInvitedUsers] = useState<Array<any> | null>(null);
|
||||
return (
|
||||
<Popup tab={0} title="Invite a user">
|
||||
<SearchInput width="100%" variant="alternate" placeholder="Email address or name" name="search" />
|
||||
<MemberList>
|
||||
{users
|
||||
.filter(u => u.id !== projectMembers.find(p => p.id === u.id)?.id)
|
||||
.map(user => (
|
||||
<UserMember
|
||||
key={user.id}
|
||||
onCardMemberClick={() => onAddProjectMember(user.id)}
|
||||
showName
|
||||
member={user}
|
||||
taskID=""
|
||||
/>
|
||||
))}
|
||||
</MemberList>
|
||||
<InviteContainer>
|
||||
<AsyncSelect
|
||||
getOptionValue={option => option.value.id}
|
||||
placeholder="Email address or username"
|
||||
noOptionsMessage={() => null}
|
||||
onChange={(e: any) => {
|
||||
setInvitedUsers(e);
|
||||
}}
|
||||
isMulti
|
||||
autoFocus
|
||||
cacheOptions
|
||||
styles={colourStyles}
|
||||
defaultOption
|
||||
components={{
|
||||
MultiValue: OptionValue,
|
||||
Option: UserOption,
|
||||
IndicatorSeparator: null,
|
||||
DropdownIndicator: null,
|
||||
}}
|
||||
loadOptions={(i, cb) => fetchMembers(client, projectID, {}, i, cb)}
|
||||
/>
|
||||
</InviteContainer>
|
||||
<InviteButton
|
||||
onClick={() => {
|
||||
if (invitedUsers) {
|
||||
onInviteProjectMembers(
|
||||
invitedUsers.map(user => {
|
||||
if (user.value.type === 0) {
|
||||
return {
|
||||
userID: user.value.id,
|
||||
};
|
||||
}
|
||||
return {
|
||||
email: user.value.id,
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
}}
|
||||
disabled={invitedUsers === null}
|
||||
hoverVariant="none"
|
||||
fontSize="16px"
|
||||
>
|
||||
Send Invite
|
||||
</InviteButton>
|
||||
</Popup>
|
||||
);
|
||||
};
|
||||
@ -135,11 +415,30 @@ const Project = () => {
|
||||
const [value, setValue] = useStateWithLocalStorage(CARD_LABEL_VARIANT_STORAGE_KEY);
|
||||
const [updateProjectMemberRole] = useUpdateProjectMemberRoleMutation();
|
||||
|
||||
const [deleteTask] = useDeleteTaskMutation();
|
||||
const [deleteTask] = useDeleteTaskMutation({
|
||||
update: (client, resp) =>
|
||||
updateApolloCache<FindProjectQuery>(
|
||||
client,
|
||||
FindProjectDocument,
|
||||
cache =>
|
||||
produce(cache, draftCache => {
|
||||
const taskGroupIdx = draftCache.findProject.taskGroups.findIndex(
|
||||
tg => tg.tasks.findIndex(t => t.id === resp.data.deleteTask.taskID) !== -1,
|
||||
);
|
||||
|
||||
if (taskGroupIdx !== -1) {
|
||||
draftCache.findProject.taskGroups[taskGroupIdx].tasks = cache.findProject.taskGroups[
|
||||
taskGroupIdx
|
||||
].tasks.filter(t => t.id !== resp.data.deleteTask.taskID);
|
||||
}
|
||||
}),
|
||||
{ projectID },
|
||||
),
|
||||
});
|
||||
|
||||
const [updateTaskName] = useUpdateTaskNameMutation();
|
||||
|
||||
const { loading, data } = useFindProjectQuery({
|
||||
const { loading, data, error } = useFindProjectQuery({
|
||||
variables: { projectID },
|
||||
});
|
||||
|
||||
@ -157,14 +456,36 @@ const Project = () => {
|
||||
},
|
||||
});
|
||||
|
||||
const [createProjectMember] = useCreateProjectMemberMutation({
|
||||
const [inviteProjectMembers] = useInviteProjectMembersMutation({
|
||||
update: (client, response) => {
|
||||
updateApolloCache<FindProjectQuery>(
|
||||
client,
|
||||
FindProjectDocument,
|
||||
cache =>
|
||||
produce(cache, draftCache => {
|
||||
draftCache.findProject.members.push({ ...response.data.createProjectMember.member });
|
||||
draftCache.findProject.members = [
|
||||
...cache.findProject.members,
|
||||
...response.data.inviteProjectMembers.members,
|
||||
];
|
||||
draftCache.findProject.invitedMembers = [
|
||||
...cache.findProject.invitedMembers,
|
||||
...response.data.inviteProjectMembers.invitedMembers,
|
||||
];
|
||||
}),
|
||||
{ projectID },
|
||||
);
|
||||
},
|
||||
});
|
||||
const [deleteInvitedProjectMember] = useDeleteInvitedProjectMemberMutation({
|
||||
update: (client, response) => {
|
||||
updateApolloCache<FindProjectQuery>(
|
||||
client,
|
||||
FindProjectDocument,
|
||||
cache =>
|
||||
produce(cache, draftCache => {
|
||||
draftCache.findProject.invitedMembers = cache.findProject.invitedMembers.filter(
|
||||
m => m.email !== response.data.deleteInvitedProjectMember.invitedMember.email,
|
||||
);
|
||||
}),
|
||||
{ projectID },
|
||||
);
|
||||
@ -205,6 +526,9 @@ const Project = () => {
|
||||
</>
|
||||
);
|
||||
}
|
||||
if (error) {
|
||||
history.push('/projects');
|
||||
}
|
||||
if (data) {
|
||||
labelsRef.current = data.findProject.labels;
|
||||
|
||||
@ -221,6 +545,10 @@ const Project = () => {
|
||||
deleteProjectMember({ variables: { userID, projectID } });
|
||||
hidePopup();
|
||||
}}
|
||||
onRemoveInvitedFromBoard={email => {
|
||||
deleteInvitedProjectMember({ variables: { projectID, email } });
|
||||
hidePopup();
|
||||
}}
|
||||
onSaveProjectName={projectName => {
|
||||
updateProjectName({ variables: { projectID, name: projectName } });
|
||||
}}
|
||||
@ -228,8 +556,10 @@ const Project = () => {
|
||||
showPopup(
|
||||
$target,
|
||||
<UserManagementPopup
|
||||
onAddProjectMember={userID => {
|
||||
createProjectMember({ variables: { userID, projectID } });
|
||||
projectID={projectID}
|
||||
onInviteProjectMembers={members => {
|
||||
inviteProjectMembers({ variables: { projectID, members } });
|
||||
hidePopup();
|
||||
}}
|
||||
users={data.users}
|
||||
projectMembers={data.findProject.members}
|
||||
@ -240,8 +570,9 @@ const Project = () => {
|
||||
menuType={[{ name: 'Board', link: location.pathname }]}
|
||||
currentTab={0}
|
||||
projectMembers={data.findProject.members}
|
||||
projectInvitedMembers={data.findProject.invitedMembers}
|
||||
projectID={projectID}
|
||||
teamID={data.findProject.team.id}
|
||||
teamID={data.findProject.team ? data.findProject.team.id : null}
|
||||
name={data.findProject.name}
|
||||
/>
|
||||
<Route path={`${match.path}`} exact render={() => <Redirect to={`${match.url}/board`} />} />
|
||||
@ -284,6 +615,7 @@ const Project = () => {
|
||||
}}
|
||||
onDeleteTask={deletedTask => {
|
||||
deleteTask({ variables: { taskID: deletedTask.id } });
|
||||
history.push(`${match.url}/board`);
|
||||
}}
|
||||
onOpenAddLabelPopup={(task, $targetRef) => {
|
||||
taskLabelsRef.current = task.labels;
|
||||
|
@ -21,33 +21,6 @@ import updateApolloCache from 'shared/utils/cache';
|
||||
import produce from 'immer';
|
||||
import NOOP from 'shared/utils/noop';
|
||||
|
||||
const EmptyStateContent = styled.div`
|
||||
display: flex;
|
||||
justy-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
`;
|
||||
|
||||
const EmptyStateTitle = styled.h3`
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
`;
|
||||
|
||||
const EmptyStatePrompt = styled.span`
|
||||
color: rgba(${props => props.theme.colors.text.primary});
|
||||
font-size: 16px;
|
||||
margin-top: 8px;
|
||||
`;
|
||||
|
||||
const EmptyState = styled(Empty)`
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
`;
|
||||
|
||||
const CreateTeamButton = styled(Button)`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
type CreateTeamData = { teamName: string };
|
||||
|
||||
type CreateTeamFormProps = {
|
||||
@ -56,6 +29,10 @@ type CreateTeamFormProps = {
|
||||
|
||||
const CreateTeamFormContainer = styled.form``;
|
||||
|
||||
const CreateTeamButton = styled(Button)`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
const CreateTeamForm: React.FC<CreateTeamFormProps> = ({ onCreateTeam }) => {
|
||||
const { register, handleSubmit } = useForm<CreateTeamData>();
|
||||
const createTeam = (data: CreateTeamData) => {
|
||||
@ -209,13 +186,6 @@ const ProjectsContainer = styled.div`
|
||||
min-width: 288px;
|
||||
`;
|
||||
|
||||
const ProjectGrid = styled.div`
|
||||
max-width: 780px;
|
||||
display: grid;
|
||||
grid-template-columns: 240px 240px 240px;
|
||||
gap: 20px 10px;
|
||||
`;
|
||||
|
||||
const AddTeamButton = styled(Button)`
|
||||
padding: 6px 12px;
|
||||
position: absolute;
|
||||
@ -223,10 +193,6 @@ const AddTeamButton = styled(Button)`
|
||||
right: 12px;
|
||||
`;
|
||||
|
||||
const CreateFirstTeam = styled(Button)`
|
||||
margin-top: 8px;
|
||||
`;
|
||||
|
||||
type ShowNewProject = {
|
||||
open: boolean;
|
||||
initialTeamID: null | string;
|
||||
@ -267,6 +233,13 @@ const Projects = () => {
|
||||
if (data && user) {
|
||||
const { projects, teams, organizations } = data;
|
||||
const organizationID = organizations[0].id ?? null;
|
||||
const personalProjects = projects
|
||||
.filter(p => p.team === null)
|
||||
.sort((a, b) => {
|
||||
const textA = a.name.toUpperCase();
|
||||
const textB = b.name.toUpperCase();
|
||||
return textA < textB ? -1 : textA > textB ? 1 : 0; // eslint-disable-line no-nested-ternary
|
||||
});
|
||||
const projectTeams = teams
|
||||
.sort((a, b) => {
|
||||
const textA = a.name.toUpperCase();
|
||||
@ -278,7 +251,7 @@ const Projects = () => {
|
||||
id: team.id,
|
||||
name: team.name,
|
||||
projects: projects
|
||||
.filter(project => project.team.id === team.id)
|
||||
.filter(project => project.team && project.team.id === team.id)
|
||||
.sort((a, b) => {
|
||||
const textA = a.name.toUpperCase();
|
||||
const textB = b.name.toUpperCase();
|
||||
@ -319,39 +292,35 @@ const Projects = () => {
|
||||
Add Team
|
||||
</AddTeamButton>
|
||||
)}
|
||||
{projectTeams.length === 0 && (
|
||||
<EmptyStateContent>
|
||||
<EmptyState width={425} height={425} />
|
||||
<EmptyStateTitle>No teams exist</EmptyStateTitle>
|
||||
<EmptyStatePrompt>Create a new team to get started</EmptyStatePrompt>
|
||||
<CreateFirstTeam
|
||||
variant="outline"
|
||||
onClick={$target => {
|
||||
showPopup(
|
||||
$target,
|
||||
<Popup
|
||||
title="Create team"
|
||||
tab={0}
|
||||
onClose={() => {
|
||||
hidePopup();
|
||||
}}
|
||||
>
|
||||
<CreateTeamForm
|
||||
onCreateTeam={teamName => {
|
||||
if (organizationID) {
|
||||
createTeam({ variables: { name: teamName, organizationID } });
|
||||
hidePopup();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Popup>,
|
||||
);
|
||||
}}
|
||||
>
|
||||
Create new team
|
||||
</CreateFirstTeam>
|
||||
</EmptyStateContent>
|
||||
)}
|
||||
<div>
|
||||
<ProjectSectionTitleWrapper>
|
||||
<ProjectSectionTitle>Personal Projects</ProjectSectionTitle>
|
||||
</ProjectSectionTitleWrapper>
|
||||
<ProjectList>
|
||||
{personalProjects.map((project, idx) => (
|
||||
<ProjectListItem key={project.id}>
|
||||
<ProjectTile color={colors[idx % 5]} to={`/projects/${project.id}`}>
|
||||
<ProjectTileFade />
|
||||
<ProjectTileDetails>
|
||||
<ProjectTileName>{project.name}</ProjectTileName>
|
||||
</ProjectTileDetails>
|
||||
</ProjectTile>
|
||||
</ProjectListItem>
|
||||
))}
|
||||
<ProjectListItem>
|
||||
<ProjectAddTile
|
||||
onClick={() => {
|
||||
setShowNewProject({ open: true, initialTeamID: 'no-team' });
|
||||
}}
|
||||
>
|
||||
<ProjectTileFade />
|
||||
<ProjectAddTileDetails>
|
||||
<ProjectTileName centered>Create new project</ProjectTileName>
|
||||
</ProjectAddTileDetails>
|
||||
</ProjectAddTile>
|
||||
</ProjectListItem>
|
||||
</ProjectList>
|
||||
</div>
|
||||
{projectTeams.map(team => {
|
||||
return (
|
||||
<div key={team.id}>
|
||||
@ -405,7 +374,7 @@ const Projects = () => {
|
||||
initialTeamID={showNewProject.initialTeamID}
|
||||
onCreateProject={(name, teamID) => {
|
||||
if (user) {
|
||||
createProject({ variables: { teamID, name, userID: user.id } });
|
||||
createProject({ variables: { teamID, name } });
|
||||
setShowNewProject({ open: false, initialTeamID: null });
|
||||
}
|
||||
}}
|
||||
|
@ -8,15 +8,28 @@ import { HttpLink } from 'apollo-link-http';
|
||||
import { onError } from 'apollo-link-error';
|
||||
import { enableMapSet } from 'immer';
|
||||
import { ApolloLink, Observable, fromPromise } from 'apollo-link';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
import updateLocale from 'dayjs/plugin/updateLocale';
|
||||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||
import isBetween from 'dayjs/plugin/isBetween';
|
||||
import weekday from 'dayjs/plugin/weekday';
|
||||
import { getAccessToken, getNewToken, setAccessToken } from 'shared/utils/accessToken';
|
||||
import cache from './App/cache';
|
||||
import App from './App';
|
||||
|
||||
// https://able.bio/AnasT/apollo-graphql-async-access-token-refresh--470t1c8
|
||||
|
||||
dayjs.extend(isSameOrAfter);
|
||||
|
||||
dayjs.extend(weekday);
|
||||
dayjs.extend(isBetween);
|
||||
dayjs.extend(customParseFormat);
|
||||
enableMapSet();
|
||||
|
||||
moment.updateLocale('en', {
|
||||
dayjs.extend(updateLocale);
|
||||
|
||||
dayjs.updateLocale('en', {
|
||||
week: {
|
||||
dow: 1, // First day of week is Monday
|
||||
doy: 7, // First week of year must contain 1 January (7 + 1 - 1)
|
||||
|
0
frontend/src/outline.d.ts
vendored
Normal file
0
frontend/src/outline.d.ts
vendored
Normal file
@ -51,7 +51,9 @@ export const Default = () => {
|
||||
},
|
||||
},
|
||||
]}
|
||||
invitedUsers={[]}
|
||||
onAddUser={action('add user')}
|
||||
onDeleteInvitedUser={action('delete invited user')}
|
||||
/>
|
||||
</ThemeProvider>
|
||||
</>
|
||||
|
@ -104,8 +104,8 @@ type TeamRoleManagerPopupProps = {
|
||||
user: User;
|
||||
users: Array<User>;
|
||||
warning?: string | null;
|
||||
canChangeRole: boolean;
|
||||
onChangeRole: (roleCode: RoleCode) => void;
|
||||
canChangeRole?: boolean;
|
||||
onChangeRole?: (roleCode: RoleCode) => void;
|
||||
updateUserPassword?: (user: TaskUser, password: string) => void;
|
||||
onDeleteUser?: (userID: string, newOwnerID: string | null) => void;
|
||||
};
|
||||
@ -530,8 +530,10 @@ type AdminProps = {
|
||||
onDeleteUser: (userID: string, newOwnerID: string | null) => void;
|
||||
onInviteUser: ($target: React.RefObject<HTMLElement>) => void;
|
||||
users: Array<User>;
|
||||
invitedUsers: Array<InvitedUserAccount>;
|
||||
canInviteUser: boolean;
|
||||
onUpdateUserPassword: (user: TaskUser, password: string) => void;
|
||||
onDeleteInvitedUser: (invitedUserID: string) => void;
|
||||
};
|
||||
|
||||
const Admin: React.FC<AdminProps> = ({
|
||||
@ -540,7 +542,9 @@ const Admin: React.FC<AdminProps> = ({
|
||||
onUpdateUserPassword,
|
||||
canInviteUser,
|
||||
onDeleteUser,
|
||||
onDeleteInvitedUser,
|
||||
onInviteUser,
|
||||
invitedUsers,
|
||||
users,
|
||||
}) => {
|
||||
const warning =
|
||||
@ -577,7 +581,7 @@ const Admin: React.FC<AdminProps> = ({
|
||||
<TabContent>
|
||||
<MemberListWrapper>
|
||||
<MemberListHeader>
|
||||
<ListTitle>{`Members (${users.length})`}</ListTitle>
|
||||
<ListTitle>{`Members (${users.length + invitedUsers.length})`}</ListTitle>
|
||||
<ListDesc>
|
||||
Organization admins can create / manage / delete all projects & teams. Members only have access to teams
|
||||
or projects they have been added to.
|
||||
@ -635,6 +639,65 @@ const Admin: React.FC<AdminProps> = ({
|
||||
</MemberListItem>
|
||||
);
|
||||
})}
|
||||
{invitedUsers.map(member => {
|
||||
return (
|
||||
<MemberListItem>
|
||||
<MemberProfile
|
||||
showRoleIcons
|
||||
size={32}
|
||||
onMemberProfile={NOOP}
|
||||
member={{
|
||||
id: member.id,
|
||||
fullName: member.email,
|
||||
profileIcon: {
|
||||
bgColor: '#fff',
|
||||
url: null,
|
||||
initials: member.email.charAt(0),
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<MemberListItemDetails>
|
||||
<MemberItemName>{member.email}</MemberItemName>
|
||||
<MemberItemUsername>Invited</MemberItemUsername>
|
||||
</MemberListItemDetails>
|
||||
<MemberItemOptions>
|
||||
<MemberItemOption
|
||||
variant="outline"
|
||||
onClick={$target => {
|
||||
showPopup(
|
||||
$target,
|
||||
<TeamRoleManagerPopup
|
||||
user={{
|
||||
id: member.id,
|
||||
fullName: member.email,
|
||||
profileIcon: {
|
||||
bgColor: '#fff',
|
||||
url: null,
|
||||
initials: member.email.charAt(0),
|
||||
},
|
||||
member: {
|
||||
teams: [],
|
||||
projects: [],
|
||||
},
|
||||
owned: {
|
||||
teams: [],
|
||||
projects: [],
|
||||
},
|
||||
}}
|
||||
users={users}
|
||||
onDeleteUser={() => {
|
||||
onDeleteInvitedUser(member.id);
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
}}
|
||||
>
|
||||
Manage
|
||||
</MemberItemOption>
|
||||
</MemberItemOptions>
|
||||
</MemberListItem>
|
||||
);
|
||||
})}
|
||||
</MemberList>
|
||||
</MemberListWrapper>
|
||||
</TabContent>
|
||||
|
@ -35,11 +35,15 @@ const Base = styled.button<{ color: string; disabled: boolean }>`
|
||||
`}
|
||||
`;
|
||||
|
||||
const Filled = styled(Base)`
|
||||
const Filled = styled(Base)<{ hoverVariant: HoverVariant }>`
|
||||
background: rgba(${props => props.theme.colors[props.color]});
|
||||
&:hover {
|
||||
box-shadow: 0 8px 25px -8px rgba(${props => props.theme.colors[props.color]});
|
||||
}
|
||||
${props =>
|
||||
props.hoverVariant === 'boxShadow' &&
|
||||
css`
|
||||
&:hover {
|
||||
box-shadow: 0 8px 25px -8px rgba(${props.theme.colors[props.color]});
|
||||
}
|
||||
`}
|
||||
`;
|
||||
const Outline = styled(Base)<{ invert: boolean }>`
|
||||
border: 1px solid rgba(${props => props.theme.colors[props.color]});
|
||||
@ -123,9 +127,11 @@ const Relief = styled(Base)`
|
||||
}
|
||||
`;
|
||||
|
||||
type HoverVariant = 'boxShadow' | 'none';
|
||||
type ButtonProps = {
|
||||
fontSize?: string;
|
||||
variant?: 'filled' | 'outline' | 'flat' | 'lineDown' | 'gradient' | 'relief';
|
||||
hoverVariant?: HoverVariant;
|
||||
color?: 'primary' | 'danger' | 'success' | 'warning' | 'dark';
|
||||
disabled?: boolean;
|
||||
type?: 'button' | 'submit';
|
||||
@ -142,6 +148,7 @@ const Button: React.FC<ButtonProps> = ({
|
||||
invert = false,
|
||||
color = 'primary',
|
||||
variant = 'filled',
|
||||
hoverVariant = 'boxShadow',
|
||||
type = 'button',
|
||||
justifyTextContent = 'center',
|
||||
icon,
|
||||
@ -158,7 +165,15 @@ const Button: React.FC<ButtonProps> = ({
|
||||
switch (variant) {
|
||||
case 'filled':
|
||||
return (
|
||||
<Filled ref={$button} type={type} onClick={handleClick} className={className} disabled={disabled} color={color}>
|
||||
<Filled
|
||||
ref={$button}
|
||||
hoverVariant={hoverVariant}
|
||||
type={type}
|
||||
onClick={handleClick}
|
||||
className={className}
|
||||
disabled={disabled}
|
||||
color={color}
|
||||
>
|
||||
{icon && icon}
|
||||
<Text hasIcon={typeof icon !== 'undefined'} justifyTextContent={justifyTextContent} fontSize={fontSize}>
|
||||
{children}
|
||||
|
@ -26,10 +26,9 @@ const CardComposer = ({ isOpen, onCreateCard, onClose }: Props) => {
|
||||
useOnOutsideClick($cardRef, true, onClose, null);
|
||||
useOnEscapeKeyDown(isOpen, onClose);
|
||||
return (
|
||||
<CardComposerWrapper isOpen={isOpen}>
|
||||
<CardComposerWrapper isOpen={isOpen} ref={$cardRef}>
|
||||
<Card
|
||||
title={cardName}
|
||||
ref={$cardRef}
|
||||
taskID=""
|
||||
taskGroupID=""
|
||||
editable
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect, forwardRef } from 'react';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
import styled from 'styled-components';
|
||||
import DatePicker from 'react-datepicker';
|
||||
import _ from 'lodash';
|
||||
@ -110,12 +110,12 @@ const HeaderActions = styled.div`
|
||||
`;
|
||||
|
||||
const DueDateManager: React.FC<DueDateManagerProps> = ({ task, onDueDateChange, onRemoveDueDate, onCancel }) => {
|
||||
const now = moment();
|
||||
const now = dayjs();
|
||||
const { register, handleSubmit, errors, setValue, setError, formState, control } = useForm<DueDateFormData>();
|
||||
const [startDate, setStartDate] = useState(new Date());
|
||||
|
||||
useEffect(() => {
|
||||
const newDate = moment(startDate).format('YYYY-MM-DD');
|
||||
const newDate = dayjs(startDate).format('YYYY-MM-DD');
|
||||
setValue('endDate', newDate);
|
||||
}, [startDate]);
|
||||
|
||||
@ -135,7 +135,7 @@ const DueDateManager: React.FC<DueDateManagerProps> = ({ task, onDueDateChange,
|
||||
'December',
|
||||
];
|
||||
const saveDueDate = (data: any) => {
|
||||
const newDate = moment(`${data.endDate} ${moment(data.endTime).format('h:mm A')}`, 'YYYY-MM-DD h:mm A');
|
||||
const newDate = dayjs(`${data.endDate} ${dayjs(data.endTime).format('h:mm A')}`, 'YYYY-MM-DD h:mm A');
|
||||
if (newDate.isValid()) {
|
||||
onDueDateChange(task, newDate.toDate());
|
||||
}
|
||||
|
@ -73,7 +73,6 @@ export const HeaderName = styled(TextareaAutosize)`
|
||||
box-shadow: none;
|
||||
font-weight: 600;
|
||||
margin: -4px 0;
|
||||
padding: 4px 8px;
|
||||
|
||||
letter-spacing: normal;
|
||||
word-spacing: normal;
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
getNewDraggablePosition,
|
||||
getAfterDropDraggableList,
|
||||
} from 'shared/utils/draggables';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
import { TaskSorting, TaskSortingType, TaskSortingDirection, sortTasks } from 'shared/utils/sorting';
|
||||
|
||||
import { Container, BoardContainer, BoardWrapper } from './Styles';
|
||||
@ -51,7 +51,7 @@ export type TaskStatusFilter = {
|
||||
|
||||
export interface TaskMetaFilterName {
|
||||
meta: TaskMeta;
|
||||
value?: string | moment.Moment | null;
|
||||
value?: string | dayjs.Dayjs | null;
|
||||
id?: string | null;
|
||||
}
|
||||
|
||||
@ -104,30 +104,30 @@ function shouldStatusFilter(task: Task, filter: TaskStatusFilter) {
|
||||
return true;
|
||||
}
|
||||
if (filter.status === TaskStatus.COMPLETE && task.completedAt && task.complete === true) {
|
||||
const completedAt = moment(task.completedAt);
|
||||
const REFERENCE = moment(); // fixed just for testing, use moment();
|
||||
const completedAt = dayjs(task.completedAt);
|
||||
const REFERENCE = dayjs();
|
||||
switch (filter.since) {
|
||||
case TaskSince.TODAY:
|
||||
const TODAY = REFERENCE.clone().startOf('day');
|
||||
return completedAt.isSame(TODAY, 'd');
|
||||
case TaskSince.YESTERDAY:
|
||||
const YESTERDAY = REFERENCE.clone()
|
||||
.subtract(1, 'days')
|
||||
.subtract(1, 'day')
|
||||
.startOf('day');
|
||||
return completedAt.isSameOrAfter(YESTERDAY, 'd');
|
||||
case TaskSince.ONE_WEEK:
|
||||
const ONE_WEEK = REFERENCE.clone()
|
||||
.subtract(7, 'days')
|
||||
.subtract(7, 'day')
|
||||
.startOf('day');
|
||||
return completedAt.isSameOrAfter(ONE_WEEK, 'd');
|
||||
case TaskSince.TWO_WEEKS:
|
||||
const TWO_WEEKS = REFERENCE.clone()
|
||||
.subtract(14, 'days')
|
||||
.subtract(14, 'day')
|
||||
.startOf('day');
|
||||
return completedAt.isSameOrAfter(TWO_WEEKS, 'd');
|
||||
case TaskSince.THREE_WEEKS:
|
||||
const THREE_WEEKS = REFERENCE.clone()
|
||||
.subtract(21, 'days')
|
||||
.subtract(21, 'day')
|
||||
.startOf('day');
|
||||
return completedAt.isSameOrAfter(THREE_WEEKS, 'd');
|
||||
default:
|
||||
@ -353,7 +353,7 @@ const SimpleLists: React.FC<SimpleProps> = ({
|
||||
task.dueDate
|
||||
? {
|
||||
isPastDue: false,
|
||||
formattedDate: moment(task.dueDate).format('MMM D, YYYY'),
|
||||
formattedDate: dayjs(task.dueDate).format('MMM D, YYYY'),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { TaskMetaFilters, DueDateFilterType } from 'shared/components/Lists';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
enum ShouldFilter {
|
||||
NO_FILTER,
|
||||
@ -24,8 +24,8 @@ export default function shouldMetaFilter(task: Task, filters: TaskMetaFilters) {
|
||||
isFiltered = shouldFilter(!(task.dueDate && task.dueDate !== null));
|
||||
}
|
||||
if (task.dueDate) {
|
||||
const taskDueDate = moment(task.dueDate);
|
||||
const today = moment();
|
||||
const taskDueDate = dayjs(task.dueDate);
|
||||
const today = dayjs();
|
||||
let start;
|
||||
let end;
|
||||
switch (filters.dueDate.type) {
|
||||
@ -40,7 +40,7 @@ export default function shouldMetaFilter(task: Task, filters: TaskMetaFilters) {
|
||||
taskDueDate.isBefore(
|
||||
today
|
||||
.clone()
|
||||
.add(1, 'days')
|
||||
.add(1, 'day')
|
||||
.endOf('day'),
|
||||
),
|
||||
);
|
||||
@ -60,12 +60,12 @@ export default function shouldMetaFilter(task: Task, filters: TaskMetaFilters) {
|
||||
start = today
|
||||
.clone()
|
||||
.weekday(0)
|
||||
.add(7, 'days')
|
||||
.add(7, 'day')
|
||||
.startOf('day');
|
||||
end = today
|
||||
.clone()
|
||||
.weekday(6)
|
||||
.add(7, 'days')
|
||||
.add(7, 'day')
|
||||
.endOf('day');
|
||||
isFiltered = shouldFilter(taskDueDate.isBetween(start, end));
|
||||
break;
|
||||
@ -73,7 +73,7 @@ export default function shouldMetaFilter(task: Task, filters: TaskMetaFilters) {
|
||||
start = today.clone().startOf('day');
|
||||
end = today
|
||||
.clone()
|
||||
.add(7, 'days')
|
||||
.add(7, 'day')
|
||||
.endOf('day');
|
||||
isFiltered = shouldFilter(taskDueDate.isBetween(start, end));
|
||||
break;
|
||||
@ -81,7 +81,7 @@ export default function shouldMetaFilter(task: Task, filters: TaskMetaFilters) {
|
||||
start = today.clone().startOf('day');
|
||||
end = today
|
||||
.clone()
|
||||
.add(14, 'days')
|
||||
.add(14, 'day')
|
||||
.endOf('day');
|
||||
isFiltered = shouldFilter(taskDueDate.isBetween(start, end));
|
||||
break;
|
||||
@ -89,7 +89,7 @@ export default function shouldMetaFilter(task: Task, filters: TaskMetaFilters) {
|
||||
start = today.clone().startOf('day');
|
||||
end = today
|
||||
.clone()
|
||||
.add(21, 'days')
|
||||
.add(21, 'day')
|
||||
.endOf('day');
|
||||
isFiltered = shouldFilter(taskDueDate.isBetween(start, end));
|
||||
break;
|
||||
|
@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import NormalizeStyles from 'App/NormalizeStyles';
|
||||
import BaseStyles from 'App/BaseStyles';
|
||||
import LoadingSpinner from '.';
|
||||
|
||||
export default {
|
||||
component: LoadingSpinner,
|
||||
title: 'Login',
|
||||
parameters: {
|
||||
backgrounds: [
|
||||
{ name: 'white', value: '#ffffff' },
|
||||
{ name: 'gray', value: '#cdd3e1', default: true },
|
||||
],
|
||||
},
|
||||
};
|
||||
export const Default = () => {
|
||||
return (
|
||||
<>
|
||||
<NormalizeStyles />
|
||||
<BaseStyles />
|
||||
<LoadingSpinner />
|
||||
</>
|
||||
);
|
||||
};
|
42
frontend/src/shared/components/LoadingSpinner/Styles.ts
Normal file
42
frontend/src/shared/components/LoadingSpinner/Styles.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import styled, { keyframes } from 'styled-components';
|
||||
|
||||
const LoadingSpinnerKeyframes = keyframes`
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
`;
|
||||
|
||||
export const LoadingSpinnerWrapper = styled.div<{ color: string; size: string; borderSize: string; thickness: string }>`
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: ${props => props.borderSize};
|
||||
height: ${props => props.borderSize};
|
||||
|
||||
& > div {
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: ${props => props.size};
|
||||
height: ${props => props.size};
|
||||
margin: ${props => props.thickness};
|
||||
border: ${props => props.thickness} solid rgba(${props => props.theme.colors[props.color]});
|
||||
border-radius: 50%;
|
||||
animation: 1.2s ${LoadingSpinnerKeyframes} cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
||||
border-color: rgba(${props => props.theme.colors[props.color]}) transparent transparent transparent;
|
||||
}
|
||||
|
||||
& > div:nth-child(1) {
|
||||
animation-delay: -0.45s;
|
||||
}
|
||||
& > div:nth-child(2) {
|
||||
animation-delay: -0.3s;
|
||||
}
|
||||
& > div:nth-child(3) {
|
||||
animation-delay: -0.15s;
|
||||
}
|
||||
`;
|
||||
|
||||
export default LoadingSpinnerWrapper;
|
41
frontend/src/shared/components/LoadingSpinner/index.tsx
Normal file
41
frontend/src/shared/components/LoadingSpinner/index.tsx
Normal file
@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
|
||||
import { LoadingSpinnerWrapper} from './Styles';
|
||||
|
||||
type LoadingSpinnerProps = {
|
||||
color?: 'primary' | 'danger' | 'success' | 'warning' | 'dark';
|
||||
size?: string;
|
||||
borderSize?: string;
|
||||
thickness?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The default parameters may not be applicable to every scenario
|
||||
*
|
||||
* While borderSize and size should be a single prop,
|
||||
* it is currently not as such because it would require math to be done to strings
|
||||
* e.g "80px - 16"
|
||||
*
|
||||
*
|
||||
* @param color
|
||||
* @param size The size of the spinner. It is recommended to be at least 16 px less than the borderSize
|
||||
* @param thickness
|
||||
* @param borderSize Border size affects the size of the border which if is too small may break the spinner.
|
||||
* @constructor
|
||||
*/
|
||||
const LoadingSpinner: React.FC<LoadingSpinnerProps> = ({
|
||||
color = 'primary',
|
||||
size = '64px',
|
||||
thickness = '8px',
|
||||
borderSize = '80px',
|
||||
}) => {
|
||||
return (
|
||||
<LoadingSpinnerWrapper color={color} size={size} thickness={thickness} borderSize={borderSize}>
|
||||
<div />
|
||||
<div />
|
||||
<div />
|
||||
</LoadingSpinnerWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default LoadingSpinner;
|
@ -3,6 +3,7 @@ import AccessAccount from 'shared/undraw/AccessAccount';
|
||||
import { User, Lock, Taskcafe } from 'shared/icons';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import LoadingSpinner from 'shared/components/LoadingSpinner';
|
||||
import {
|
||||
Form,
|
||||
LogoWrapper,
|
||||
@ -73,6 +74,7 @@ const Login = ({ onSubmit }: LoginProps) => {
|
||||
|
||||
<ActionButtons>
|
||||
<RegisterButton variant="outline">Register</RegisterButton>
|
||||
{!isComplete && <LoadingSpinner size="32px" thickness="2px" borderSize="48px" />}
|
||||
<LoginButton type="submit" disabled={!isComplete}>
|
||||
Login
|
||||
</LoginButton>
|
||||
|
@ -47,6 +47,7 @@ const permissions = [
|
||||
type MiniProfileProps = {
|
||||
bio: string;
|
||||
user: TaskUser;
|
||||
invited?: boolean;
|
||||
onRemoveFromTask?: () => void;
|
||||
onChangeRole?: (roleCode: RoleCode) => void;
|
||||
onRemoveFromBoard?: () => void;
|
||||
@ -56,6 +57,7 @@ type MiniProfileProps = {
|
||||
const MiniProfile: React.FC<MiniProfileProps> = ({
|
||||
user,
|
||||
bio,
|
||||
invited,
|
||||
canChangeRole,
|
||||
onRemoveFromTask,
|
||||
onChangeRole,
|
||||
@ -74,7 +76,7 @@ const MiniProfile: React.FC<MiniProfileProps> = ({
|
||||
)}
|
||||
<ProfileInfo>
|
||||
<InfoTitle>{user.fullName}</InfoTitle>
|
||||
<InfoUsername>{`@${user.username}`}</InfoUsername>
|
||||
{invited ? <InfoUsername>Invited</InfoUsername> : <InfoUsername>{`@${user.username}`}</InfoUsername>}
|
||||
<InfoBio>{bio}</InfoBio>
|
||||
</ProfileInfo>
|
||||
</Profile>
|
||||
|
@ -217,13 +217,13 @@ type NewProjectProps = {
|
||||
initialTeamID: string | null;
|
||||
teams: Array<Team>;
|
||||
onClose: () => void;
|
||||
onCreateProject: (projectName: string, teamID: string) => void;
|
||||
onCreateProject: (projectName: string, teamID: string | null) => void;
|
||||
};
|
||||
|
||||
const NewProject: React.FC<NewProjectProps> = ({ initialTeamID, teams, onClose, onCreateProject }) => {
|
||||
const [projectName, setProjectName] = useState('');
|
||||
const [team, setTeam] = useState<null | string>(initialTeamID);
|
||||
const options = teams.map(t => ({ label: t.name, value: t.id }));
|
||||
const options = [{ label: 'No team', value: 'no-team' }, ...teams.map(t => ({ label: t.name, value: t.id }))];
|
||||
return (
|
||||
<Overlay>
|
||||
<Content>
|
||||
@ -271,8 +271,8 @@ const NewProject: React.FC<NewProjectProps> = ({ initialTeamID, teams, onClose,
|
||||
</ProjectInfo>
|
||||
<CreateButton
|
||||
onClick={() => {
|
||||
if (team && projectName !== '') {
|
||||
onCreateProject(projectName, team);
|
||||
if (projectName !== '') {
|
||||
onCreateProject(projectName, team === 'no-team' ? null : team);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
@ -16,7 +16,7 @@ function getBackgroundColor(isDisabled: boolean, isSelected: boolean, isFocused:
|
||||
return null;
|
||||
}
|
||||
|
||||
const colourStyles = {
|
||||
export const colourStyles = {
|
||||
control: (styles: any, data: any) => {
|
||||
return {
|
||||
...styles,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useRef } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import styled, { css } from 'styled-components';
|
||||
import { DoubleChevronUp, Crown } from 'shared/icons';
|
||||
|
||||
export const AdminIcon = styled(DoubleChevronUp)`
|
||||
@ -24,7 +24,12 @@ const TaskDetailAssignee = styled.div`
|
||||
position: relative;
|
||||
`;
|
||||
|
||||
export const Wrapper = styled.div<{ size: number | string; bgColor: string | null; backgroundURL: string | null }>`
|
||||
export const Wrapper = styled.div<{
|
||||
size: number | string;
|
||||
bgColor: string | null;
|
||||
backgroundURL: string | null;
|
||||
hasClick: boolean;
|
||||
}>`
|
||||
width: ${props => props.size}px;
|
||||
height: ${props => props.size}px;
|
||||
border-radius: 9999px;
|
||||
@ -37,33 +42,60 @@ export const Wrapper = styled.div<{ size: number | string; bgColor: string | nul
|
||||
background-size: contain;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
${props =>
|
||||
props.hasClick &&
|
||||
css`
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
`}
|
||||
`;
|
||||
|
||||
type TaskAssigneeProps = {
|
||||
size: number | string;
|
||||
showRoleIcons?: boolean;
|
||||
member: TaskUser;
|
||||
onMemberProfile: ($targetRef: React.RefObject<HTMLElement>, memberID: string) => void;
|
||||
invited?: boolean;
|
||||
onMemberProfile?: ($targetRef: React.RefObject<HTMLElement>, memberID: string) => void;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const TaskAssignee: React.FC<TaskAssigneeProps> = ({ showRoleIcons, member, onMemberProfile, size, className }) => {
|
||||
const TaskAssignee: React.FC<TaskAssigneeProps> = ({
|
||||
showRoleIcons,
|
||||
member,
|
||||
invited,
|
||||
onMemberProfile,
|
||||
size,
|
||||
className,
|
||||
}) => {
|
||||
const $memberRef = useRef<HTMLDivElement>(null);
|
||||
let profileIcon: ProfileIcon = {
|
||||
url: null,
|
||||
bgColor: null,
|
||||
initials: null,
|
||||
};
|
||||
if (member.profileIcon) {
|
||||
profileIcon = member.profileIcon;
|
||||
}
|
||||
return (
|
||||
<TaskDetailAssignee
|
||||
className={className}
|
||||
ref={$memberRef}
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
onMemberProfile($memberRef, member.id);
|
||||
if (onMemberProfile) {
|
||||
onMemberProfile($memberRef, member.id);
|
||||
}
|
||||
}}
|
||||
key={member.id}
|
||||
>
|
||||
<Wrapper backgroundURL={member.profileIcon.url ?? null} bgColor={member.profileIcon.bgColor ?? null} size={size}>
|
||||
{(!member.profileIcon.url && member.profileIcon.initials) ?? ''}
|
||||
<Wrapper
|
||||
hasClick={typeof onMemberProfile !== undefined}
|
||||
backgroundURL={profileIcon.url ?? null}
|
||||
bgColor={profileIcon.bgColor ?? null}
|
||||
size={size}
|
||||
>
|
||||
{(!profileIcon.url && profileIcon.initials) ?? ''}
|
||||
</Wrapper>
|
||||
{showRoleIcons && member.role && member.role.code === 'admin' && <AdminIcon width={10} height={10} />}
|
||||
{showRoleIcons && member.role && member.role.code === 'owner' && <OwnerIcon width={10} height={10} />}
|
||||
|
@ -17,7 +17,7 @@ import dark from 'shared/utils/editorTheme';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import Task from 'shared/icons/Task';
|
||||
import {
|
||||
@ -182,7 +182,7 @@ const TaskDetails: React.FC<TaskDetailsProps> = ({
|
||||
}}
|
||||
>
|
||||
{task.dueDate ? (
|
||||
<SidebarButtonText>{moment(task.dueDate).format('MMM D [at] h:mm A')}</SidebarButtonText>
|
||||
<SidebarButtonText>{dayjs(task.dueDate).format('MMM D [at] h:mm A')}</SidebarButtonText>
|
||||
) : (
|
||||
<SidebarButtonText>No due date</SidebarButtonText>
|
||||
)}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useRef, useState, useEffect } from 'react';
|
||||
import { Home, Star, Bell, AngleDown, BarChart, CheckCircle } from 'shared/icons';
|
||||
import { Home, Star, Bell, AngleDown, BarChart, CheckCircle, ListUnordered } from 'shared/icons';
|
||||
import styled from 'styled-components';
|
||||
import ProfileIcon from 'shared/components/ProfileIcon';
|
||||
import { usePopup } from 'shared/components/PopupMenu';
|
||||
@ -30,6 +30,7 @@ import {
|
||||
ProjectMember,
|
||||
ProjectMembers,
|
||||
} from './Styles';
|
||||
import { useHistory } from 'react-router';
|
||||
|
||||
type IconContainerProps = {
|
||||
disabled?: boolean;
|
||||
@ -173,8 +174,11 @@ type NavBarProps = {
|
||||
user: TaskUser | null;
|
||||
onOpenSettings: ($target: React.RefObject<HTMLElement>) => void;
|
||||
projectMembers?: Array<TaskUser> | null;
|
||||
projectInvitedMembers?: Array<InvitedUser> | null;
|
||||
|
||||
onRemoveFromBoard?: (userID: string) => void;
|
||||
onMemberProfile?: ($targetRef: React.RefObject<HTMLElement>, memberID: string) => void;
|
||||
onInvitedMemberProfile?: ($targetRef: React.RefObject<HTMLElement>, email: string) => void;
|
||||
};
|
||||
|
||||
const NavBar: React.FC<NavBarProps> = ({
|
||||
@ -184,10 +188,12 @@ const NavBar: React.FC<NavBarProps> = ({
|
||||
onChangeProjectOwner,
|
||||
currentTab,
|
||||
onMemberProfile,
|
||||
onInvitedMemberProfile,
|
||||
canEditProjectName = false,
|
||||
onOpenProjectFinder,
|
||||
onFavorite,
|
||||
onSetTab,
|
||||
projectInvitedMembers,
|
||||
onChangeRole,
|
||||
name,
|
||||
onRemoveFromBoard,
|
||||
@ -204,6 +210,7 @@ const NavBar: React.FC<NavBarProps> = ({
|
||||
onProfileClick($target);
|
||||
}
|
||||
};
|
||||
const history = useHistory();
|
||||
const { showPopup } = usePopup();
|
||||
return (
|
||||
<NavbarWrapper>
|
||||
@ -245,19 +252,38 @@ const NavBar: React.FC<NavBarProps> = ({
|
||||
<TaskcafeTitle>Taskcafé</TaskcafeTitle>
|
||||
</LogoContainer>
|
||||
<GlobalActions>
|
||||
{projectMembers && onMemberProfile && (
|
||||
{projectMembers && projectInvitedMembers && onMemberProfile && onInvitedMemberProfile && (
|
||||
<>
|
||||
<ProjectMembers>
|
||||
{projectMembers.map((member, idx) => (
|
||||
<ProjectMember
|
||||
showRoleIcons
|
||||
zIndex={projectMembers.length - idx}
|
||||
zIndex={projectMembers.length - idx + projectInvitedMembers.length}
|
||||
key={member.id}
|
||||
size={28}
|
||||
member={member}
|
||||
onMemberProfile={onMemberProfile}
|
||||
/>
|
||||
))}
|
||||
{projectInvitedMembers.map((member, idx) => (
|
||||
<ProjectMember
|
||||
showRoleIcons
|
||||
zIndex={projectInvitedMembers.length - idx}
|
||||
key={member.email}
|
||||
size={28}
|
||||
invited
|
||||
member={{
|
||||
id: member.email,
|
||||
fullName: member.email,
|
||||
profileIcon: {
|
||||
url: null,
|
||||
initials: member.email.charAt(0),
|
||||
bgColor: '#fff',
|
||||
},
|
||||
}}
|
||||
onMemberProfile={onInvitedMemberProfile}
|
||||
/>
|
||||
))}
|
||||
{canInviteUser && (
|
||||
<InviteButton
|
||||
onClick={$target => {
|
||||
@ -283,6 +309,9 @@ const NavBar: React.FC<NavBarProps> = ({
|
||||
<IconContainer disabled onClick={NOOP}>
|
||||
<CheckCircle width={20} height={20} />
|
||||
</IconContainer>
|
||||
<IconContainer onClick={() => history.push('/outline')}>
|
||||
<ListUnordered width={20} height={20} />
|
||||
</IconContainer>
|
||||
<IconContainer disabled onClick={onNotificationClick}>
|
||||
<Bell color="#c2c6dc" size={20} />
|
||||
</IconContainer>
|
||||
|
@ -113,6 +113,14 @@ export type UserAccount = {
|
||||
member: MemberList;
|
||||
};
|
||||
|
||||
export type InvitedUserAccount = {
|
||||
__typename?: 'InvitedUserAccount';
|
||||
id: Scalars['ID'];
|
||||
email: Scalars['String'];
|
||||
invitedOn: Scalars['Time'];
|
||||
member: MemberList;
|
||||
};
|
||||
|
||||
export type Team = {
|
||||
__typename?: 'Team';
|
||||
id: Scalars['ID'];
|
||||
@ -121,14 +129,21 @@ export type Team = {
|
||||
members: Array<Member>;
|
||||
};
|
||||
|
||||
export type InvitedMember = {
|
||||
__typename?: 'InvitedMember';
|
||||
email: Scalars['String'];
|
||||
invitedOn: Scalars['Time'];
|
||||
};
|
||||
|
||||
export type Project = {
|
||||
__typename?: 'Project';
|
||||
id: Scalars['ID'];
|
||||
createdAt: Scalars['Time'];
|
||||
name: Scalars['String'];
|
||||
team: Team;
|
||||
team?: Maybe<Team>;
|
||||
taskGroups: Array<TaskGroup>;
|
||||
members: Array<Member>;
|
||||
invitedMembers: Array<InvitedMember>;
|
||||
labels: Array<ProjectLabel>;
|
||||
};
|
||||
|
||||
@ -209,7 +224,10 @@ export enum ObjectType {
|
||||
Org = 'ORG',
|
||||
Team = 'TEAM',
|
||||
Project = 'PROJECT',
|
||||
Task = 'TASK'
|
||||
Task = 'TASK',
|
||||
TaskGroup = 'TASK_GROUP',
|
||||
TaskChecklist = 'TASK_CHECKLIST',
|
||||
TaskChecklistItem = 'TASK_CHECKLIST_ITEM'
|
||||
}
|
||||
|
||||
export type Query = {
|
||||
@ -218,11 +236,13 @@ export type Query = {
|
||||
findTask: Task;
|
||||
findTeam: Team;
|
||||
findUser: UserAccount;
|
||||
invitedUsers: Array<InvitedUserAccount>;
|
||||
labelColors: Array<LabelColor>;
|
||||
me: MePayload;
|
||||
notifications: Array<Notification>;
|
||||
organizations: Array<Organization>;
|
||||
projects: Array<Project>;
|
||||
searchMembers: Array<MemberSearchResult>;
|
||||
taskGroups: Array<TaskGroup>;
|
||||
teams: Array<Team>;
|
||||
users: Array<UserAccount>;
|
||||
@ -253,6 +273,11 @@ export type QueryProjectsArgs = {
|
||||
input?: Maybe<ProjectsFilter>;
|
||||
};
|
||||
|
||||
|
||||
export type QuerySearchMembersArgs = {
|
||||
input: MemberSearchFilter;
|
||||
};
|
||||
|
||||
export type Mutation = {
|
||||
__typename?: 'Mutation';
|
||||
addTaskLabel: Task;
|
||||
@ -260,7 +285,6 @@ export type Mutation = {
|
||||
clearProfileAvatar: UserAccount;
|
||||
createProject: Project;
|
||||
createProjectLabel: ProjectLabel;
|
||||
createProjectMember: CreateProjectMemberPayload;
|
||||
createRefreshToken: RefreshToken;
|
||||
createTask: Task;
|
||||
createTaskChecklist: TaskChecklist;
|
||||
@ -269,6 +293,8 @@ export type Mutation = {
|
||||
createTeam: Team;
|
||||
createTeamMember: CreateTeamMemberPayload;
|
||||
createUserAccount: UserAccount;
|
||||
deleteInvitedProjectMember: DeleteInvitedProjectMemberPayload;
|
||||
deleteInvitedUserAccount: DeleteInvitedUserAccountPayload;
|
||||
deleteProject: DeleteProjectPayload;
|
||||
deleteProjectLabel: ProjectLabel;
|
||||
deleteProjectMember: DeleteProjectMemberPayload;
|
||||
@ -281,6 +307,7 @@ export type Mutation = {
|
||||
deleteTeamMember: DeleteTeamMemberPayload;
|
||||
deleteUserAccount: DeleteUserAccountPayload;
|
||||
duplicateTaskGroup: DuplicateTaskGroupPayload;
|
||||
inviteProjectMembers: InviteProjectMembersPayload;
|
||||
logoutUser: Scalars['Boolean'];
|
||||
removeTaskLabel: Task;
|
||||
setTaskChecklistItemComplete: TaskChecklistItem;
|
||||
@ -330,11 +357,6 @@ export type MutationCreateProjectLabelArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateProjectMemberArgs = {
|
||||
input: CreateProjectMember;
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateRefreshTokenArgs = {
|
||||
input: NewRefreshToken;
|
||||
};
|
||||
@ -375,6 +397,16 @@ export type MutationCreateUserAccountArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type MutationDeleteInvitedProjectMemberArgs = {
|
||||
input: DeleteInvitedProjectMember;
|
||||
};
|
||||
|
||||
|
||||
export type MutationDeleteInvitedUserAccountArgs = {
|
||||
input: DeleteInvitedUserAccount;
|
||||
};
|
||||
|
||||
|
||||
export type MutationDeleteProjectArgs = {
|
||||
input: DeleteProject;
|
||||
};
|
||||
@ -435,6 +467,11 @@ export type MutationDuplicateTaskGroupArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type MutationInviteProjectMembersArgs = {
|
||||
input: InviteProjectMembers;
|
||||
};
|
||||
|
||||
|
||||
export type MutationLogoutUserArgs = {
|
||||
input: LogoutUser;
|
||||
};
|
||||
@ -588,7 +625,7 @@ export type ProjectsFilter = {
|
||||
};
|
||||
|
||||
export type FindUser = {
|
||||
userId: Scalars['String'];
|
||||
userID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type FindProject = {
|
||||
@ -640,8 +677,7 @@ export type Notification = {
|
||||
};
|
||||
|
||||
export type NewProject = {
|
||||
userID: Scalars['UUID'];
|
||||
teamID: Scalars['UUID'];
|
||||
teamID?: Maybe<Scalars['UUID']>;
|
||||
name: Scalars['String'];
|
||||
};
|
||||
|
||||
@ -686,15 +722,32 @@ export type UpdateProjectLabelColor = {
|
||||
labelColorID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type CreateProjectMember = {
|
||||
export type DeleteInvitedProjectMember = {
|
||||
projectID: Scalars['UUID'];
|
||||
userID: Scalars['UUID'];
|
||||
email: Scalars['String'];
|
||||
};
|
||||
|
||||
export type CreateProjectMemberPayload = {
|
||||
__typename?: 'CreateProjectMemberPayload';
|
||||
export type DeleteInvitedProjectMemberPayload = {
|
||||
__typename?: 'DeleteInvitedProjectMemberPayload';
|
||||
invitedMember: InvitedMember;
|
||||
};
|
||||
|
||||
export type MemberInvite = {
|
||||
userID?: Maybe<Scalars['UUID']>;
|
||||
email?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type InviteProjectMembers = {
|
||||
projectID: Scalars['UUID'];
|
||||
members: Array<MemberInvite>;
|
||||
};
|
||||
|
||||
export type InviteProjectMembersPayload = {
|
||||
__typename?: 'InviteProjectMembersPayload';
|
||||
ok: Scalars['Boolean'];
|
||||
member: Member;
|
||||
projectID: Scalars['UUID'];
|
||||
members: Array<Member>;
|
||||
invitedMembers: Array<InvitedMember>;
|
||||
};
|
||||
|
||||
export type DeleteProjectMember = {
|
||||
@ -722,7 +775,7 @@ export type UpdateProjectMemberRolePayload = {
|
||||
};
|
||||
|
||||
export type NewTask = {
|
||||
taskGroupID: Scalars['String'];
|
||||
taskGroupID: Scalars['UUID'];
|
||||
name: Scalars['String'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
@ -765,34 +818,34 @@ export type NewTaskLocation = {
|
||||
};
|
||||
|
||||
export type DeleteTaskInput = {
|
||||
taskID: Scalars['String'];
|
||||
taskID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type DeleteTaskPayload = {
|
||||
__typename?: 'DeleteTaskPayload';
|
||||
taskID: Scalars['String'];
|
||||
taskID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type UpdateTaskName = {
|
||||
taskID: Scalars['String'];
|
||||
taskID: Scalars['UUID'];
|
||||
name: Scalars['String'];
|
||||
};
|
||||
|
||||
export type UpdateTaskChecklistItemLocation = {
|
||||
checklistID: Scalars['UUID'];
|
||||
checklistItemID: Scalars['UUID'];
|
||||
taskChecklistID: Scalars['UUID'];
|
||||
taskChecklistItemID: Scalars['UUID'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
|
||||
export type UpdateTaskChecklistItemLocationPayload = {
|
||||
__typename?: 'UpdateTaskChecklistItemLocationPayload';
|
||||
checklistID: Scalars['UUID'];
|
||||
taskChecklistID: Scalars['UUID'];
|
||||
prevChecklistID: Scalars['UUID'];
|
||||
checklistItem: TaskChecklistItem;
|
||||
};
|
||||
|
||||
export type UpdateTaskChecklistLocation = {
|
||||
checklistID: Scalars['UUID'];
|
||||
taskChecklistID: Scalars['UUID'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
|
||||
@ -908,7 +961,7 @@ export type DeleteTaskGroupPayload = {
|
||||
};
|
||||
|
||||
export type NewTaskGroup = {
|
||||
projectID: Scalars['String'];
|
||||
projectID: Scalars['UUID'];
|
||||
name: Scalars['String'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
@ -919,6 +972,7 @@ export type AddTaskLabelInput = {
|
||||
};
|
||||
|
||||
export type RemoveTaskLabelInput = {
|
||||
taskID: Scalars['UUID'];
|
||||
taskLabelID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
@ -986,6 +1040,29 @@ export type UpdateTeamMemberRolePayload = {
|
||||
member: Member;
|
||||
};
|
||||
|
||||
export type DeleteInvitedUserAccount = {
|
||||
invitedUserID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type DeleteInvitedUserAccountPayload = {
|
||||
__typename?: 'DeleteInvitedUserAccountPayload';
|
||||
invitedUser: InvitedUserAccount;
|
||||
};
|
||||
|
||||
export type MemberSearchFilter = {
|
||||
SearchFilter: Scalars['String'];
|
||||
projectID?: Maybe<Scalars['UUID']>;
|
||||
};
|
||||
|
||||
export type MemberSearchResult = {
|
||||
__typename?: 'MemberSearchResult';
|
||||
similarity: Scalars['Int'];
|
||||
user: UserAccount;
|
||||
confirmed: Scalars['Boolean'];
|
||||
invited: Scalars['Boolean'];
|
||||
joined: Scalars['Boolean'];
|
||||
};
|
||||
|
||||
export type UpdateUserInfoPayload = {
|
||||
__typename?: 'UpdateUserInfoPayload';
|
||||
user: UserAccount;
|
||||
@ -1020,7 +1097,7 @@ export type UpdateUserRolePayload = {
|
||||
};
|
||||
|
||||
export type NewRefreshToken = {
|
||||
userId: Scalars['String'];
|
||||
userID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type NewUserAccount = {
|
||||
@ -1033,7 +1110,7 @@ export type NewUserAccount = {
|
||||
};
|
||||
|
||||
export type LogoutUser = {
|
||||
userID: Scalars['String'];
|
||||
userID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
export type DeleteUserAccount = {
|
||||
@ -1081,8 +1158,7 @@ export type ClearProfileAvatarMutation = (
|
||||
);
|
||||
|
||||
export type CreateProjectMutationVariables = {
|
||||
teamID: Scalars['UUID'];
|
||||
userID: Scalars['UUID'];
|
||||
teamID?: Maybe<Scalars['UUID']>;
|
||||
name: Scalars['String'];
|
||||
};
|
||||
|
||||
@ -1092,10 +1168,10 @@ export type CreateProjectMutation = (
|
||||
& { createProject: (
|
||||
{ __typename?: 'Project' }
|
||||
& Pick<Project, 'id' | 'name'>
|
||||
& { team: (
|
||||
& { team?: Maybe<(
|
||||
{ __typename?: 'Team' }
|
||||
& Pick<Team, 'id' | 'name'>
|
||||
) }
|
||||
)> }
|
||||
) }
|
||||
);
|
||||
|
||||
@ -1119,7 +1195,7 @@ export type CreateProjectLabelMutation = (
|
||||
);
|
||||
|
||||
export type CreateTaskGroupMutationVariables = {
|
||||
projectID: Scalars['String'];
|
||||
projectID: Scalars['UUID'];
|
||||
name: Scalars['String'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
@ -1147,7 +1223,7 @@ export type DeleteProjectLabelMutation = (
|
||||
);
|
||||
|
||||
export type DeleteTaskMutationVariables = {
|
||||
taskID: Scalars['String'];
|
||||
taskID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
|
||||
@ -1190,10 +1266,10 @@ export type FindProjectQuery = (
|
||||
& { findProject: (
|
||||
{ __typename?: 'Project' }
|
||||
& Pick<Project, 'name'>
|
||||
& { team: (
|
||||
& { team?: Maybe<(
|
||||
{ __typename?: 'Team' }
|
||||
& Pick<Team, 'id'>
|
||||
), members: Array<(
|
||||
)>, members: Array<(
|
||||
{ __typename?: 'Member' }
|
||||
& Pick<Member, 'id' | 'fullName' | 'username'>
|
||||
& { role: (
|
||||
@ -1203,6 +1279,9 @@ export type FindProjectQuery = (
|
||||
{ __typename?: 'ProfileIcon' }
|
||||
& Pick<ProfileIcon, 'url' | 'initials' | 'bgColor'>
|
||||
) }
|
||||
)>, invitedMembers: Array<(
|
||||
{ __typename?: 'InvitedMember' }
|
||||
& Pick<InvitedMember, 'email' | 'invitedOn'>
|
||||
)>, labels: Array<(
|
||||
{ __typename?: 'ProjectLabel' }
|
||||
& Pick<ProjectLabel, 'id' | 'createdDate' | 'name'>
|
||||
@ -1357,10 +1436,10 @@ export type GetProjectsQuery = (
|
||||
)>, projects: Array<(
|
||||
{ __typename?: 'Project' }
|
||||
& Pick<Project, 'id' | 'name'>
|
||||
& { team: (
|
||||
& { team?: Maybe<(
|
||||
{ __typename?: 'Team' }
|
||||
& Pick<Team, 'id' | 'name'>
|
||||
) }
|
||||
)> }
|
||||
)> }
|
||||
);
|
||||
|
||||
@ -1388,31 +1467,6 @@ export type MeQuery = (
|
||||
) }
|
||||
);
|
||||
|
||||
export type CreateProjectMemberMutationVariables = {
|
||||
projectID: Scalars['UUID'];
|
||||
userID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
|
||||
export type CreateProjectMemberMutation = (
|
||||
{ __typename?: 'Mutation' }
|
||||
& { createProjectMember: (
|
||||
{ __typename?: 'CreateProjectMemberPayload' }
|
||||
& Pick<CreateProjectMemberPayload, 'ok'>
|
||||
& { member: (
|
||||
{ __typename?: 'Member' }
|
||||
& Pick<Member, 'id' | 'fullName' | 'username'>
|
||||
& { profileIcon: (
|
||||
{ __typename?: 'ProfileIcon' }
|
||||
& Pick<ProfileIcon, 'url' | 'initials' | 'bgColor'>
|
||||
), role: (
|
||||
{ __typename?: 'Role' }
|
||||
& Pick<Role, 'code' | 'name'>
|
||||
) }
|
||||
) }
|
||||
) }
|
||||
);
|
||||
|
||||
export type DeleteProjectMutationVariables = {
|
||||
projectID: Scalars['UUID'];
|
||||
};
|
||||
@ -1430,6 +1484,23 @@ export type DeleteProjectMutation = (
|
||||
) }
|
||||
);
|
||||
|
||||
export type DeleteInvitedProjectMemberMutationVariables = {
|
||||
projectID: Scalars['UUID'];
|
||||
email: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type DeleteInvitedProjectMemberMutation = (
|
||||
{ __typename?: 'Mutation' }
|
||||
& { deleteInvitedProjectMember: (
|
||||
{ __typename?: 'DeleteInvitedProjectMemberPayload' }
|
||||
& { invitedMember: (
|
||||
{ __typename?: 'InvitedMember' }
|
||||
& Pick<InvitedMember, 'email'>
|
||||
) }
|
||||
) }
|
||||
);
|
||||
|
||||
export type DeleteProjectMemberMutationVariables = {
|
||||
projectID: Scalars['UUID'];
|
||||
userID: Scalars['UUID'];
|
||||
@ -1448,6 +1519,34 @@ export type DeleteProjectMemberMutation = (
|
||||
) }
|
||||
);
|
||||
|
||||
export type InviteProjectMembersMutationVariables = {
|
||||
projectID: Scalars['UUID'];
|
||||
members: Array<MemberInvite>;
|
||||
};
|
||||
|
||||
|
||||
export type InviteProjectMembersMutation = (
|
||||
{ __typename?: 'Mutation' }
|
||||
& { inviteProjectMembers: (
|
||||
{ __typename?: 'InviteProjectMembersPayload' }
|
||||
& Pick<InviteProjectMembersPayload, 'ok'>
|
||||
& { invitedMembers: Array<(
|
||||
{ __typename?: 'InvitedMember' }
|
||||
& Pick<InvitedMember, 'email' | 'invitedOn'>
|
||||
)>, members: Array<(
|
||||
{ __typename?: 'Member' }
|
||||
& Pick<Member, 'id' | 'fullName' | 'username'>
|
||||
& { profileIcon: (
|
||||
{ __typename?: 'ProfileIcon' }
|
||||
& Pick<ProfileIcon, 'url' | 'initials' | 'bgColor'>
|
||||
), role: (
|
||||
{ __typename?: 'Role' }
|
||||
& Pick<Role, 'code' | 'name'>
|
||||
) }
|
||||
)> }
|
||||
) }
|
||||
);
|
||||
|
||||
export type UpdateProjectMemberRoleMutationVariables = {
|
||||
projectID: Scalars['UUID'];
|
||||
userID: Scalars['UUID'];
|
||||
@ -1472,7 +1571,7 @@ export type UpdateProjectMemberRoleMutation = (
|
||||
);
|
||||
|
||||
export type CreateTaskMutationVariables = {
|
||||
taskGroupID: Scalars['String'];
|
||||
taskGroupID: Scalars['UUID'];
|
||||
name: Scalars['String'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
@ -1583,8 +1682,8 @@ export type SetTaskCompleteMutation = (
|
||||
);
|
||||
|
||||
export type UpdateTaskChecklistItemLocationMutationVariables = {
|
||||
checklistID: Scalars['UUID'];
|
||||
checklistItemID: Scalars['UUID'];
|
||||
taskChecklistID: Scalars['UUID'];
|
||||
taskChecklistItemID: Scalars['UUID'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
|
||||
@ -1593,7 +1692,7 @@ export type UpdateTaskChecklistItemLocationMutation = (
|
||||
{ __typename?: 'Mutation' }
|
||||
& { updateTaskChecklistItemLocation: (
|
||||
{ __typename?: 'UpdateTaskChecklistItemLocationPayload' }
|
||||
& Pick<UpdateTaskChecklistItemLocationPayload, 'checklistID' | 'prevChecklistID'>
|
||||
& Pick<UpdateTaskChecklistItemLocationPayload, 'taskChecklistID' | 'prevChecklistID'>
|
||||
& { checklistItem: (
|
||||
{ __typename?: 'TaskChecklistItem' }
|
||||
& Pick<TaskChecklistItem, 'id' | 'taskChecklistID' | 'position'>
|
||||
@ -1616,7 +1715,7 @@ export type UpdateTaskChecklistItemNameMutation = (
|
||||
);
|
||||
|
||||
export type UpdateTaskChecklistLocationMutationVariables = {
|
||||
checklistID: Scalars['UUID'];
|
||||
taskChecklistID: Scalars['UUID'];
|
||||
position: Scalars['Float'];
|
||||
};
|
||||
|
||||
@ -1833,10 +1932,10 @@ export type GetTeamQuery = (
|
||||
), projects: Array<(
|
||||
{ __typename?: 'Project' }
|
||||
& Pick<Project, 'id' | 'name'>
|
||||
& { team: (
|
||||
& { team?: Maybe<(
|
||||
{ __typename?: 'Team' }
|
||||
& Pick<Team, 'id' | 'name'>
|
||||
) }
|
||||
)> }
|
||||
)>, users: Array<(
|
||||
{ __typename?: 'UserAccount' }
|
||||
& Pick<UserAccount, 'id' | 'email' | 'fullName' | 'username'>
|
||||
@ -2072,7 +2171,7 @@ export type UpdateTaskLocationMutation = (
|
||||
);
|
||||
|
||||
export type UpdateTaskNameMutationVariables = {
|
||||
taskID: Scalars['String'];
|
||||
taskID: Scalars['UUID'];
|
||||
name: Scalars['String'];
|
||||
};
|
||||
|
||||
@ -2128,6 +2227,22 @@ export type CreateUserAccountMutation = (
|
||||
) }
|
||||
);
|
||||
|
||||
export type DeleteInvitedUserAccountMutationVariables = {
|
||||
invitedUserID: Scalars['UUID'];
|
||||
};
|
||||
|
||||
|
||||
export type DeleteInvitedUserAccountMutation = (
|
||||
{ __typename?: 'Mutation' }
|
||||
& { deleteInvitedUserAccount: (
|
||||
{ __typename?: 'DeleteInvitedUserAccountPayload' }
|
||||
& { invitedUser: (
|
||||
{ __typename?: 'InvitedUserAccount' }
|
||||
& Pick<InvitedUserAccount, 'id'>
|
||||
) }
|
||||
) }
|
||||
);
|
||||
|
||||
export type DeleteUserAccountMutationVariables = {
|
||||
userID: Scalars['UUID'];
|
||||
newOwnerID?: Maybe<Scalars['UUID']>;
|
||||
@ -2209,7 +2324,10 @@ export type UsersQueryVariables = {};
|
||||
|
||||
export type UsersQuery = (
|
||||
{ __typename?: 'Query' }
|
||||
& { users: Array<(
|
||||
& { invitedUsers: Array<(
|
||||
{ __typename?: 'InvitedUserAccount' }
|
||||
& Pick<InvitedUserAccount, 'id' | 'email' | 'invitedOn'>
|
||||
)>, users: Array<(
|
||||
{ __typename?: 'UserAccount' }
|
||||
& Pick<UserAccount, 'id' | 'email' | 'fullName' | 'username'>
|
||||
& { role: (
|
||||
@ -2361,8 +2479,8 @@ export type ClearProfileAvatarMutationHookResult = ReturnType<typeof useClearPro
|
||||
export type ClearProfileAvatarMutationResult = ApolloReactCommon.MutationResult<ClearProfileAvatarMutation>;
|
||||
export type ClearProfileAvatarMutationOptions = ApolloReactCommon.BaseMutationOptions<ClearProfileAvatarMutation, ClearProfileAvatarMutationVariables>;
|
||||
export const CreateProjectDocument = gql`
|
||||
mutation createProject($teamID: UUID!, $userID: UUID!, $name: String!) {
|
||||
createProject(input: {teamID: $teamID, userID: $userID, name: $name}) {
|
||||
mutation createProject($teamID: UUID, $name: String!) {
|
||||
createProject(input: {teamID: $teamID, name: $name}) {
|
||||
id
|
||||
name
|
||||
team {
|
||||
@ -2388,7 +2506,6 @@ export type CreateProjectMutationFn = ApolloReactCommon.MutationFunction<CreateP
|
||||
* const [createProjectMutation, { data, loading, error }] = useCreateProjectMutation({
|
||||
* variables: {
|
||||
* teamID: // value for 'teamID'
|
||||
* userID: // value for 'userID'
|
||||
* name: // value for 'name'
|
||||
* },
|
||||
* });
|
||||
@ -2442,7 +2559,7 @@ export type CreateProjectLabelMutationHookResult = ReturnType<typeof useCreatePr
|
||||
export type CreateProjectLabelMutationResult = ApolloReactCommon.MutationResult<CreateProjectLabelMutation>;
|
||||
export type CreateProjectLabelMutationOptions = ApolloReactCommon.BaseMutationOptions<CreateProjectLabelMutation, CreateProjectLabelMutationVariables>;
|
||||
export const CreateTaskGroupDocument = gql`
|
||||
mutation createTaskGroup($projectID: String!, $name: String!, $position: Float!) {
|
||||
mutation createTaskGroup($projectID: UUID!, $name: String!, $position: Float!) {
|
||||
createTaskGroup(input: {projectID: $projectID, name: $name, position: $position}) {
|
||||
id
|
||||
name
|
||||
@ -2510,7 +2627,7 @@ export type DeleteProjectLabelMutationHookResult = ReturnType<typeof useDeletePr
|
||||
export type DeleteProjectLabelMutationResult = ApolloReactCommon.MutationResult<DeleteProjectLabelMutation>;
|
||||
export type DeleteProjectLabelMutationOptions = ApolloReactCommon.BaseMutationOptions<DeleteProjectLabelMutation, DeleteProjectLabelMutationVariables>;
|
||||
export const DeleteTaskDocument = gql`
|
||||
mutation deleteTask($taskID: String!) {
|
||||
mutation deleteTask($taskID: UUID!) {
|
||||
deleteTask(input: {taskID: $taskID}) {
|
||||
taskID
|
||||
}
|
||||
@ -2602,6 +2719,10 @@ export const FindProjectDocument = gql`
|
||||
bgColor
|
||||
}
|
||||
}
|
||||
invitedMembers {
|
||||
email
|
||||
invitedOn
|
||||
}
|
||||
labels {
|
||||
id
|
||||
createdDate
|
||||
@ -2883,53 +3004,6 @@ export function useMeLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptio
|
||||
export type MeQueryHookResult = ReturnType<typeof useMeQuery>;
|
||||
export type MeLazyQueryHookResult = ReturnType<typeof useMeLazyQuery>;
|
||||
export type MeQueryResult = ApolloReactCommon.QueryResult<MeQuery, MeQueryVariables>;
|
||||
export const CreateProjectMemberDocument = gql`
|
||||
mutation createProjectMember($projectID: UUID!, $userID: UUID!) {
|
||||
createProjectMember(input: {projectID: $projectID, userID: $userID}) {
|
||||
ok
|
||||
member {
|
||||
id
|
||||
fullName
|
||||
profileIcon {
|
||||
url
|
||||
initials
|
||||
bgColor
|
||||
}
|
||||
username
|
||||
role {
|
||||
code
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export type CreateProjectMemberMutationFn = ApolloReactCommon.MutationFunction<CreateProjectMemberMutation, CreateProjectMemberMutationVariables>;
|
||||
|
||||
/**
|
||||
* __useCreateProjectMemberMutation__
|
||||
*
|
||||
* To run a mutation, you first call `useCreateProjectMemberMutation` within a React component and pass it any options that fit your needs.
|
||||
* When your component renders, `useCreateProjectMemberMutation` returns a tuple that includes:
|
||||
* - A mutate function that you can call at any time to execute the mutation
|
||||
* - An object with fields that represent the current status of the mutation's execution
|
||||
*
|
||||
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
||||
*
|
||||
* @example
|
||||
* const [createProjectMemberMutation, { data, loading, error }] = useCreateProjectMemberMutation({
|
||||
* variables: {
|
||||
* projectID: // value for 'projectID'
|
||||
* userID: // value for 'userID'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useCreateProjectMemberMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<CreateProjectMemberMutation, CreateProjectMemberMutationVariables>) {
|
||||
return ApolloReactHooks.useMutation<CreateProjectMemberMutation, CreateProjectMemberMutationVariables>(CreateProjectMemberDocument, baseOptions);
|
||||
}
|
||||
export type CreateProjectMemberMutationHookResult = ReturnType<typeof useCreateProjectMemberMutation>;
|
||||
export type CreateProjectMemberMutationResult = ApolloReactCommon.MutationResult<CreateProjectMemberMutation>;
|
||||
export type CreateProjectMemberMutationOptions = ApolloReactCommon.BaseMutationOptions<CreateProjectMemberMutation, CreateProjectMemberMutationVariables>;
|
||||
export const DeleteProjectDocument = gql`
|
||||
mutation deleteProject($projectID: UUID!) {
|
||||
deleteProject(input: {projectID: $projectID}) {
|
||||
@ -2965,6 +3039,41 @@ export function useDeleteProjectMutation(baseOptions?: ApolloReactHooks.Mutation
|
||||
export type DeleteProjectMutationHookResult = ReturnType<typeof useDeleteProjectMutation>;
|
||||
export type DeleteProjectMutationResult = ApolloReactCommon.MutationResult<DeleteProjectMutation>;
|
||||
export type DeleteProjectMutationOptions = ApolloReactCommon.BaseMutationOptions<DeleteProjectMutation, DeleteProjectMutationVariables>;
|
||||
export const DeleteInvitedProjectMemberDocument = gql`
|
||||
mutation deleteInvitedProjectMember($projectID: UUID!, $email: String!) {
|
||||
deleteInvitedProjectMember(input: {projectID: $projectID, email: $email}) {
|
||||
invitedMember {
|
||||
email
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export type DeleteInvitedProjectMemberMutationFn = ApolloReactCommon.MutationFunction<DeleteInvitedProjectMemberMutation, DeleteInvitedProjectMemberMutationVariables>;
|
||||
|
||||
/**
|
||||
* __useDeleteInvitedProjectMemberMutation__
|
||||
*
|
||||
* To run a mutation, you first call `useDeleteInvitedProjectMemberMutation` within a React component and pass it any options that fit your needs.
|
||||
* When your component renders, `useDeleteInvitedProjectMemberMutation` returns a tuple that includes:
|
||||
* - A mutate function that you can call at any time to execute the mutation
|
||||
* - An object with fields that represent the current status of the mutation's execution
|
||||
*
|
||||
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
||||
*
|
||||
* @example
|
||||
* const [deleteInvitedProjectMemberMutation, { data, loading, error }] = useDeleteInvitedProjectMemberMutation({
|
||||
* variables: {
|
||||
* projectID: // value for 'projectID'
|
||||
* email: // value for 'email'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDeleteInvitedProjectMemberMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<DeleteInvitedProjectMemberMutation, DeleteInvitedProjectMemberMutationVariables>) {
|
||||
return ApolloReactHooks.useMutation<DeleteInvitedProjectMemberMutation, DeleteInvitedProjectMemberMutationVariables>(DeleteInvitedProjectMemberDocument, baseOptions);
|
||||
}
|
||||
export type DeleteInvitedProjectMemberMutationHookResult = ReturnType<typeof useDeleteInvitedProjectMemberMutation>;
|
||||
export type DeleteInvitedProjectMemberMutationResult = ApolloReactCommon.MutationResult<DeleteInvitedProjectMemberMutation>;
|
||||
export type DeleteInvitedProjectMemberMutationOptions = ApolloReactCommon.BaseMutationOptions<DeleteInvitedProjectMemberMutation, DeleteInvitedProjectMemberMutationVariables>;
|
||||
export const DeleteProjectMemberDocument = gql`
|
||||
mutation deleteProjectMember($projectID: UUID!, $userID: UUID!) {
|
||||
deleteProjectMember(input: {projectID: $projectID, userID: $userID}) {
|
||||
@ -3002,6 +3111,57 @@ export function useDeleteProjectMemberMutation(baseOptions?: ApolloReactHooks.Mu
|
||||
export type DeleteProjectMemberMutationHookResult = ReturnType<typeof useDeleteProjectMemberMutation>;
|
||||
export type DeleteProjectMemberMutationResult = ApolloReactCommon.MutationResult<DeleteProjectMemberMutation>;
|
||||
export type DeleteProjectMemberMutationOptions = ApolloReactCommon.BaseMutationOptions<DeleteProjectMemberMutation, DeleteProjectMemberMutationVariables>;
|
||||
export const InviteProjectMembersDocument = gql`
|
||||
mutation inviteProjectMembers($projectID: UUID!, $members: [MemberInvite!]!) {
|
||||
inviteProjectMembers(input: {projectID: $projectID, members: $members}) {
|
||||
ok
|
||||
invitedMembers {
|
||||
email
|
||||
invitedOn
|
||||
}
|
||||
members {
|
||||
id
|
||||
fullName
|
||||
profileIcon {
|
||||
url
|
||||
initials
|
||||
bgColor
|
||||
}
|
||||
username
|
||||
role {
|
||||
code
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export type InviteProjectMembersMutationFn = ApolloReactCommon.MutationFunction<InviteProjectMembersMutation, InviteProjectMembersMutationVariables>;
|
||||
|
||||
/**
|
||||
* __useInviteProjectMembersMutation__
|
||||
*
|
||||
* To run a mutation, you first call `useInviteProjectMembersMutation` within a React component and pass it any options that fit your needs.
|
||||
* When your component renders, `useInviteProjectMembersMutation` returns a tuple that includes:
|
||||
* - A mutate function that you can call at any time to execute the mutation
|
||||
* - An object with fields that represent the current status of the mutation's execution
|
||||
*
|
||||
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
||||
*
|
||||
* @example
|
||||
* const [inviteProjectMembersMutation, { data, loading, error }] = useInviteProjectMembersMutation({
|
||||
* variables: {
|
||||
* projectID: // value for 'projectID'
|
||||
* members: // value for 'members'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useInviteProjectMembersMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<InviteProjectMembersMutation, InviteProjectMembersMutationVariables>) {
|
||||
return ApolloReactHooks.useMutation<InviteProjectMembersMutation, InviteProjectMembersMutationVariables>(InviteProjectMembersDocument, baseOptions);
|
||||
}
|
||||
export type InviteProjectMembersMutationHookResult = ReturnType<typeof useInviteProjectMembersMutation>;
|
||||
export type InviteProjectMembersMutationResult = ApolloReactCommon.MutationResult<InviteProjectMembersMutation>;
|
||||
export type InviteProjectMembersMutationOptions = ApolloReactCommon.BaseMutationOptions<InviteProjectMembersMutation, InviteProjectMembersMutationVariables>;
|
||||
export const UpdateProjectMemberRoleDocument = gql`
|
||||
mutation updateProjectMemberRole($projectID: UUID!, $userID: UUID!, $roleCode: RoleCode!) {
|
||||
updateProjectMemberRole(input: {projectID: $projectID, userID: $userID, roleCode: $roleCode}) {
|
||||
@ -3044,7 +3204,7 @@ export type UpdateProjectMemberRoleMutationHookResult = ReturnType<typeof useUpd
|
||||
export type UpdateProjectMemberRoleMutationResult = ApolloReactCommon.MutationResult<UpdateProjectMemberRoleMutation>;
|
||||
export type UpdateProjectMemberRoleMutationOptions = ApolloReactCommon.BaseMutationOptions<UpdateProjectMemberRoleMutation, UpdateProjectMemberRoleMutationVariables>;
|
||||
export const CreateTaskDocument = gql`
|
||||
mutation createTask($taskGroupID: String!, $name: String!, $position: Float!) {
|
||||
mutation createTask($taskGroupID: UUID!, $name: String!, $position: Float!) {
|
||||
createTask(input: {taskGroupID: $taskGroupID, name: $name, position: $position}) {
|
||||
...TaskFields
|
||||
}
|
||||
@ -3297,9 +3457,9 @@ export type SetTaskCompleteMutationHookResult = ReturnType<typeof useSetTaskComp
|
||||
export type SetTaskCompleteMutationResult = ApolloReactCommon.MutationResult<SetTaskCompleteMutation>;
|
||||
export type SetTaskCompleteMutationOptions = ApolloReactCommon.BaseMutationOptions<SetTaskCompleteMutation, SetTaskCompleteMutationVariables>;
|
||||
export const UpdateTaskChecklistItemLocationDocument = gql`
|
||||
mutation updateTaskChecklistItemLocation($checklistID: UUID!, $checklistItemID: UUID!, $position: Float!) {
|
||||
updateTaskChecklistItemLocation(input: {checklistID: $checklistID, checklistItemID: $checklistItemID, position: $position}) {
|
||||
checklistID
|
||||
mutation updateTaskChecklistItemLocation($taskChecklistID: UUID!, $taskChecklistItemID: UUID!, $position: Float!) {
|
||||
updateTaskChecklistItemLocation(input: {taskChecklistID: $taskChecklistID, taskChecklistItemID: $taskChecklistItemID, position: $position}) {
|
||||
taskChecklistID
|
||||
prevChecklistID
|
||||
checklistItem {
|
||||
id
|
||||
@ -3324,8 +3484,8 @@ export type UpdateTaskChecklistItemLocationMutationFn = ApolloReactCommon.Mutati
|
||||
* @example
|
||||
* const [updateTaskChecklistItemLocationMutation, { data, loading, error }] = useUpdateTaskChecklistItemLocationMutation({
|
||||
* variables: {
|
||||
* checklistID: // value for 'checklistID'
|
||||
* checklistItemID: // value for 'checklistItemID'
|
||||
* taskChecklistID: // value for 'taskChecklistID'
|
||||
* taskChecklistItemID: // value for 'taskChecklistItemID'
|
||||
* position: // value for 'position'
|
||||
* },
|
||||
* });
|
||||
@ -3371,8 +3531,8 @@ export type UpdateTaskChecklistItemNameMutationHookResult = ReturnType<typeof us
|
||||
export type UpdateTaskChecklistItemNameMutationResult = ApolloReactCommon.MutationResult<UpdateTaskChecklistItemNameMutation>;
|
||||
export type UpdateTaskChecklistItemNameMutationOptions = ApolloReactCommon.BaseMutationOptions<UpdateTaskChecklistItemNameMutation, UpdateTaskChecklistItemNameMutationVariables>;
|
||||
export const UpdateTaskChecklistLocationDocument = gql`
|
||||
mutation updateTaskChecklistLocation($checklistID: UUID!, $position: Float!) {
|
||||
updateTaskChecklistLocation(input: {checklistID: $checklistID, position: $position}) {
|
||||
mutation updateTaskChecklistLocation($taskChecklistID: UUID!, $position: Float!) {
|
||||
updateTaskChecklistLocation(input: {taskChecklistID: $taskChecklistID, position: $position}) {
|
||||
checklist {
|
||||
id
|
||||
position
|
||||
@ -3395,7 +3555,7 @@ export type UpdateTaskChecklistLocationMutationFn = ApolloReactCommon.MutationFu
|
||||
* @example
|
||||
* const [updateTaskChecklistLocationMutation, { data, loading, error }] = useUpdateTaskChecklistLocationMutation({
|
||||
* variables: {
|
||||
* checklistID: // value for 'checklistID'
|
||||
* taskChecklistID: // value for 'taskChecklistID'
|
||||
* position: // value for 'position'
|
||||
* },
|
||||
* });
|
||||
@ -4275,7 +4435,7 @@ export type UpdateTaskLocationMutationHookResult = ReturnType<typeof useUpdateTa
|
||||
export type UpdateTaskLocationMutationResult = ApolloReactCommon.MutationResult<UpdateTaskLocationMutation>;
|
||||
export type UpdateTaskLocationMutationOptions = ApolloReactCommon.BaseMutationOptions<UpdateTaskLocationMutation, UpdateTaskLocationMutationVariables>;
|
||||
export const UpdateTaskNameDocument = gql`
|
||||
mutation updateTaskName($taskID: String!, $name: String!) {
|
||||
mutation updateTaskName($taskID: UUID!, $name: String!) {
|
||||
updateTaskName(input: {taskID: $taskID, name: $name}) {
|
||||
id
|
||||
name
|
||||
@ -4380,6 +4540,40 @@ export function useCreateUserAccountMutation(baseOptions?: ApolloReactHooks.Muta
|
||||
export type CreateUserAccountMutationHookResult = ReturnType<typeof useCreateUserAccountMutation>;
|
||||
export type CreateUserAccountMutationResult = ApolloReactCommon.MutationResult<CreateUserAccountMutation>;
|
||||
export type CreateUserAccountMutationOptions = ApolloReactCommon.BaseMutationOptions<CreateUserAccountMutation, CreateUserAccountMutationVariables>;
|
||||
export const DeleteInvitedUserAccountDocument = gql`
|
||||
mutation deleteInvitedUserAccount($invitedUserID: UUID!) {
|
||||
deleteInvitedUserAccount(input: {invitedUserID: $invitedUserID}) {
|
||||
invitedUser {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export type DeleteInvitedUserAccountMutationFn = ApolloReactCommon.MutationFunction<DeleteInvitedUserAccountMutation, DeleteInvitedUserAccountMutationVariables>;
|
||||
|
||||
/**
|
||||
* __useDeleteInvitedUserAccountMutation__
|
||||
*
|
||||
* To run a mutation, you first call `useDeleteInvitedUserAccountMutation` within a React component and pass it any options that fit your needs.
|
||||
* When your component renders, `useDeleteInvitedUserAccountMutation` returns a tuple that includes:
|
||||
* - A mutate function that you can call at any time to execute the mutation
|
||||
* - An object with fields that represent the current status of the mutation's execution
|
||||
*
|
||||
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
|
||||
*
|
||||
* @example
|
||||
* const [deleteInvitedUserAccountMutation, { data, loading, error }] = useDeleteInvitedUserAccountMutation({
|
||||
* variables: {
|
||||
* invitedUserID: // value for 'invitedUserID'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDeleteInvitedUserAccountMutation(baseOptions?: ApolloReactHooks.MutationHookOptions<DeleteInvitedUserAccountMutation, DeleteInvitedUserAccountMutationVariables>) {
|
||||
return ApolloReactHooks.useMutation<DeleteInvitedUserAccountMutation, DeleteInvitedUserAccountMutationVariables>(DeleteInvitedUserAccountDocument, baseOptions);
|
||||
}
|
||||
export type DeleteInvitedUserAccountMutationHookResult = ReturnType<typeof useDeleteInvitedUserAccountMutation>;
|
||||
export type DeleteInvitedUserAccountMutationResult = ApolloReactCommon.MutationResult<DeleteInvitedUserAccountMutation>;
|
||||
export type DeleteInvitedUserAccountMutationOptions = ApolloReactCommon.BaseMutationOptions<DeleteInvitedUserAccountMutation, DeleteInvitedUserAccountMutationVariables>;
|
||||
export const DeleteUserAccountDocument = gql`
|
||||
mutation deleteUserAccount($userID: UUID!, $newOwnerID: UUID) {
|
||||
deleteUserAccount(input: {userID: $userID, newOwnerID: $newOwnerID}) {
|
||||
@ -4533,6 +4727,11 @@ export type UpdateUserRoleMutationResult = ApolloReactCommon.MutationResult<Upda
|
||||
export type UpdateUserRoleMutationOptions = ApolloReactCommon.BaseMutationOptions<UpdateUserRoleMutation, UpdateUserRoleMutationVariables>;
|
||||
export const UsersDocument = gql`
|
||||
query users {
|
||||
invitedUsers {
|
||||
id
|
||||
email
|
||||
invitedOn
|
||||
}
|
||||
users {
|
||||
id
|
||||
email
|
||||
@ -4594,4 +4793,4 @@ export function useUsersLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOp
|
||||
}
|
||||
export type UsersQueryHookResult = ReturnType<typeof useUsersQuery>;
|
||||
export type UsersLazyQueryHookResult = ReturnType<typeof useUsersLazyQuery>;
|
||||
export type UsersQueryResult = ApolloReactCommon.QueryResult<UsersQuery, UsersQueryVariables>;
|
||||
export type UsersQueryResult = ApolloReactCommon.QueryResult<UsersQuery, UsersQueryVariables>;
|
@ -1,5 +1,5 @@
|
||||
mutation createProject($teamID: UUID!, $userID: UUID!, $name: String!) {
|
||||
createProject(input: {teamID: $teamID, userID: $userID, name: $name}) {
|
||||
mutation createProject($teamID: UUID, $name: String!) {
|
||||
createProject(input: {teamID: $teamID, name: $name}) {
|
||||
id
|
||||
name
|
||||
team {
|
||||
|
@ -1,4 +1,4 @@
|
||||
mutation createTaskGroup( $projectID: String!, $name: String!, $position: Float! ) {
|
||||
mutation createTaskGroup( $projectID: UUID!, $name: String!, $position: Float! ) {
|
||||
createTaskGroup(
|
||||
input: { projectID: $projectID, name: $name, position: $position }
|
||||
) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
mutation deleteTask($taskID: String!) {
|
||||
mutation deleteTask($taskID: UUID!) {
|
||||
deleteTask(input: { taskID: $taskID }) {
|
||||
taskID
|
||||
}
|
||||
|
@ -22,6 +22,10 @@ query findProject($projectID: UUID!) {
|
||||
bgColor
|
||||
}
|
||||
}
|
||||
invitedMembers {
|
||||
email
|
||||
invitedOn
|
||||
}
|
||||
labels {
|
||||
id
|
||||
createdDate
|
||||
|
@ -1,25 +0,0 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const CREATE_PROJECT_MEMBER_MUTATION = gql`
|
||||
mutation createProjectMember($projectID: UUID!, $userID: UUID!) {
|
||||
createProjectMember(input: { projectID: $projectID, userID: $userID }) {
|
||||
ok
|
||||
member {
|
||||
id
|
||||
fullName
|
||||
profileIcon {
|
||||
url
|
||||
initials
|
||||
bgColor
|
||||
}
|
||||
username
|
||||
role {
|
||||
code
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default CREATE_PROJECT_MEMBER_MUTATION;
|
@ -0,0 +1,13 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const DELETE_PROJECT_INVITED_MEMBER_MUTATION = gql`
|
||||
mutation deleteInvitedProjectMember($projectID: UUID!, $email: String!) {
|
||||
deleteInvitedProjectMember(input: { projectID: $projectID, email: $email }) {
|
||||
invitedMember {
|
||||
email
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default DELETE_PROJECT_INVITED_MEMBER_MUTATION;
|
29
frontend/src/shared/graphql/project/inviteProjectMembers.ts
Normal file
29
frontend/src/shared/graphql/project/inviteProjectMembers.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const INVITE_PROJECT_MEMBERS_MUTATION = gql`
|
||||
mutation inviteProjectMembers($projectID: UUID!, $members: [MemberInvite!]!) {
|
||||
inviteProjectMembers(input: { projectID: $projectID, members: $members }) {
|
||||
ok
|
||||
invitedMembers {
|
||||
email
|
||||
invitedOn
|
||||
}
|
||||
members {
|
||||
id
|
||||
fullName
|
||||
profileIcon {
|
||||
url
|
||||
initials
|
||||
bgColor
|
||||
}
|
||||
username
|
||||
role {
|
||||
code
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default INVITE_PROJECT_MEMBERS_MUTATION;
|
@ -2,7 +2,7 @@ import gql from 'graphql-tag';
|
||||
import TASK_FRAGMENT from '../fragments/task';
|
||||
|
||||
const CREATE_TASK_MUTATION = gql`
|
||||
mutation createTask($taskGroupID: String!, $name: String!, $position: Float!) {
|
||||
mutation createTask($taskGroupID: UUID!, $name: String!, $position: Float!) {
|
||||
createTask(input: { taskGroupID: $taskGroupID, name: $name, position: $position }) {
|
||||
...TaskFields
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const UPDATE_TASK_CHECKLIST_ITEM_LOCATION_MUTATION = gql`
|
||||
mutation updateTaskChecklistItemLocation($checklistID: UUID!, $checklistItemID: UUID!, $position: Float!) {
|
||||
mutation updateTaskChecklistItemLocation($taskChecklistID: UUID!, $taskChecklistItemID: UUID!, $position: Float!) {
|
||||
updateTaskChecklistItemLocation(
|
||||
input: { checklistID: $checklistID, checklistItemID: $checklistItemID, position: $position }
|
||||
input: { taskChecklistID: $taskChecklistID, taskChecklistItemID: $taskChecklistItemID, position: $position }
|
||||
) {
|
||||
checklistID
|
||||
taskChecklistID
|
||||
prevChecklistID
|
||||
checklistItem {
|
||||
id
|
||||
|
@ -1,8 +1,8 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
const UPDATE_TASK_CHECKLIST_LOCATION_MUTATION = gql`
|
||||
mutation updateTaskChecklistLocation($checklistID: UUID!, $position: Float!) {
|
||||
updateTaskChecklistLocation(input: { checklistID: $checklistID, position: $position }) {
|
||||
mutation updateTaskChecklistLocation($taskChecklistID: UUID!, $position: Float!) {
|
||||
updateTaskChecklistLocation(input: { taskChecklistID: $taskChecklistID, position: $position }) {
|
||||
checklist {
|
||||
id
|
||||
position
|
||||
|
@ -1,4 +1,4 @@
|
||||
mutation updateTaskName($taskID: String!, $name: String!) {
|
||||
mutation updateTaskName($taskID: UUID!, $name: String!) {
|
||||
updateTaskName(input: { taskID: $taskID, name: $name }) {
|
||||
id
|
||||
name
|
||||
|
13
frontend/src/shared/graphql/user/deleteInvitedUser.ts
Normal file
13
frontend/src/shared/graphql/user/deleteInvitedUser.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const DELETE_INVITED_USER_MUTATION = gql`
|
||||
mutation deleteInvitedUserAccount($invitedUserID: UUID!) {
|
||||
deleteInvitedUserAccount(input: { invitedUserID: $invitedUserID }) {
|
||||
invitedUser {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default DELETE_INVITED_USER_MUTATION;
|
@ -1,4 +1,9 @@
|
||||
query users {
|
||||
invitedUsers {
|
||||
id
|
||||
email
|
||||
invitedOn
|
||||
}
|
||||
users {
|
||||
id
|
||||
email
|
||||
|
12
frontend/src/shared/icons/ArrowDown.tsx
Normal file
12
frontend/src/shared/icons/ArrowDown.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import Icon, { IconProps } from './Icon';
|
||||
|
||||
const ArrowDown: React.FC<IconProps> = ({ width = '16px', height = '16px', className }) => {
|
||||
return (
|
||||
<Icon width={width} height={height} className={className} viewBox="0 0 448 512">
|
||||
<path d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z" />
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
export default ArrowDown;
|
12
frontend/src/shared/icons/CaretDown.tsx
Normal file
12
frontend/src/shared/icons/CaretDown.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import Icon, { IconProps } from './Icon';
|
||||
|
||||
const CaretDown: React.FC<IconProps> = ({ width = '16px', height = '16px', className }) => {
|
||||
return (
|
||||
<Icon width={width} height={height} className={className} viewBox="0 0 320 512">
|
||||
<path d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z" />
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
export default CaretDown;
|
12
frontend/src/shared/icons/CaretRight.tsx
Normal file
12
frontend/src/shared/icons/CaretRight.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import Icon, { IconProps } from './Icon';
|
||||
|
||||
const CaretRight: React.FC<IconProps> = ({ width = '16px', height = '16px', className }) => {
|
||||
return (
|
||||
<Icon width={width} height={height} className={className} viewBox="0 0 192 512">
|
||||
<path d="M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z" />
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
export default CaretRight;
|
12
frontend/src/shared/icons/Dot.tsx
Normal file
12
frontend/src/shared/icons/Dot.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import Icon, { IconProps } from './Icon';
|
||||
|
||||
const Dot: React.FC<IconProps> = ({ width = '16px', height = '16px', className }) => {
|
||||
return (
|
||||
<Icon width={width} height={height} className={className} viewBox="0 0 18 18">
|
||||
<circle cx="9" cy="9" r="3.5" />
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
export default Dot;
|
12
frontend/src/shared/icons/DotCircle.tsx
Normal file
12
frontend/src/shared/icons/DotCircle.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import Icon, { IconProps } from './Icon';
|
||||
|
||||
const DotCircle: React.FC<IconProps> = ({ width = '16px', height = '16px', className }) => {
|
||||
return (
|
||||
<Icon width={width} height={height} className={className} viewBox="0 0 512 512">
|
||||
<path d="M256 8C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm80 248c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80z" />
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
export default DotCircle;
|
12
frontend/src/shared/icons/EyeSlash.tsx
Normal file
12
frontend/src/shared/icons/EyeSlash.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import Icon, { IconProps } from './Icon';
|
||||
|
||||
const EyeSlash: React.FC<IconProps> = ({ width = '16px', height = '16px', className }) => {
|
||||
return (
|
||||
<Icon width={width} height={height} className={className} viewBox="0 0 640 512">
|
||||
<path d="M320 400c-75.85 0-137.25-58.71-142.9-133.11L72.2 185.82c-13.79 17.3-26.48 35.59-36.72 55.59a32.35 32.35 0 0 0 0 29.19C89.71 376.41 197.07 448 320 448c26.91 0 52.87-4 77.89-10.46L346 397.39a144.13 144.13 0 0 1-26 2.61zm313.82 58.1l-110.55-85.44a331.25 331.25 0 0 0 81.25-102.07 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64a308.15 308.15 0 0 0-147.32 37.7L45.46 3.37A16 16 0 0 0 23 6.18L3.37 31.45A16 16 0 0 0 6.18 53.9l588.36 454.73a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zm-183.72-142l-39.3-30.38A94.75 94.75 0 0 0 416 256a94.76 94.76 0 0 0-121.31-92.21A47.65 47.65 0 0 1 304 192a46.64 46.64 0 0 1-1.54 10l-73.61-56.89A142.31 142.31 0 0 1 320 112a143.92 143.92 0 0 1 144 144c0 21.63-5.29 41.79-13.9 60.11z" />
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
export default EyeSlash;
|
12
frontend/src/shared/icons/ListUnordered.tsx
Normal file
12
frontend/src/shared/icons/ListUnordered.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import Icon, { IconProps } from './Icon';
|
||||
|
||||
const ListUnordered: React.FC<IconProps> = ({ width = '16px', height = '16px', className }) => {
|
||||
return (
|
||||
<Icon width={width} height={height} className={className} viewBox="0 0 512 512">
|
||||
<path d="M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z" />
|
||||
</Icon>
|
||||
);
|
||||
};
|
||||
|
||||
export default ListUnordered;
|
@ -1,9 +1,16 @@
|
||||
import Cross from './Cross';
|
||||
import Cog from './Cog';
|
||||
import ArrowDown from './ArrowDown';
|
||||
import ListUnordered from './ListUnordered';
|
||||
import Dot from './Dot';
|
||||
import CaretDown from './CaretDown';
|
||||
import Eye from './Eye';
|
||||
import EyeSlash from './EyeSlash';
|
||||
import CaretRight from './CaretRight';
|
||||
import List from './List';
|
||||
import At from './At';
|
||||
import Task from './Task';
|
||||
import DotCircle from './DotCircle';
|
||||
import Smile from './Smile';
|
||||
import Paperclip from './Paperclip';
|
||||
import Calendar from './Calendar';
|
||||
@ -88,5 +95,12 @@ export {
|
||||
Paperclip,
|
||||
Share,
|
||||
Eye,
|
||||
ListUnordered,
|
||||
EyeSlash,
|
||||
List,
|
||||
CaretDown,
|
||||
Dot,
|
||||
ArrowDown,
|
||||
CaretRight,
|
||||
DotCircle,
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
let accessToken = '';
|
||||
|
||||
export function setAccessToken(newToken: string) {
|
||||
console.log(newToken);
|
||||
accessToken = newToken;
|
||||
}
|
||||
export function getAccessToken() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export enum TaskSortingType {
|
||||
NONE,
|
||||
@ -46,7 +46,7 @@ export function sortTasks(a: Task, b: Task, taskSorting: TaskSorting) {
|
||||
if (b.dueDate && !a.dueDate) {
|
||||
return 1;
|
||||
}
|
||||
return moment(a.dueDate).diff(moment(b.dueDate));
|
||||
return dayjs(a.dueDate).diff(dayjs(b.dueDate));
|
||||
}
|
||||
if (taskSorting.type === TaskSortingType.COMPLETE) {
|
||||
if (a.complete && !b.complete) {
|
||||
|
138
frontend/src/taskcafe.d.ts
vendored
138
frontend/src/taskcafe.d.ts
vendored
@ -127,3 +127,141 @@ type ElementBounds = {
|
||||
};
|
||||
|
||||
type CardLabelVariant = 'large' | 'small';
|
||||
|
||||
type InvitedUser = {
|
||||
email: string;
|
||||
invitedOn: string;
|
||||
};
|
||||
|
||||
type InvitedUserAccount = {
|
||||
id: string;
|
||||
email: string;
|
||||
invitedOn: string;
|
||||
};
|
||||
|
||||
type NodeDimensions = {
|
||||
entry: React.RefObject<HTMLElement>;
|
||||
children: React.RefObject<HTMLElement> | null;
|
||||
};
|
||||
|
||||
type OutlineNode = {
|
||||
id: string;
|
||||
parent: string;
|
||||
depth: number;
|
||||
position: number;
|
||||
ancestors: Array<string>;
|
||||
collapsed: boolean;
|
||||
children: number;
|
||||
};
|
||||
|
||||
type RelationshipChild = {
|
||||
position: number;
|
||||
id: string;
|
||||
depth: number;
|
||||
children: number;
|
||||
};
|
||||
|
||||
type NodeRelationships = {
|
||||
self: { id: string; depth: number };
|
||||
children: Array<RelationshipChild>;
|
||||
numberOfSubChildren: number;
|
||||
};
|
||||
|
||||
type OutlineData = {
|
||||
published: Map<string, string>;
|
||||
nodes: Map<number, Map<string, OutlineNode>>;
|
||||
relationships: Map<string, NodeRelationships>;
|
||||
dimensions: Map<string, NodeDimensions>;
|
||||
};
|
||||
|
||||
type ImpactZoneData = {
|
||||
node: OutlineNode;
|
||||
dimensions: NodeDimensions;
|
||||
};
|
||||
|
||||
type ImpactZone = {
|
||||
above: ImpactZoneData | null;
|
||||
below: ImpactZoneData | null;
|
||||
};
|
||||
|
||||
type ImpactData = {
|
||||
zone: ImpactZone;
|
||||
depth: number;
|
||||
};
|
||||
|
||||
type ImpactPosition = 'before' | 'after' | 'beforeChildren' | 'afterChildren';
|
||||
|
||||
type ImpactAction = {
|
||||
on: 'children' | 'entry';
|
||||
position: ImpactPosition;
|
||||
};
|
||||
|
||||
type ItemElement = {
|
||||
id: string;
|
||||
parent: null | string;
|
||||
position: number;
|
||||
collapsed: boolean;
|
||||
children?: Array<ItemElement>;
|
||||
};
|
||||
type NodeDimensions = {
|
||||
entry: React.RefObject<HTMLElement>;
|
||||
children: React.RefObject<HTMLElement> | null;
|
||||
};
|
||||
|
||||
type OutlineNode = {
|
||||
id: string;
|
||||
parent: string;
|
||||
depth: number;
|
||||
position: number;
|
||||
ancestors: Array<string>;
|
||||
children: number;
|
||||
};
|
||||
|
||||
type RelationshipChild = {
|
||||
position: number;
|
||||
id: string;
|
||||
depth: number;
|
||||
children: number;
|
||||
};
|
||||
|
||||
type NodeRelationships = {
|
||||
self: { id: string; depth: number };
|
||||
children: Array<RelationshipChild>;
|
||||
numberOfSubChildren: number;
|
||||
};
|
||||
|
||||
type OutlineData = {
|
||||
published: Map<string, string>;
|
||||
nodes: Map<number, Map<string, OutlineNode>>;
|
||||
relationships: Map<string, NodeRelationships>;
|
||||
dimensions: Map<string, NodeDimensions>;
|
||||
};
|
||||
|
||||
type ImpactZoneData = {
|
||||
node: OutlineNode;
|
||||
dimensions: NodeDimensions;
|
||||
};
|
||||
|
||||
type ImpactZone = {
|
||||
above: ImpactZoneData | null;
|
||||
below: ImpactZoneData | null;
|
||||
};
|
||||
|
||||
type ImpactData = {
|
||||
zone: ImpactZone;
|
||||
depth: number;
|
||||
};
|
||||
|
||||
type ImpactPosition = 'before' | 'after' | 'beforeChildren' | 'afterChildren';
|
||||
|
||||
type ImpactAction = {
|
||||
on: 'children' | 'entry';
|
||||
position: ImpactPosition;
|
||||
};
|
||||
|
||||
type ItemElement = {
|
||||
id: string;
|
||||
parent: null | string;
|
||||
position: number;
|
||||
children?: Array<ItemElement>;
|
||||
};
|
||||
|
@ -1342,7 +1342,7 @@
|
||||
pirates "^4.0.0"
|
||||
source-map-support "^0.5.16"
|
||||
|
||||
"@babel/runtime@7.8.4", "@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.3.1", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.4", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4":
|
||||
"@babel/runtime@7.8.4", "@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.3.1", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.4", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4":
|
||||
version "7.8.4"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.8.4.tgz#d79f5a2040f7caa24d53e563aad49cbc05581308"
|
||||
integrity sha512-neAp3zt80trRVBI1x0azq6c57aNBqYZH8KhMm3TaB7wEI5Q4A2SHfBHE8w9gOhI/lrqxtEbXZgQIrHP+wvSGwQ==
|
||||
@ -1610,46 +1610,6 @@
|
||||
ts-node "^8"
|
||||
tslib "^1"
|
||||
|
||||
"@fortawesome/fontawesome-common-types@^0.2.27":
|
||||
version "0.2.27"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.27.tgz#19706345859fc46adf3684ed01d11b40903b87e9"
|
||||
integrity sha512-97GaByGaXDGMkzcJX7VmR/jRJd8h1mfhtA7RsxDBN61GnWE/PPCZhOdwG/8OZYktiRUF0CvFOr+VgRkJrt6TWg==
|
||||
|
||||
"@fortawesome/fontawesome-svg-core@^1.2.27":
|
||||
version "1.2.27"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.27.tgz#e4db8e3be81a40988213507c3e3d0c158a6641a3"
|
||||
integrity sha512-sOD3DKynocnHYpuw2sLPnTunDj7rLk91LYhi2axUYwuGe9cPCw7Bsu9EWtVdNJP+IYgTCZIbyARKXuy5K/nv+Q==
|
||||
dependencies:
|
||||
"@fortawesome/fontawesome-common-types" "^0.2.27"
|
||||
|
||||
"@fortawesome/free-brands-svg-icons@^5.12.1":
|
||||
version "5.12.1"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/free-brands-svg-icons/-/free-brands-svg-icons-5.12.1.tgz#67977addd15e21e57aa1ed71cd2ddecdfaa88647"
|
||||
integrity sha512-IYUYcgGsQuwiIHjRGfeSTCIQKUSZMb6FsV6mDj78K0D+YzGJkM4cvEBBUMHtnla5D2HCxncMI/9JX5YIk2GHeQ==
|
||||
dependencies:
|
||||
"@fortawesome/fontawesome-common-types" "^0.2.27"
|
||||
|
||||
"@fortawesome/free-regular-svg-icons@^5.12.1":
|
||||
version "5.12.1"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/free-regular-svg-icons/-/free-regular-svg-icons-5.12.1.tgz#4b378d93655acc5e432d5ed7ee127768dd351a99"
|
||||
integrity sha512-bGda18seHXb+24K6DPUFzqn4kG7B+JViP/BscMcNUXvT00M86xNhdgP2TXSdflQXn53QWqymKjx/8rhaDOJyhA==
|
||||
dependencies:
|
||||
"@fortawesome/fontawesome-common-types" "^0.2.27"
|
||||
|
||||
"@fortawesome/free-solid-svg-icons@^5.12.1":
|
||||
version "5.12.1"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.12.1.tgz#76b6f958a3471821ff146f8f955e6d7cfe87147c"
|
||||
integrity sha512-k3MwRFFUhyL4cuCJSaHDA0YNYMELDXX0h8JKtWYxO5XD3Dn+maXOMrVAAiNGooUyM2v/wz/TOaM0jxYVKeXX7g==
|
||||
dependencies:
|
||||
"@fortawesome/fontawesome-common-types" "^0.2.27"
|
||||
|
||||
"@fortawesome/react-fontawesome@^0.1.8":
|
||||
version "0.1.8"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/react-fontawesome/-/react-fontawesome-0.1.8.tgz#cb6d4dd3aeec45b6ff2d48c812317a6627618511"
|
||||
integrity sha512-I5h9YQg/ePA3Br9ISS18fcwOYmzQYDSM1ftH03/8nHkiqIVHtUyQBw482+60dnzvlr82gHt3mGm+nDUp159FCw==
|
||||
dependencies:
|
||||
prop-types "^15.5.10"
|
||||
|
||||
"@graphql-codegen/cli@^1.13.2":
|
||||
version "1.13.2"
|
||||
resolved "https://registry.yarnpkg.com/@graphql-codegen/cli/-/cli-1.13.2.tgz#4cfb3a4d766e3177ff727ea1b93429fd0f93cfcd"
|
||||
@ -2181,11 +2141,6 @@
|
||||
dependencies:
|
||||
any-observable "^0.3.0"
|
||||
|
||||
"@sheerun/mutationobserver-shim@^0.3.2":
|
||||
version "0.3.2"
|
||||
resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz#8013f2af54a2b7d735f71560ff360d3a8176a87b"
|
||||
integrity sha512-vTCdPp/T/Q3oSqwHmZ5Kpa9oI7iLtGl3RQaA/NyLHikvcrPxACkkKVr/XzkSPJWXHRhKGzVvb0urJsbMlRxi1Q==
|
||||
|
||||
"@storybook/addon-actions@^5.3.13":
|
||||
version "5.3.13"
|
||||
resolved "https://registry.yarnpkg.com/@storybook/addon-actions/-/addon-actions-5.3.13.tgz#faf57ca14a46ce0c69168c631fbfc3d79d294b38"
|
||||
@ -2947,47 +2902,6 @@
|
||||
"@svgr/plugin-svgo" "^4.3.1"
|
||||
loader-utils "^1.2.3"
|
||||
|
||||
"@testing-library/dom@^6.11.0":
|
||||
version "6.12.2"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-6.12.2.tgz#5d549acf43f2e0c23b2abfd4e36d65594c3b2741"
|
||||
integrity sha512-KCnvHra5fV+wDxg3wJObGvZFxq7v1DJt829GNFLuRDjKxVNc/B5AdsylNF5PMHFbWMXDsHwM26d2NZcZO9KjbQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.6.2"
|
||||
"@sheerun/mutationobserver-shim" "^0.3.2"
|
||||
"@types/testing-library__dom" "^6.0.0"
|
||||
aria-query "3.0.0"
|
||||
pretty-format "^24.9.0"
|
||||
wait-for-expect "^3.0.0"
|
||||
|
||||
"@testing-library/jest-dom@^4.2.4":
|
||||
version "4.2.4"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-4.2.4.tgz#00dfa0cbdd837d9a3c2a7f3f0a248ea6e7b89742"
|
||||
integrity sha512-j31Bn0rQo12fhCWOUWy9fl7wtqkp7In/YP2p5ZFyRuiiB9Qs3g+hS4gAmDWONbAHcRmVooNJ5eOHQDCOmUFXHg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.5.1"
|
||||
chalk "^2.4.1"
|
||||
css "^2.2.3"
|
||||
css.escape "^1.5.1"
|
||||
jest-diff "^24.0.0"
|
||||
jest-matcher-utils "^24.0.0"
|
||||
lodash "^4.17.11"
|
||||
pretty-format "^24.0.0"
|
||||
redent "^3.0.0"
|
||||
|
||||
"@testing-library/react@^9.3.2":
|
||||
version "9.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-9.4.0.tgz#b021ac8cb987c8dc54c6841875f745bf9b2e88e5"
|
||||
integrity sha512-XdhDWkI4GktUPsz0AYyeQ8M9qS/JFie06kcSnUVcpgOwFjAu9vhwR83qBl+lw9yZWkbECjL8Hd+n5hH6C0oWqg==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.7.6"
|
||||
"@testing-library/dom" "^6.11.0"
|
||||
"@types/testing-library__react" "^9.1.2"
|
||||
|
||||
"@testing-library/user-event@^7.1.2":
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-7.2.1.tgz#2ad4e844175a3738cb9e7064be5ea070b8863a1c"
|
||||
integrity sha512-oZ0Ib5I4Z2pUEcoo95cT1cr6slco9WY7yiPpG+RGNkj8YcYgJnM7pXmYmorNOReh8MIGcKSqXyeGjxnr8YiZbA==
|
||||
|
||||
"@types/anymatch@*":
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
|
||||
@ -3337,21 +3251,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.5.tgz#9adbc12950582aa65ead76bffdf39fe0c27a3c02"
|
||||
integrity sha512-/gG2M/Imw7cQFp8PGvz/SwocNrmKFjFsm5Pb8HdbHkZ1K8pmuPzOX4VeVoiEecFCVf4CsN1r3/BRvx+6sNqwtQ==
|
||||
|
||||
"@types/testing-library__dom@*", "@types/testing-library__dom@^6.0.0":
|
||||
version "6.12.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/testing-library__dom/-/testing-library__dom-6.12.1.tgz#37af28fae051f9e3feed5684535b1540c97ae28b"
|
||||
integrity sha512-cgqnEjxKk31tQt29j4baSWaZPNjQf3bHalj2gcHQTpW5SuHRal76gOpF0vypeEo6o+sS5inOvvNdzLY0B3FB2A==
|
||||
dependencies:
|
||||
pretty-format "^24.3.0"
|
||||
|
||||
"@types/testing-library__react@^9.1.2":
|
||||
version "9.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/testing-library__react/-/testing-library__react-9.1.2.tgz#e33af9124c60a010fc03a34eff8f8a34a75c4351"
|
||||
integrity sha512-CYaMqrswQ+cJACy268jsLAw355DZtPZGt3Jwmmotlcu8O/tkoXBI6AeZ84oZBJsIsesozPKzWzmv/0TIU+1E9Q==
|
||||
dependencies:
|
||||
"@types/react-dom" "*"
|
||||
"@types/testing-library__dom" "*"
|
||||
|
||||
"@types/uglify-js@*":
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
|
||||
@ -4193,7 +4092,7 @@ argparse@^1.0.7:
|
||||
dependencies:
|
||||
sprintf-js "~1.0.2"
|
||||
|
||||
aria-query@3.0.0, aria-query@^3.0.0:
|
||||
aria-query@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-3.0.0.tgz#65b3fcc1ca1155a8c9ae64d6eee297f15d5133cc"
|
||||
integrity sha1-ZbP8wcoRVajJrmTW7uKX8V1RM8w=
|
||||
@ -6255,12 +6154,7 @@ css-what@^3.2.1:
|
||||
resolved "https://registry.yarnpkg.com/css-what/-/css-what-3.2.1.tgz#f4a8f12421064621b456755e34a03a2c22df5da1"
|
||||
integrity sha512-WwOrosiQTvyms+Ti5ZC5vGEK0Vod3FTt1ca+payZqvKuGJF+dq7bG63DstxtN0dpm6FxY27a/zS3Wten+gEtGw==
|
||||
|
||||
css.escape@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb"
|
||||
integrity sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=
|
||||
|
||||
css@^2.0.0, css@^2.2.3:
|
||||
css@^2.0.0:
|
||||
version "2.2.4"
|
||||
resolved "https://registry.yarnpkg.com/css/-/css-2.2.4.tgz#c646755c73971f2bba6a601e2cf2fd71b1298929"
|
||||
integrity sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==
|
||||
@ -6426,6 +6320,11 @@ date-fns@^2.0.1:
|
||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.12.0.tgz#01754c8a2f3368fc1119cf4625c3dad8c1845ee6"
|
||||
integrity sha512-qJgn99xxKnFgB1qL4jpxU7Q2t0LOn1p8KMIveef3UZD7kqjT3tpFNNdXJelEHhE+rUgffriXriw/sOSU+cS1Hw==
|
||||
|
||||
dayjs@^1.9.1:
|
||||
version "1.9.1"
|
||||
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.9.1.tgz#201a755f7db5103ed6de63ba93a984141c754541"
|
||||
integrity sha512-01NCTBg8cuMJG1OQc6PR7T66+AFYiPwgDvdJmvJBn29NGzIG+DIFxPLNjHzwz3cpFIvG+NcwIjP9hSaPVoOaDg==
|
||||
|
||||
de-indent@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
|
||||
@ -9720,7 +9619,7 @@ jest-config@^24.9.0:
|
||||
pretty-format "^24.9.0"
|
||||
realpath-native "^1.1.0"
|
||||
|
||||
jest-diff@^24.0.0, jest-diff@^24.3.0, jest-diff@^24.9.0:
|
||||
jest-diff@^24.3.0, jest-diff@^24.9.0:
|
||||
version "24.9.0"
|
||||
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.9.0.tgz#931b7d0d5778a1baf7452cb816e325e3724055da"
|
||||
integrity sha512-qMfrTs8AdJE2iqrTp0hzh7kTd2PQWrsFyj9tORoKmu32xjPjeE4NyjVRDz8ybYwqS2ik8N4hsIpiVTyFeo2lBQ==
|
||||
@ -9837,7 +9736,7 @@ jest-leak-detector@^24.9.0:
|
||||
jest-get-type "^24.9.0"
|
||||
pretty-format "^24.9.0"
|
||||
|
||||
jest-matcher-utils@^24.0.0, jest-matcher-utils@^24.9.0:
|
||||
jest-matcher-utils@^24.9.0:
|
||||
version "24.9.0"
|
||||
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-24.9.0.tgz#f5b3661d5e628dffe6dd65251dfdae0e87c3a073"
|
||||
integrity sha512-OZz2IXsu6eaiMAwe67c1T+5tUAtQyQx27/EMEkbFAGiw52tB9em+uGbzpcgYVpA8wl0hlxKPZxrly4CXU/GjHA==
|
||||
@ -10701,6 +10600,11 @@ lodash@4.17.15, "lodash@>=3.5 <5", lodash@^4.0.1, lodash@^4.17.11, lodash@^4.17.
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
||||
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
|
||||
|
||||
lodash@^4.17.20:
|
||||
version "4.17.20"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
||||
|
||||
log-symbols@3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4"
|
||||
@ -12965,7 +12869,7 @@ pretty-error@^2.1.1:
|
||||
renderkid "^2.0.1"
|
||||
utila "~0.4"
|
||||
|
||||
pretty-format@^24.0.0, pretty-format@^24.3.0, pretty-format@^24.9.0:
|
||||
pretty-format@^24.9.0:
|
||||
version "24.9.0"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9"
|
||||
integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA==
|
||||
@ -14183,14 +14087,6 @@ recursive-readdir@2.2.2:
|
||||
dependencies:
|
||||
minimatch "3.0.4"
|
||||
|
||||
redent@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f"
|
||||
integrity sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==
|
||||
dependencies:
|
||||
indent-string "^4.0.0"
|
||||
strip-indent "^3.0.0"
|
||||
|
||||
redux@^4.0.4:
|
||||
version "4.0.5"
|
||||
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f"
|
||||
@ -16820,11 +16716,6 @@ w3c-xmlserializer@^1.1.2:
|
||||
webidl-conversions "^4.0.2"
|
||||
xml-name-validator "^3.0.0"
|
||||
|
||||
wait-for-expect@^3.0.0:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/wait-for-expect/-/wait-for-expect-3.0.2.tgz#d2f14b2f7b778c9b82144109c8fa89ceaadaa463"
|
||||
integrity sha512-cfS1+DZxuav1aBYbaO/kE06EOS8yRw7qOFoD3XtjTkYvCvh3zUvNST8DXK/nPaeqIzIv3P3kL3lRJn8iwOiSag==
|
||||
|
||||
walker@^1.0.7, walker@~1.0.5:
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"
|
||||
|
1
go.mod
1
go.mod
@ -11,6 +11,7 @@ require (
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/jmoiron/sqlx v1.2.0
|
||||
github.com/lib/pq v1.3.0
|
||||
github.com/lithammer/fuzzysearch v1.1.0
|
||||
github.com/magefile/mage v1.9.0
|
||||
github.com/pelletier/go-toml v1.8.0 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
|
3
go.sum
3
go.sum
@ -109,6 +109,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSY
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369 h1:XNT/Zf5l++1Pyg08/HV04ppB0gKxAqtZQBRYiYrUuYk=
|
||||
github.com/cznic/mathutil v0.0.0-20180504122225-ca4c9f2c1369/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@ -357,6 +358,8 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lithammer/fuzzysearch v1.1.0 h1:go9v8tLCrNTTlH42OAaq4eHFe81TDHEnlrMEb6R4f+A=
|
||||
github.com/lithammer/fuzzysearch v1.1.0/go.mod h1:Bqx4wo8lTOFcJr3ckpY6HA9lEIOO0H5HrkJ5CsN56HQ=
|
||||
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/magefile/mage v1.9.0 h1:t3AU2wNwehMCW97vuqQLtw6puppWXHO+O2MHo5a50XE=
|
||||
github.com/magefile/mage v1.9.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
|
||||
|
@ -7,8 +7,6 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var jwtKey = []byte("taskcafe_test_key")
|
||||
|
||||
// RestrictedMode is used restrict JWT access to just the install route
|
||||
type RestrictedMode string
|
||||
|
||||
@ -54,7 +52,7 @@ func (r *ErrMalformedToken) Error() string {
|
||||
}
|
||||
|
||||
// NewAccessToken generates a new JWT access token with the correct claims
|
||||
func NewAccessToken(userID string, restrictedMode RestrictedMode, orgRole string) (string, error) {
|
||||
func NewAccessToken(userID string, restrictedMode RestrictedMode, orgRole string, jwtKey []byte) (string, error) {
|
||||
role := RoleMember
|
||||
if orgRole == "admin" {
|
||||
role = RoleAdmin
|
||||
@ -76,7 +74,7 @@ func NewAccessToken(userID string, restrictedMode RestrictedMode, orgRole string
|
||||
}
|
||||
|
||||
// NewAccessTokenCustomExpiration creates an access token with a custom duration
|
||||
func NewAccessTokenCustomExpiration(userID string, dur time.Duration) (string, error) {
|
||||
func NewAccessTokenCustomExpiration(userID string, dur time.Duration, jwtKey []byte) (string, error) {
|
||||
accessExpirationTime := time.Now().Add(dur)
|
||||
accessClaims := &AccessTokenClaims{
|
||||
UserID: userID,
|
||||
@ -94,7 +92,7 @@ func NewAccessTokenCustomExpiration(userID string, dur time.Duration) (string, e
|
||||
}
|
||||
|
||||
// ValidateAccessToken validates a JWT access token and returns the contained claims or an error if it's invalid
|
||||
func ValidateAccessToken(accessTokenString string) (AccessTokenClaims, error) {
|
||||
func ValidateAccessToken(accessTokenString string, jwtKey []byte) (AccessTokenClaims, error) {
|
||||
accessClaims := &AccessTokenClaims{}
|
||||
accessToken, err := jwt.ParseWithClaims(accessTokenString, accessClaims, func(token *jwt.Token) (interface{}, error) {
|
||||
return jwtKey, nil
|
||||
|
@ -62,11 +62,31 @@ func initConfig() {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
viper.SetDefault("server.hostname", "0.0.0.0:3333")
|
||||
viper.SetDefault("database.host", "127.0.0.1")
|
||||
viper.SetDefault("database.name", "taskcafe")
|
||||
viper.SetDefault("database.user", "taskcafe")
|
||||
viper.SetDefault("database.password", "taskcafe_test")
|
||||
|
||||
viper.SetDefault("queue.broker", "amqp://guest:guest@localhost:5672/")
|
||||
viper.SetDefault("queue.store", "memcache://localhost:11211")
|
||||
|
||||
}
|
||||
|
||||
// Execute the root cobra command
|
||||
func Execute() {
|
||||
viper.SetDefault("server.hostname", "0.0.0.0:3333")
|
||||
viper.SetDefault("database.host", "127.0.0.1")
|
||||
viper.SetDefault("database.name", "taskcafe")
|
||||
viper.SetDefault("database.user", "taskcafe")
|
||||
viper.SetDefault("database.password", "taskcafe_test")
|
||||
viper.SetDefault("database.port", "5432")
|
||||
|
||||
viper.SetDefault("queue.broker", "amqp://guest:guest@localhost:5672/")
|
||||
viper.SetDefault("queue.store", "memcache://localhost:11211")
|
||||
|
||||
rootCmd.SetVersionTemplate(versionTemplate)
|
||||
rootCmd.AddCommand(newWebCmd(), newMigrateCmd(), newTokenCmd(), newWorkerCmd())
|
||||
rootCmd.AddCommand(newWebCmd(), newMigrateCmd(), newTokenCmd(), newWorkerCmd(), newResetPasswordCmd())
|
||||
rootCmd.Execute()
|
||||
}
|
||||
|
@ -68,9 +68,5 @@ func newMigrateCmd() *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
viper.SetDefault("database.host", "127.0.0.1")
|
||||
viper.SetDefault("database.name", "taskcafe")
|
||||
viper.SetDefault("database.user", "taskcafe")
|
||||
viper.SetDefault("database.password", "taskcafe_test")
|
||||
return c
|
||||
}
|
||||
|
68
internal/commands/reset_password.go
Normal file
68
internal/commands/reset_password.go
Normal file
@ -0,0 +1,68 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func newResetPasswordCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "reset-password",
|
||||
Short: "Resets password of the specified user",
|
||||
Long: "If the user forgets its password you can reset it with this command.",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
connection := fmt.Sprintf("user=%s password=%s host=%s dbname=%s sslmode=disable",
|
||||
viper.GetString("database.user"),
|
||||
viper.GetString("database.password"),
|
||||
viper.GetString("database.host"),
|
||||
viper.GetString("database.name"),
|
||||
)
|
||||
var database *sqlx.DB
|
||||
var err error
|
||||
var retryDuration time.Duration
|
||||
maxRetryNumber := 4
|
||||
for i := 0; i < maxRetryNumber; i++ {
|
||||
database, err = sqlx.Connect("postgres", connection)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
retryDuration = time.Duration(i*2) * time.Second
|
||||
log.WithFields(log.Fields{"retryNumber": i, "retryDuration": retryDuration}).WithError(err).Error("issue connecting to database, retrying")
|
||||
if i != maxRetryNumber-1 {
|
||||
time.Sleep(retryDuration)
|
||||
}
|
||||
}
|
||||
database.SetMaxOpenConns(25)
|
||||
database.SetMaxIdleConns(25)
|
||||
database.SetConnMaxLifetime(5 * time.Minute)
|
||||
repo := *db.NewRepository(database)
|
||||
|
||||
username := args[0]
|
||||
password := args[1]
|
||||
|
||||
user, err := repo.GetUserAccountByUsername(context.TODO(), username)
|
||||
if err != nil {
|
||||
fmt.Println("There is no user with that username. :/")
|
||||
return nil
|
||||
}
|
||||
|
||||
hashedPwd, err := bcrypt.GenerateFromPassword([]byte(password), 14)
|
||||
|
||||
if _, err := repo.SetUserPassword(context.TODO(), db.SetUserPasswordParams{UserID: user.UserID, PasswordHash: string(hashedPwd)}); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Updated user \"" + username + "\" password.")
|
||||
defer database.Close()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
@ -1,12 +1,15 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jordanknott/taskcafe/internal/auth"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func newTokenCmd() *cobra.Command {
|
||||
@ -15,13 +18,18 @@ func newTokenCmd() *cobra.Command {
|
||||
Short: "Create a long lived JWT token for dev purposes",
|
||||
Long: "Create a long lived JWT token for dev purposes",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
token, err := auth.NewAccessTokenCustomExpiration(args[0], time.Hour*24)
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
secret := viper.GetString("server.secret")
|
||||
if strings.TrimSpace(secret) == "" {
|
||||
return errors.New("server.secret must be set (TASKCAFE_SERVER_SECRET)")
|
||||
}
|
||||
token, err := auth.NewAccessTokenCustomExpiration(args[0], time.Hour*24, []byte(secret))
|
||||
if err != nil {
|
||||
log.WithError(err).Error("issue while creating access token")
|
||||
return
|
||||
return err
|
||||
}
|
||||
fmt.Println(token)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,13 @@ package commands
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
"github.com/golang-migrate/migrate/v4/database/postgres"
|
||||
"github.com/golang-migrate/migrate/v4/source/httpfs"
|
||||
"github.com/google/uuid"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
@ -30,24 +32,30 @@ func newWebCmd() *cobra.Command {
|
||||
log.SetFormatter(Formatter)
|
||||
log.SetLevel(log.InfoLevel)
|
||||
|
||||
connection := fmt.Sprintf("user=%s password=%s host=%s dbname=%s sslmode=disable",
|
||||
connection := fmt.Sprintf("user=%s password=%s host=%s dbname=%s port=%s sslmode=disable",
|
||||
viper.GetString("database.user"),
|
||||
viper.GetString("database.password"),
|
||||
viper.GetString("database.host"),
|
||||
viper.GetString("database.name"),
|
||||
viper.GetString("database.port"),
|
||||
)
|
||||
var db *sqlx.DB
|
||||
var err error
|
||||
retryNumber := 0
|
||||
for i := 0; retryNumber <= 3; i++ {
|
||||
retryNumber++
|
||||
var retryDuration time.Duration
|
||||
maxRetryNumber := 4
|
||||
for i := 0; i < maxRetryNumber; i++ {
|
||||
db, err = sqlx.Connect("postgres", connection)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
retryDuration := time.Duration(i*2) * time.Second
|
||||
log.WithFields(log.Fields{"retryNumber": retryNumber, "retryDuration": retryDuration}).WithError(err).Error("issue connecting to database, retrying")
|
||||
time.Sleep(retryDuration)
|
||||
retryDuration = time.Duration(i*2) * time.Second
|
||||
log.WithFields(log.Fields{"retryNumber": i, "retryDuration": retryDuration}).WithError(err).Error("issue connecting to database, retrying")
|
||||
if i != maxRetryNumber-1 {
|
||||
time.Sleep(retryDuration)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
db.SetMaxOpenConns(25)
|
||||
db.SetMaxIdleConns(25)
|
||||
@ -62,22 +70,21 @@ func newWebCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{"url": viper.GetString("server.hostname")}).Info("starting server")
|
||||
r, _ := route.NewRouter(db)
|
||||
http.ListenAndServe(viper.GetString("server.hostname"), r)
|
||||
return nil
|
||||
secret := viper.GetString("server.secret")
|
||||
if strings.TrimSpace(secret) == "" {
|
||||
log.Warn("server.secret is not set, generating a random secret")
|
||||
secret = uuid.New().String()
|
||||
}
|
||||
r, _ := route.NewRouter(db, []byte(secret))
|
||||
return http.ListenAndServe(viper.GetString("server.hostname"), r)
|
||||
},
|
||||
}
|
||||
cc.Flags().Bool("migrate", false, "if true, auto run's schema migrations before starting the web server")
|
||||
viper.BindPFlag("migrate", cc.Flags().Lookup("migrate"))
|
||||
viper.SetDefault("migrate", false)
|
||||
viper.SetDefault("server.hostname", "0.0.0.0:3333")
|
||||
viper.SetDefault("database.host", "127.0.0.1")
|
||||
viper.SetDefault("database.name", "taskcafe")
|
||||
viper.SetDefault("database.user", "taskcafe")
|
||||
viper.SetDefault("database.password", "taskcafe_test")
|
||||
|
||||
viper.SetDefault("queue.broker", "amqp://guest:guest@localhost:5672/")
|
||||
viper.SetDefault("queue.store", "memcache://localhost:11211")
|
||||
cc.Flags().Bool("migrate", false, "if true, auto run's schema migrations before starting the web server")
|
||||
|
||||
viper.BindPFlag("migrate", cc.Flags().Lookup("migrate"))
|
||||
|
||||
viper.SetDefault("migrate", false)
|
||||
return cc
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,10 @@ package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"time"
|
||||
|
||||
"github.com/RichardKnop/machinery/v1"
|
||||
"github.com/RichardKnop/machinery/v1/config"
|
||||
@ -72,12 +73,5 @@ func newWorkerCmd() *cobra.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
viper.SetDefault("database.host", "127.0.0.1")
|
||||
viper.SetDefault("database.name", "taskcafe")
|
||||
viper.SetDefault("database.user", "taskcafe")
|
||||
viper.SetDefault("database.password", "taskcafe_test")
|
||||
|
||||
viper.SetDefault("queue.broker", "amqp://guest:guest@localhost:5672/")
|
||||
viper.SetDefault("queue.store", "memcache://localhost:11211")
|
||||
return cc
|
||||
}
|
||||
|
@ -38,6 +38,12 @@ type Organization struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type PersonalProject struct {
|
||||
PersonalProjectID uuid.UUID `json:"personal_project_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
@ -61,6 +67,12 @@ type ProjectMember struct {
|
||||
RoleCode string `json:"role_code"`
|
||||
}
|
||||
|
||||
type ProjectMemberInvited struct {
|
||||
ProjectMemberInvitedID uuid.UUID `json:"project_member_invited_id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
}
|
||||
|
||||
type RefreshToken struct {
|
||||
TokenID uuid.UUID `json:"token_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
@ -159,3 +171,10 @@ type UserAccount struct {
|
||||
RoleCode string `json:"role_code"`
|
||||
Bio string `json:"bio"`
|
||||
}
|
||||
|
||||
type UserAccountInvited struct {
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invited_on"`
|
||||
HasJoined bool `json:"has_joined"`
|
||||
}
|
||||
|
@ -10,18 +10,17 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createProject = `-- name: CreateProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES ($1, $2, $3) RETURNING project_id, team_id, created_at, name
|
||||
const createPersonalProject = `-- name: CreatePersonalProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES (null, $1, $2) RETURNING project_id, team_id, created_at, name
|
||||
`
|
||||
|
||||
type CreateProjectParams struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
type CreatePersonalProjectParams struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, createProject, arg.TeamID, arg.CreatedAt, arg.Name)
|
||||
func (q *Queries) CreatePersonalProject(ctx context.Context, arg CreatePersonalProjectParams) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, createPersonalProject, arg.CreatedAt, arg.Name)
|
||||
var i Project
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
@ -32,6 +31,22 @@ func (q *Queries) CreateProject(ctx context.Context, arg CreateProjectParams) (P
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createPersonalProjectLink = `-- name: CreatePersonalProjectLink :one
|
||||
INSERT INTO personal_project (project_id, user_id) VALUES ($1, $2) RETURNING personal_project_id, project_id, user_id
|
||||
`
|
||||
|
||||
type CreatePersonalProjectLinkParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreatePersonalProjectLink(ctx context.Context, arg CreatePersonalProjectLinkParams) (PersonalProject, error) {
|
||||
row := q.db.QueryRowContext(ctx, createPersonalProjectLink, arg.ProjectID, arg.UserID)
|
||||
var i PersonalProject
|
||||
err := row.Scan(&i.PersonalProjectID, &i.ProjectID, &i.UserID)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createProjectMember = `-- name: CreateProjectMember :one
|
||||
INSERT INTO project_member (project_id, user_id, role_code, added_at) VALUES ($1, $2, $3, $4)
|
||||
RETURNING project_member_id, project_id, user_id, added_at, role_code
|
||||
@ -62,6 +77,37 @@ func (q *Queries) CreateProjectMember(ctx context.Context, arg CreateProjectMemb
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createTeamProject = `-- name: CreateTeamProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES ($1, $2, $3) RETURNING project_id, team_id, created_at, name
|
||||
`
|
||||
|
||||
type CreateTeamProjectParams struct {
|
||||
TeamID uuid.UUID `json:"team_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateTeamProject(ctx context.Context, arg CreateTeamProjectParams) (Project, error) {
|
||||
row := q.db.QueryRowContext(ctx, createTeamProject, arg.TeamID, arg.CreatedAt, arg.Name)
|
||||
var i Project
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteInvitedProjectMemberByID = `-- name: DeleteInvitedProjectMemberByID :exec
|
||||
DELETE FROM project_member_invited WHERE project_member_invited_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteInvitedProjectMemberByID(ctx context.Context, projectMemberInvitedID uuid.UUID) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteInvitedProjectMemberByID, projectMemberInvitedID)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteProjectByID = `-- name: DeleteProjectByID :exec
|
||||
DELETE FROM project WHERE project_id = $1
|
||||
`
|
||||
@ -85,12 +131,12 @@ func (q *Queries) DeleteProjectMember(ctx context.Context, arg DeleteProjectMemb
|
||||
return err
|
||||
}
|
||||
|
||||
const getAllProjects = `-- name: GetAllProjects :many
|
||||
SELECT project_id, team_id, created_at, name FROM project
|
||||
const getAllProjectsForTeam = `-- name: GetAllProjectsForTeam :many
|
||||
SELECT project_id, team_id, created_at, name FROM project WHERE team_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllProjects(ctx context.Context) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllProjects)
|
||||
func (q *Queries) GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllProjectsForTeam, teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -117,12 +163,12 @@ func (q *Queries) GetAllProjects(ctx context.Context) ([]Project, error) {
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getAllProjectsForTeam = `-- name: GetAllProjectsForTeam :many
|
||||
SELECT project_id, team_id, created_at, name FROM project WHERE team_id = $1
|
||||
const getAllTeamProjects = `-- name: GetAllTeamProjects :many
|
||||
SELECT project_id, team_id, created_at, name FROM project WHERE team_id IS NOT null
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllProjectsForTeam, teamID)
|
||||
func (q *Queries) GetAllTeamProjects(ctx context.Context) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllTeamProjects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -182,6 +228,42 @@ func (q *Queries) GetAllVisibleProjectsForUserID(ctx context.Context, userID uui
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getInvitedMembersForProjectID = `-- name: GetInvitedMembersForProjectID :many
|
||||
SELECT uai.user_account_invited_id, email, invited_on FROM project_member_invited AS pmi
|
||||
INNER JOIN user_account_invited AS uai
|
||||
ON uai.user_account_invited_id = pmi.user_account_invited_id
|
||||
WHERE project_id = $1
|
||||
`
|
||||
|
||||
type GetInvitedMembersForProjectIDRow struct {
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invited_on"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetInvitedMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]GetInvitedMembersForProjectIDRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getInvitedMembersForProjectID, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetInvitedMembersForProjectIDRow
|
||||
for rows.Next() {
|
||||
var i GetInvitedMembersForProjectIDRow
|
||||
if err := rows.Scan(&i.UserAccountInvitedID, &i.Email, &i.InvitedOn); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getMemberProjectIDsForUserID = `-- name: GetMemberProjectIDsForUserID :many
|
||||
SELECT project_id FROM project_member WHERE user_id = $1
|
||||
`
|
||||
@ -209,6 +291,40 @@ func (q *Queries) GetMemberProjectIDsForUserID(ctx context.Context, userID uuid.
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getPersonalProjectsForUserID = `-- name: GetPersonalProjectsForUserID :many
|
||||
SELECT project.project_id, project.team_id, project.created_at, project.name FROM project
|
||||
LEFT JOIN personal_project ON personal_project.project_id = project.project_id
|
||||
WHERE personal_project.user_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetPersonalProjectsForUserID(ctx context.Context, userID uuid.UUID) ([]Project, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getPersonalProjectsForUserID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Project
|
||||
for rows.Next() {
|
||||
var i Project
|
||||
if err := rows.Scan(
|
||||
&i.ProjectID,
|
||||
&i.TeamID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProjectByID = `-- name: GetProjectByID :one
|
||||
SELECT project_id, team_id, created_at, name FROM project WHERE project_id = $1
|
||||
`
|
||||
@ -225,6 +341,26 @@ func (q *Queries) GetProjectByID(ctx context.Context, projectID uuid.UUID) (Proj
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProjectMemberInvitedIDByEmail = `-- name: GetProjectMemberInvitedIDByEmail :one
|
||||
SELECT email, invited_on, project_member_invited_id FROM user_account_invited AS uai
|
||||
inner join project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE email = $1
|
||||
`
|
||||
|
||||
type GetProjectMemberInvitedIDByEmailRow struct {
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invited_on"`
|
||||
ProjectMemberInvitedID uuid.UUID `json:"project_member_invited_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetProjectMemberInvitedIDByEmail(ctx context.Context, email string) (GetProjectMemberInvitedIDByEmailRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectMemberInvitedIDByEmail, email)
|
||||
var i GetProjectMemberInvitedIDByEmailRow
|
||||
err := row.Scan(&i.Email, &i.InvitedOn, &i.ProjectMemberInvitedID)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getProjectMembersForProjectID = `-- name: GetProjectMembersForProjectID :many
|
||||
SELECT project_member_id, project_id, user_id, added_at, role_code FROM project_member WHERE project_id = $1
|
||||
`
|
||||
|
@ -9,11 +9,14 @@ import (
|
||||
)
|
||||
|
||||
type Querier interface {
|
||||
CreateInvitedProjectMember(ctx context.Context, arg CreateInvitedProjectMemberParams) (ProjectMemberInvited, error)
|
||||
CreateInvitedUser(ctx context.Context, email string) (UserAccountInvited, error)
|
||||
CreateLabelColor(ctx context.Context, arg CreateLabelColorParams) (LabelColor, error)
|
||||
CreateNotification(ctx context.Context, arg CreateNotificationParams) (Notification, error)
|
||||
CreateNotificationObject(ctx context.Context, arg CreateNotificationObjectParams) (NotificationObject, error)
|
||||
CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Organization, error)
|
||||
CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error)
|
||||
CreatePersonalProject(ctx context.Context, arg CreatePersonalProjectParams) (Project, error)
|
||||
CreatePersonalProjectLink(ctx context.Context, arg CreatePersonalProjectLinkParams) (PersonalProject, error)
|
||||
CreateProjectLabel(ctx context.Context, arg CreateProjectLabelParams) (ProjectLabel, error)
|
||||
CreateProjectMember(ctx context.Context, arg CreateProjectMemberParams) (ProjectMember, error)
|
||||
CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (RefreshToken, error)
|
||||
@ -27,8 +30,11 @@ type Querier interface {
|
||||
CreateTaskLabelForTask(ctx context.Context, arg CreateTaskLabelForTaskParams) (TaskLabel, error)
|
||||
CreateTeam(ctx context.Context, arg CreateTeamParams) (Team, error)
|
||||
CreateTeamMember(ctx context.Context, arg CreateTeamMemberParams) (TeamMember, error)
|
||||
CreateTeamProject(ctx context.Context, arg CreateTeamProjectParams) (Project, error)
|
||||
CreateUserAccount(ctx context.Context, arg CreateUserAccountParams) (UserAccount, error)
|
||||
DeleteExpiredTokens(ctx context.Context) error
|
||||
DeleteInvitedProjectMemberByID(ctx context.Context, projectMemberInvitedID uuid.UUID) error
|
||||
DeleteInvitedUserAccount(ctx context.Context, userAccountInvitedID uuid.UUID) (UserAccountInvited, error)
|
||||
DeleteProjectByID(ctx context.Context, projectID uuid.UUID) error
|
||||
DeleteProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) error
|
||||
DeleteProjectMember(ctx context.Context, arg DeleteProjectMemberParams) error
|
||||
@ -47,25 +53,34 @@ type Querier interface {
|
||||
DeleteUserAccountByID(ctx context.Context, userID uuid.UUID) error
|
||||
GetAllNotificationsForUserID(ctx context.Context, notifierID uuid.UUID) ([]Notification, error)
|
||||
GetAllOrganizations(ctx context.Context) ([]Organization, error)
|
||||
GetAllProjects(ctx context.Context) ([]Project, error)
|
||||
GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) ([]Project, error)
|
||||
GetAllTaskGroups(ctx context.Context) ([]TaskGroup, error)
|
||||
GetAllTasks(ctx context.Context) ([]Task, error)
|
||||
GetAllTeamProjects(ctx context.Context) ([]Project, error)
|
||||
GetAllTeams(ctx context.Context) ([]Team, error)
|
||||
GetAllUserAccounts(ctx context.Context) ([]UserAccount, error)
|
||||
GetAllVisibleProjectsForUserID(ctx context.Context, userID uuid.UUID) ([]Project, error)
|
||||
GetAssignedMembersForTask(ctx context.Context, taskID uuid.UUID) ([]TaskAssigned, error)
|
||||
GetEntityForNotificationID(ctx context.Context, notificationID uuid.UUID) (GetEntityForNotificationIDRow, error)
|
||||
GetEntityIDForNotificationID(ctx context.Context, notificationID uuid.UUID) (uuid.UUID, error)
|
||||
GetInvitedMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]GetInvitedMembersForProjectIDRow, error)
|
||||
GetInvitedUserAccounts(ctx context.Context) ([]UserAccountInvited, error)
|
||||
GetInvitedUserByEmail(ctx context.Context, email string) (UserAccountInvited, error)
|
||||
GetLabelColorByID(ctx context.Context, labelColorID uuid.UUID) (LabelColor, error)
|
||||
GetLabelColors(ctx context.Context) ([]LabelColor, error)
|
||||
GetMemberData(ctx context.Context, projectID uuid.UUID) ([]UserAccount, error)
|
||||
GetMemberProjectIDsForUserID(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error)
|
||||
GetMemberTeamIDsForUserID(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error)
|
||||
GetNotificationForNotificationID(ctx context.Context, notificationID uuid.UUID) (GetNotificationForNotificationIDRow, error)
|
||||
GetPersonalProjectsForUserID(ctx context.Context, userID uuid.UUID) ([]Project, error)
|
||||
GetProjectByID(ctx context.Context, projectID uuid.UUID) (Project, error)
|
||||
GetProjectIDForTask(ctx context.Context, taskID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectIDForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectIDForTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectIDForTaskGroup(ctx context.Context, taskGroupID uuid.UUID) (uuid.UUID, error)
|
||||
GetProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) (ProjectLabel, error)
|
||||
GetProjectLabelsForProject(ctx context.Context, projectID uuid.UUID) ([]ProjectLabel, error)
|
||||
GetProjectMemberInvitedIDByEmail(ctx context.Context, email string) (GetProjectMemberInvitedIDByEmailRow, error)
|
||||
GetProjectMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectMember, error)
|
||||
GetProjectRolesForUserID(ctx context.Context, userID uuid.UUID) ([]GetProjectRolesForUserIDRow, error)
|
||||
GetRefreshTokenByID(ctx context.Context, tokenID uuid.UUID) (RefreshToken, error)
|
||||
|
@ -25,4 +25,3 @@ WHERE n.notification_id = $1;
|
||||
-- name: CreateNotification :one
|
||||
INSERT INTO notification(notification_object_id, notifier_id)
|
||||
VALUES ($1, $2) RETURNING *;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
-- name: GetAllProjects :many
|
||||
SELECT * FROM project;
|
||||
-- name: GetAllTeamProjects :many
|
||||
SELECT * FROM project WHERE team_id IS NOT null;
|
||||
|
||||
-- name: GetAllProjectsForTeam :many
|
||||
SELECT * FROM project WHERE team_id = $1;
|
||||
@ -7,9 +7,12 @@ SELECT * FROM project WHERE team_id = $1;
|
||||
-- name: GetProjectByID :one
|
||||
SELECT * FROM project WHERE project_id = $1;
|
||||
|
||||
-- name: CreateProject :one
|
||||
-- name: CreateTeamProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES ($1, $2, $3) RETURNING *;
|
||||
|
||||
-- name: CreatePersonalProject :one
|
||||
INSERT INTO project(team_id, created_at, name) VALUES (null, $1, $2) RETURNING *;
|
||||
|
||||
-- name: UpdateProjectNameByID :one
|
||||
UPDATE project SET name = $2 WHERE project_id = $1 RETURNING *;
|
||||
|
||||
@ -40,13 +43,37 @@ SELECT project_id, role_code FROM project_member WHERE user_id = $1;
|
||||
-- name: GetMemberProjectIDsForUserID :many
|
||||
SELECT project_id FROM project_member WHERE user_id = $1;
|
||||
|
||||
-- name: GetInvitedMembersForProjectID :many
|
||||
SELECT uai.user_account_invited_id, email, invited_on FROM project_member_invited AS pmi
|
||||
INNER JOIN user_account_invited AS uai
|
||||
ON uai.user_account_invited_id = pmi.user_account_invited_id
|
||||
WHERE project_id = $1;
|
||||
|
||||
-- name: GetProjectMemberInvitedIDByEmail :one
|
||||
SELECT email, invited_on, project_member_invited_id FROM user_account_invited AS uai
|
||||
inner join project_member_invited AS pmi
|
||||
ON pmi.user_account_invited_id = uai.user_account_invited_id
|
||||
WHERE email = $1;
|
||||
|
||||
-- name: DeleteInvitedProjectMemberByID :exec
|
||||
DELETE FROM project_member_invited WHERE project_member_invited_id = $1;
|
||||
|
||||
-- name: GetAllVisibleProjectsForUserID :many
|
||||
SELECT project.* FROM project LEFT JOIN
|
||||
project_member ON project_member.project_id = project.project_id WHERE project_member.user_id = $1;
|
||||
|
||||
-- name: GetPersonalProjectsForUserID :many
|
||||
SELECT project.* FROM project
|
||||
LEFT JOIN personal_project ON personal_project.project_id = project.project_id
|
||||
WHERE personal_project.user_id = $1;
|
||||
|
||||
|
||||
-- name: GetUserRolesForProject :one
|
||||
SELECT p.team_id, COALESCE(tm.role_code, '') AS team_role, COALESCE(pm.role_code, '') AS project_role
|
||||
FROM project AS p
|
||||
LEFT JOIN project_member AS pm ON pm.project_id = p.project_id AND pm.user_id = $1
|
||||
LEFT JOIN team_member AS tm ON tm.team_id = p.team_id AND tm.user_id = $1
|
||||
WHERE p.project_id = $2;
|
||||
|
||||
-- name: CreatePersonalProjectLink :one
|
||||
INSERT INTO personal_project (project_id, user_id) VALUES ($1, $2) RETURNING *;
|
||||
|
@ -41,3 +41,16 @@ UPDATE task_checklist SET position = $2 WHERE task_checklist_id = $1 RETURNING *
|
||||
|
||||
-- name: UpdateTaskChecklistItemLocation :one
|
||||
UPDATE task_checklist_item SET position = $2, task_checklist_id = $3 WHERE task_checklist_item_id = $1 RETURNING *;
|
||||
|
||||
-- name: GetProjectIDForTaskChecklist :one
|
||||
SELECT project_id FROM task_checklist
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE task_checklist.task_checklist_id = $1;
|
||||
|
||||
-- name: GetProjectIDForTaskChecklistItem :one
|
||||
SELECT project_id FROM task_checklist_item AS tci
|
||||
INNER JOIN task_checklist ON task_checklist.task_checklist_id = tci.task_checklist_id
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE tci.task_checklist_item_id = $1;
|
||||
|
@ -5,6 +5,9 @@ INSERT INTO task_group (project_id, created_at, name, position)
|
||||
-- name: GetTaskGroupsForProject :many
|
||||
SELECT * FROM task_group WHERE project_id = $1;
|
||||
|
||||
-- name: GetProjectIDForTaskGroup :one
|
||||
SELECT project_id from task_group WHERE task_group_id = $1;
|
||||
|
||||
-- name: GetAllTaskGroups :many
|
||||
SELECT * FROM task_group;
|
||||
|
||||
|
@ -15,6 +15,11 @@ INSERT INTO user_account(full_name, initials, email, username, created_at, passw
|
||||
UPDATE user_account SET profile_avatar_url = $2 WHERE user_id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetMemberData :many
|
||||
SELECT * FROM user_account
|
||||
WHERE username != 'system'
|
||||
AND user_id NOT IN (SELECT user_id FROM project_member WHERE project_id = $1);
|
||||
|
||||
-- name: UpdateUserAccountInfo :one
|
||||
UPDATE user_account SET bio = $2, full_name = $3, initials = $4, email = $5
|
||||
WHERE user_id = $1 RETURNING *;
|
||||
@ -32,3 +37,19 @@ UPDATE user_account SET role_code = $2 WHERE user_id = $1 RETURNING *;
|
||||
|
||||
-- name: SetUserPassword :one
|
||||
UPDATE user_account SET password_hash = $2 WHERE user_id = $1 RETURNING *;
|
||||
|
||||
-- name: CreateInvitedUser :one
|
||||
INSERT INTO user_account_invited (email) VALUES ($1) RETURNING *;
|
||||
|
||||
-- name: GetInvitedUserByEmail :one
|
||||
SELECT * FROM user_account_invited WHERE email = $1;
|
||||
|
||||
-- name: CreateInvitedProjectMember :one
|
||||
INSERT INTO project_member_invited (project_id, user_account_invited_id) VALUES ($1, $2)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetInvitedUserAccounts :many
|
||||
SELECT * FROM user_account_invited;
|
||||
|
||||
-- name: DeleteInvitedUserAccount :one
|
||||
DELETE FROM user_account_invited WHERE user_account_invited_id = $1 RETURNING *;
|
||||
|
@ -90,6 +90,35 @@ func (q *Queries) DeleteTaskChecklistItem(ctx context.Context, taskChecklistItem
|
||||
return err
|
||||
}
|
||||
|
||||
const getProjectIDForTaskChecklist = `-- name: GetProjectIDForTaskChecklist :one
|
||||
SELECT project_id FROM task_checklist
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE task_checklist.task_checklist_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectIDForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectIDForTaskChecklist, taskChecklistID)
|
||||
var project_id uuid.UUID
|
||||
err := row.Scan(&project_id)
|
||||
return project_id, err
|
||||
}
|
||||
|
||||
const getProjectIDForTaskChecklistItem = `-- name: GetProjectIDForTaskChecklistItem :one
|
||||
SELECT project_id FROM task_checklist_item AS tci
|
||||
INNER JOIN task_checklist ON task_checklist.task_checklist_id = tci.task_checklist_id
|
||||
INNER JOIN task ON task.task_id = task_checklist.task_id
|
||||
INNER JOIN task_group ON task_group.task_group_id = task.task_group_id
|
||||
WHERE tci.task_checklist_item_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectIDForTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectIDForTaskChecklistItem, taskChecklistItemID)
|
||||
var project_id uuid.UUID
|
||||
err := row.Scan(&project_id)
|
||||
return project_id, err
|
||||
}
|
||||
|
||||
const getTaskChecklistByID = `-- name: GetTaskChecklistByID :one
|
||||
SELECT task_checklist_id, task_id, created_at, name, position FROM task_checklist WHERE task_checklist_id = $1
|
||||
`
|
||||
|
@ -85,6 +85,17 @@ func (q *Queries) GetAllTaskGroups(ctx context.Context) ([]TaskGroup, error) {
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getProjectIDForTaskGroup = `-- name: GetProjectIDForTaskGroup :one
|
||||
SELECT project_id from task_group WHERE task_group_id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetProjectIDForTaskGroup(ctx context.Context, taskGroupID uuid.UUID) (uuid.UUID, error) {
|
||||
row := q.db.QueryRowContext(ctx, getProjectIDForTaskGroup, taskGroupID)
|
||||
var project_id uuid.UUID
|
||||
err := row.Scan(&project_id)
|
||||
return project_id, err
|
||||
}
|
||||
|
||||
const getTaskGroupByID = `-- name: GetTaskGroupByID :one
|
||||
SELECT task_group_id, project_id, created_at, name, position FROM task_group WHERE task_group_id = $1
|
||||
`
|
||||
|
@ -11,6 +11,39 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createInvitedProjectMember = `-- name: CreateInvitedProjectMember :one
|
||||
INSERT INTO project_member_invited (project_id, user_account_invited_id) VALUES ($1, $2)
|
||||
RETURNING project_member_invited_id, project_id, user_account_invited_id
|
||||
`
|
||||
|
||||
type CreateInvitedProjectMemberParams struct {
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
UserAccountInvitedID uuid.UUID `json:"user_account_invited_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateInvitedProjectMember(ctx context.Context, arg CreateInvitedProjectMemberParams) (ProjectMemberInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, createInvitedProjectMember, arg.ProjectID, arg.UserAccountInvitedID)
|
||||
var i ProjectMemberInvited
|
||||
err := row.Scan(&i.ProjectMemberInvitedID, &i.ProjectID, &i.UserAccountInvitedID)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createInvitedUser = `-- name: CreateInvitedUser :one
|
||||
INSERT INTO user_account_invited (email) VALUES ($1) RETURNING user_account_invited_id, email, invited_on, has_joined
|
||||
`
|
||||
|
||||
func (q *Queries) CreateInvitedUser(ctx context.Context, email string) (UserAccountInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, createInvitedUser, email)
|
||||
var i UserAccountInvited
|
||||
err := row.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createUserAccount = `-- name: CreateUserAccount :one
|
||||
INSERT INTO user_account(full_name, initials, email, username, created_at, password_hash, role_code)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio
|
||||
@ -53,6 +86,22 @@ func (q *Queries) CreateUserAccount(ctx context.Context, arg CreateUserAccountPa
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteInvitedUserAccount = `-- name: DeleteInvitedUserAccount :one
|
||||
DELETE FROM user_account_invited WHERE user_account_invited_id = $1 RETURNING user_account_invited_id, email, invited_on, has_joined
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteInvitedUserAccount(ctx context.Context, userAccountInvitedID uuid.UUID) (UserAccountInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, deleteInvitedUserAccount, userAccountInvitedID)
|
||||
var i UserAccountInvited
|
||||
err := row.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteUserAccountByID = `-- name: DeleteUserAccountByID :exec
|
||||
DELETE FROM user_account WHERE user_id = $1
|
||||
`
|
||||
@ -101,6 +150,95 @@ func (q *Queries) GetAllUserAccounts(ctx context.Context) ([]UserAccount, error)
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getInvitedUserAccounts = `-- name: GetInvitedUserAccounts :many
|
||||
SELECT user_account_invited_id, email, invited_on, has_joined FROM user_account_invited
|
||||
`
|
||||
|
||||
func (q *Queries) GetInvitedUserAccounts(ctx context.Context) ([]UserAccountInvited, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getInvitedUserAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []UserAccountInvited
|
||||
for rows.Next() {
|
||||
var i UserAccountInvited
|
||||
if err := rows.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getInvitedUserByEmail = `-- name: GetInvitedUserByEmail :one
|
||||
SELECT user_account_invited_id, email, invited_on, has_joined FROM user_account_invited WHERE email = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetInvitedUserByEmail(ctx context.Context, email string) (UserAccountInvited, error) {
|
||||
row := q.db.QueryRowContext(ctx, getInvitedUserByEmail, email)
|
||||
var i UserAccountInvited
|
||||
err := row.Scan(
|
||||
&i.UserAccountInvitedID,
|
||||
&i.Email,
|
||||
&i.InvitedOn,
|
||||
&i.HasJoined,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getMemberData = `-- name: GetMemberData :many
|
||||
SELECT user_id, created_at, email, username, password_hash, profile_bg_color, full_name, initials, profile_avatar_url, role_code, bio FROM user_account
|
||||
WHERE username != 'system'
|
||||
AND user_id NOT IN (SELECT user_id FROM project_member WHERE project_id = $1)
|
||||
`
|
||||
|
||||
func (q *Queries) GetMemberData(ctx context.Context, projectID uuid.UUID) ([]UserAccount, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getMemberData, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []UserAccount
|
||||
for rows.Next() {
|
||||
var i UserAccount
|
||||
if err := rows.Scan(
|
||||
&i.UserID,
|
||||
&i.CreatedAt,
|
||||
&i.Email,
|
||||
&i.Username,
|
||||
&i.PasswordHash,
|
||||
&i.ProfileBgColor,
|
||||
&i.FullName,
|
||||
&i.Initials,
|
||||
&i.ProfileAvatarUrl,
|
||||
&i.RoleCode,
|
||||
&i.Bio,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getRoleForUserID = `-- name: GetRoleForUserID :one
|
||||
SELECT username, role.code, role.name FROM user_account
|
||||
INNER JOIN role ON role.code = user_account.role_code
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,10 +2,12 @@ package graph
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
@ -17,8 +19,10 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/jordanknott/taskcafe/internal/auth"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/logger"
|
||||
"github.com/jordanknott/taskcafe/internal/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
)
|
||||
|
||||
// NewHandler returns a new graphql endpoint handler.
|
||||
@ -51,33 +55,77 @@ func NewHandler(repo db.Repository) http.Handler {
|
||||
fieldName = "TeamID"
|
||||
case ObjectTypeTask:
|
||||
fieldName = "TaskID"
|
||||
case ObjectTypeTaskGroup:
|
||||
fieldName = "TaskGroupID"
|
||||
case ObjectTypeTaskChecklist:
|
||||
fieldName = "TaskChecklistID"
|
||||
case ObjectTypeTaskChecklistItem:
|
||||
fieldName = "TaskChecklistItemID"
|
||||
default:
|
||||
fieldName = "ProjectID"
|
||||
}
|
||||
log.WithFields(log.Fields{"typeArg": typeArg, "fieldName": fieldName}).Info("getting field by name")
|
||||
subjectID, ok = val.FieldByName(fieldName).Interface().(uuid.UUID)
|
||||
logger.New(ctx).WithFields(log.Fields{"typeArg": typeArg, "fieldName": fieldName}).Info("getting field by name")
|
||||
subjectField := val.FieldByName(fieldName)
|
||||
if !subjectField.IsValid() {
|
||||
logger.New(ctx).Error("subject field name does not exist on input type")
|
||||
return nil, errors.New("subject field name does not exist on input type")
|
||||
}
|
||||
if fieldName == "TeamID" && subjectField.IsNil() {
|
||||
// Is a personal project, no check
|
||||
// TODO: add config setting to disable personal projects
|
||||
return next(ctx)
|
||||
}
|
||||
subjectID, ok = subjectField.Interface().(uuid.UUID)
|
||||
if !ok {
|
||||
logger.New(ctx).Error("error while casting subject UUID")
|
||||
return nil, errors.New("error while casting subject uuid")
|
||||
}
|
||||
|
||||
var err error
|
||||
if level == ActionLevelProject {
|
||||
logger.New(ctx).WithFields(log.Fields{"subjectID": subjectID}).Info("fetching subject ID by typeArg")
|
||||
if typeArg == ObjectTypeTask {
|
||||
log.WithFields(log.Fields{"subjectID": subjectID}).Info("fetching project ID using task ID")
|
||||
subjectID, err = repo.GetProjectIDForTask(ctx, subjectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
roles, err := GetProjectRoles(ctx, repo, subjectID)
|
||||
if typeArg == ObjectTypeTaskGroup {
|
||||
subjectID, err = repo.GetProjectIDForTaskGroup(ctx, subjectID)
|
||||
}
|
||||
if typeArg == ObjectTypeTaskChecklist {
|
||||
subjectID, err = repo.GetProjectIDForTaskChecklist(ctx, subjectID)
|
||||
}
|
||||
if typeArg == ObjectTypeTaskChecklistItem {
|
||||
subjectID, err = repo.GetProjectIDForTaskChecklistItem(ctx, subjectID)
|
||||
}
|
||||
if err != nil {
|
||||
logger.New(ctx).WithError(err).Error("error while getting subject ID")
|
||||
return nil, err
|
||||
}
|
||||
if roles.TeamRole == "admin" || roles.ProjectRole == "admin" {
|
||||
log.WithFields(log.Fields{"teamRole": roles.TeamRole, "projectRole": roles.ProjectRole}).Info("is team or project role")
|
||||
return next(ctx)
|
||||
projectRoles, err := GetProjectRoles(ctx, repo, subjectID)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, &gqlerror.Error{
|
||||
Message: "not authorized",
|
||||
Extensions: map[string]interface{}{
|
||||
"code": "401",
|
||||
},
|
||||
}
|
||||
}
|
||||
logger.New(ctx).WithError(err).Error("error while getting project roles")
|
||||
return nil, err
|
||||
}
|
||||
for _, validRole := range roles {
|
||||
logger.New(ctx).WithFields(log.Fields{"validRole": validRole}).Info("checking role")
|
||||
if CompareRoleLevel(projectRoles.TeamRole, validRole) || CompareRoleLevel(projectRoles.ProjectRole, validRole) {
|
||||
logger.New(ctx).WithFields(log.Fields{"teamRole": projectRoles.TeamRole, "projectRole": projectRoles.ProjectRole}).Info("is team or project role")
|
||||
return next(ctx)
|
||||
}
|
||||
}
|
||||
return nil, &gqlerror.Error{
|
||||
Message: "not authorized",
|
||||
Extensions: map[string]interface{}{
|
||||
"code": "401",
|
||||
},
|
||||
}
|
||||
return nil, errors.New("must be a team or project admin")
|
||||
} else if level == ActionLevelTeam {
|
||||
userID, ok := GetUserID(ctx)
|
||||
if !ok {
|
||||
@ -85,15 +133,28 @@ func NewHandler(repo db.Repository) http.Handler {
|
||||
}
|
||||
role, err := repo.GetTeamRoleForUserID(ctx, db.GetTeamRoleForUserIDParams{UserID: userID, TeamID: subjectID})
|
||||
if err != nil {
|
||||
logger.New(ctx).WithError(err).Error("error while getting team roles for user ID")
|
||||
return nil, err
|
||||
}
|
||||
if role.RoleCode == "admin" {
|
||||
return next(ctx)
|
||||
for _, validRole := range roles {
|
||||
if CompareRoleLevel(role.RoleCode, validRole) || CompareRoleLevel(role.RoleCode, validRole) {
|
||||
return next(ctx)
|
||||
}
|
||||
}
|
||||
return nil, &gqlerror.Error{
|
||||
Message: "not authorized",
|
||||
Extensions: map[string]interface{}{
|
||||
"code": "401",
|
||||
},
|
||||
}
|
||||
return nil, errors.New("must be a team admin")
|
||||
|
||||
}
|
||||
return nil, errors.New("invalid path")
|
||||
return nil, &gqlerror.Error{
|
||||
Message: "bad path",
|
||||
Extensions: map[string]interface{}{
|
||||
"code": "500",
|
||||
},
|
||||
}
|
||||
}
|
||||
srv := handler.New(NewExecutableSchema(c))
|
||||
srv.AddTransport(transport.Websocket{
|
||||
@ -156,6 +217,14 @@ func GetProjectRoles(ctx context.Context, r db.Repository, projectID uuid.UUID)
|
||||
return r.GetUserRolesForProject(ctx, db.GetUserRolesForProjectParams{UserID: userID, ProjectID: projectID})
|
||||
}
|
||||
|
||||
// CompareRoleLevel compares a string against a role level
|
||||
func CompareRoleLevel(a string, b RoleLevel) bool {
|
||||
if strings.ToLower(a) == strings.ToLower(b.String()) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ConvertToRoleCode converts a role code string to a RoleCode type
|
||||
func ConvertToRoleCode(r string) RoleCode {
|
||||
if r == RoleCodeAdmin.String() {
|
||||
|
@ -27,16 +27,6 @@ type ChecklistBadge struct {
|
||||
Total int `json:"total"`
|
||||
}
|
||||
|
||||
type CreateProjectMember struct {
|
||||
ProjectID uuid.UUID `json:"projectID"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
}
|
||||
|
||||
type CreateProjectMemberPayload struct {
|
||||
Ok bool `json:"ok"`
|
||||
Member *Member `json:"member"`
|
||||
}
|
||||
|
||||
type CreateTaskChecklist struct {
|
||||
TaskID uuid.UUID `json:"taskID"`
|
||||
Name string `json:"name"`
|
||||
@ -59,6 +49,23 @@ type CreateTeamMemberPayload struct {
|
||||
TeamMember *Member `json:"teamMember"`
|
||||
}
|
||||
|
||||
type DeleteInvitedProjectMember struct {
|
||||
ProjectID uuid.UUID `json:"projectID"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
type DeleteInvitedProjectMemberPayload struct {
|
||||
InvitedMember *InvitedMember `json:"invitedMember"`
|
||||
}
|
||||
|
||||
type DeleteInvitedUserAccount struct {
|
||||
InvitedUserID uuid.UUID `json:"invitedUserID"`
|
||||
}
|
||||
|
||||
type DeleteInvitedUserAccountPayload struct {
|
||||
InvitedUser *InvitedUserAccount `json:"invitedUser"`
|
||||
}
|
||||
|
||||
type DeleteProject struct {
|
||||
ProjectID uuid.UUID `json:"projectID"`
|
||||
}
|
||||
@ -121,11 +128,11 @@ type DeleteTaskGroupTasksPayload struct {
|
||||
}
|
||||
|
||||
type DeleteTaskInput struct {
|
||||
TaskID string `json:"taskID"`
|
||||
TaskID uuid.UUID `json:"taskID"`
|
||||
}
|
||||
|
||||
type DeleteTaskPayload struct {
|
||||
TaskID string `json:"taskID"`
|
||||
TaskID uuid.UUID `json:"taskID"`
|
||||
}
|
||||
|
||||
type DeleteTeam struct {
|
||||
@ -184,11 +191,35 @@ type FindTeam struct {
|
||||
}
|
||||
|
||||
type FindUser struct {
|
||||
UserID string `json:"userId"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
}
|
||||
|
||||
type InviteProjectMembers struct {
|
||||
ProjectID uuid.UUID `json:"projectID"`
|
||||
Members []MemberInvite `json:"members"`
|
||||
}
|
||||
|
||||
type InviteProjectMembersPayload struct {
|
||||
Ok bool `json:"ok"`
|
||||
ProjectID uuid.UUID `json:"projectID"`
|
||||
Members []Member `json:"members"`
|
||||
InvitedMembers []InvitedMember `json:"invitedMembers"`
|
||||
}
|
||||
|
||||
type InvitedMember struct {
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invitedOn"`
|
||||
}
|
||||
|
||||
type InvitedUserAccount struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Email string `json:"email"`
|
||||
InvitedOn time.Time `json:"invitedOn"`
|
||||
Member *MemberList `json:"member"`
|
||||
}
|
||||
|
||||
type LogoutUser struct {
|
||||
UserID string `json:"userID"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
}
|
||||
|
||||
type MePayload struct {
|
||||
@ -207,15 +238,31 @@ type Member struct {
|
||||
Member *MemberList `json:"member"`
|
||||
}
|
||||
|
||||
type MemberInvite struct {
|
||||
UserID *uuid.UUID `json:"userID"`
|
||||
Email *string `json:"email"`
|
||||
}
|
||||
|
||||
type MemberList struct {
|
||||
Teams []db.Team `json:"teams"`
|
||||
Projects []db.Project `json:"projects"`
|
||||
}
|
||||
|
||||
type MemberSearchFilter struct {
|
||||
SearchFilter string `json:"searchFilter"`
|
||||
ProjectID *uuid.UUID `json:"projectID"`
|
||||
}
|
||||
|
||||
type MemberSearchResult struct {
|
||||
Similarity int `json:"similarity"`
|
||||
ID string `json:"id"`
|
||||
User *db.UserAccount `json:"user"`
|
||||
Status ShareStatus `json:"status"`
|
||||
}
|
||||
|
||||
type NewProject struct {
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
TeamID uuid.UUID `json:"teamID"`
|
||||
Name string `json:"name"`
|
||||
TeamID *uuid.UUID `json:"teamID"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type NewProjectLabel struct {
|
||||
@ -225,19 +272,19 @@ type NewProjectLabel struct {
|
||||
}
|
||||
|
||||
type NewRefreshToken struct {
|
||||
UserID string `json:"userId"`
|
||||
UserID uuid.UUID `json:"userID"`
|
||||
}
|
||||
|
||||
type NewTask struct {
|
||||
TaskGroupID string `json:"taskGroupID"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
TaskGroupID uuid.UUID `json:"taskGroupID"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type NewTaskGroup struct {
|
||||
ProjectID string `json:"projectID"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
ProjectID uuid.UUID `json:"projectID"`
|
||||
Name string `json:"name"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type NewTaskGroupLocation struct {
|
||||
@ -303,6 +350,7 @@ type ProjectsFilter struct {
|
||||
}
|
||||
|
||||
type RemoveTaskLabelInput struct {
|
||||
TaskID uuid.UUID `json:"taskID"`
|
||||
TaskLabelID uuid.UUID `json:"taskLabelID"`
|
||||
}
|
||||
|
||||
@ -388,13 +436,13 @@ type UpdateProjectName struct {
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemLocation struct {
|
||||
ChecklistID uuid.UUID `json:"checklistID"`
|
||||
ChecklistItemID uuid.UUID `json:"checklistItemID"`
|
||||
Position float64 `json:"position"`
|
||||
TaskChecklistID uuid.UUID `json:"taskChecklistID"`
|
||||
TaskChecklistItemID uuid.UUID `json:"taskChecklistItemID"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemLocationPayload struct {
|
||||
ChecklistID uuid.UUID `json:"checklistID"`
|
||||
TaskChecklistID uuid.UUID `json:"taskChecklistID"`
|
||||
PrevChecklistID uuid.UUID `json:"prevChecklistID"`
|
||||
ChecklistItem *db.TaskChecklistItem `json:"checklistItem"`
|
||||
}
|
||||
@ -405,8 +453,8 @@ type UpdateTaskChecklistItemName struct {
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistLocation struct {
|
||||
ChecklistID uuid.UUID `json:"checklistID"`
|
||||
Position float64 `json:"position"`
|
||||
TaskChecklistID uuid.UUID `json:"taskChecklistID"`
|
||||
Position float64 `json:"position"`
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistLocationPayload struct {
|
||||
@ -439,8 +487,8 @@ type UpdateTaskLocationPayload struct {
|
||||
}
|
||||
|
||||
type UpdateTaskName struct {
|
||||
TaskID string `json:"taskID"`
|
||||
Name string `json:"name"`
|
||||
TaskID uuid.UUID `json:"taskID"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type UpdateTeamMemberRole struct {
|
||||
@ -648,10 +696,13 @@ func (e EntityType) MarshalGQL(w io.Writer) {
|
||||
type ObjectType string
|
||||
|
||||
const (
|
||||
ObjectTypeOrg ObjectType = "ORG"
|
||||
ObjectTypeTeam ObjectType = "TEAM"
|
||||
ObjectTypeProject ObjectType = "PROJECT"
|
||||
ObjectTypeTask ObjectType = "TASK"
|
||||
ObjectTypeOrg ObjectType = "ORG"
|
||||
ObjectTypeTeam ObjectType = "TEAM"
|
||||
ObjectTypeProject ObjectType = "PROJECT"
|
||||
ObjectTypeTask ObjectType = "TASK"
|
||||
ObjectTypeTaskGroup ObjectType = "TASK_GROUP"
|
||||
ObjectTypeTaskChecklist ObjectType = "TASK_CHECKLIST"
|
||||
ObjectTypeTaskChecklistItem ObjectType = "TASK_CHECKLIST_ITEM"
|
||||
)
|
||||
|
||||
var AllObjectType = []ObjectType{
|
||||
@ -659,11 +710,14 @@ var AllObjectType = []ObjectType{
|
||||
ObjectTypeTeam,
|
||||
ObjectTypeProject,
|
||||
ObjectTypeTask,
|
||||
ObjectTypeTaskGroup,
|
||||
ObjectTypeTaskChecklist,
|
||||
ObjectTypeTaskChecklistItem,
|
||||
}
|
||||
|
||||
func (e ObjectType) IsValid() bool {
|
||||
switch e {
|
||||
case ObjectTypeOrg, ObjectTypeTeam, ObjectTypeProject, ObjectTypeTask:
|
||||
case ObjectTypeOrg, ObjectTypeTeam, ObjectTypeProject, ObjectTypeTask, ObjectTypeTaskGroup, ObjectTypeTaskChecklist, ObjectTypeTaskChecklistItem:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -775,3 +829,44 @@ func (e *RoleLevel) UnmarshalGQL(v interface{}) error {
|
||||
func (e RoleLevel) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type ShareStatus string
|
||||
|
||||
const (
|
||||
ShareStatusInvited ShareStatus = "INVITED"
|
||||
ShareStatusJoined ShareStatus = "JOINED"
|
||||
)
|
||||
|
||||
var AllShareStatus = []ShareStatus{
|
||||
ShareStatusInvited,
|
||||
ShareStatusJoined,
|
||||
}
|
||||
|
||||
func (e ShareStatus) IsValid() bool {
|
||||
switch e {
|
||||
case ShareStatusInvited, ShareStatusJoined:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e ShareStatus) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *ShareStatus) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = ShareStatus(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid ShareStatus", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e ShareStatus) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
@ -86,6 +86,13 @@ type UserAccount {
|
||||
member: MemberList!
|
||||
}
|
||||
|
||||
type InvitedUserAccount {
|
||||
id: ID!
|
||||
email: String!
|
||||
invitedOn: Time!
|
||||
member: MemberList!
|
||||
}
|
||||
|
||||
type Team {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
@ -93,13 +100,20 @@ type Team {
|
||||
members: [Member!]!
|
||||
}
|
||||
|
||||
|
||||
type InvitedMember {
|
||||
email: String!
|
||||
invitedOn: Time!
|
||||
}
|
||||
|
||||
type Project {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
name: String!
|
||||
team: Team!
|
||||
team: Team
|
||||
taskGroups: [TaskGroup!]!
|
||||
members: [Member!]!
|
||||
invitedMembers: [InvitedMember!]!
|
||||
labels: [ProjectLabel!]!
|
||||
}
|
||||
|
||||
@ -158,6 +172,11 @@ type TaskChecklist {
|
||||
items: [TaskChecklistItem!]!
|
||||
}
|
||||
|
||||
enum ShareStatus {
|
||||
INVITED
|
||||
JOINED
|
||||
}
|
||||
|
||||
enum RoleLevel {
|
||||
ADMIN
|
||||
MEMBER
|
||||
@ -174,6 +193,9 @@ enum ObjectType {
|
||||
TEAM
|
||||
PROJECT
|
||||
TASK
|
||||
TASK_GROUP
|
||||
TASK_CHECKLIST
|
||||
TASK_CHECKLIST_ITEM
|
||||
}
|
||||
|
||||
directive @hasRole(roles: [RoleLevel!]!, level: ActionLevel!, type: ObjectType!) on FIELD_DEFINITION
|
||||
@ -181,8 +203,10 @@ directive @hasRole(roles: [RoleLevel!]!, level: ActionLevel!, type: ObjectType!)
|
||||
type Query {
|
||||
organizations: [Organization!]!
|
||||
users: [UserAccount!]!
|
||||
invitedUsers: [InvitedUserAccount!]!
|
||||
findUser(input: FindUser!): UserAccount!
|
||||
findProject(input: FindProject!): Project!
|
||||
findProject(input: FindProject!):
|
||||
Project! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
findTask(input: FindTask!): Task!
|
||||
projects(input: ProjectsFilter): [Project!]!
|
||||
findTeam(input: FindTeam!): Team!
|
||||
@ -215,7 +239,7 @@ input ProjectsFilter {
|
||||
}
|
||||
|
||||
input FindUser {
|
||||
userId: String!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
input FindProject {
|
||||
@ -276,8 +300,7 @@ extend type Mutation {
|
||||
}
|
||||
|
||||
input NewProject {
|
||||
userID: UUID!
|
||||
teamID: UUID!
|
||||
teamID: UUID
|
||||
name: String!
|
||||
}
|
||||
|
||||
@ -297,15 +320,15 @@ type DeleteProjectPayload {
|
||||
|
||||
extend type Mutation {
|
||||
createProjectLabel(input: NewProjectLabel!):
|
||||
ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
deleteProjectLabel(input: DeleteProjectLabel!):
|
||||
ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
updateProjectLabel(input: UpdateProjectLabel!):
|
||||
ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
updateProjectLabelName(input: UpdateProjectLabelName!):
|
||||
ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
updateProjectLabelColor(input: UpdateProjectLabelColor!):
|
||||
ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
}
|
||||
|
||||
input NewProjectLabel {
|
||||
@ -335,22 +358,41 @@ input UpdateProjectLabelColor {
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
createProjectMember(input: CreateProjectMember!):
|
||||
CreateProjectMemberPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
inviteProjectMembers(input: InviteProjectMembers!):
|
||||
InviteProjectMembersPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
deleteProjectMember(input: DeleteProjectMember!):
|
||||
DeleteProjectMemberPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
updateProjectMemberRole(input: UpdateProjectMemberRole!):
|
||||
UpdateProjectMemberRolePayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
|
||||
deleteInvitedProjectMember(input: DeleteInvitedProjectMember!):
|
||||
DeleteInvitedProjectMemberPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
}
|
||||
|
||||
input CreateProjectMember {
|
||||
input DeleteInvitedProjectMember {
|
||||
projectID: UUID!
|
||||
userID: UUID!
|
||||
email: String!
|
||||
}
|
||||
|
||||
type CreateProjectMemberPayload {
|
||||
type DeleteInvitedProjectMemberPayload {
|
||||
invitedMember: InvitedMember!
|
||||
}
|
||||
|
||||
input MemberInvite {
|
||||
userID: UUID
|
||||
email: String
|
||||
}
|
||||
|
||||
input InviteProjectMembers {
|
||||
projectID: UUID!
|
||||
members: [MemberInvite!]!
|
||||
}
|
||||
|
||||
type InviteProjectMembersPayload {
|
||||
ok: Boolean!
|
||||
member: Member!
|
||||
projectID: UUID!
|
||||
members: [Member!]!
|
||||
invitedMembers: [InvitedMember!]!
|
||||
}
|
||||
|
||||
input DeleteProjectMember {
|
||||
@ -377,29 +419,29 @@ type UpdateProjectMemberRolePayload {
|
||||
|
||||
extend type Mutation {
|
||||
createTask(input: NewTask!):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP)
|
||||
deleteTask(input: DeleteTaskInput!):
|
||||
DeleteTaskPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
DeleteTaskPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
|
||||
updateTaskDescription(input: UpdateTaskDescriptionInput!):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
updateTaskLocation(input: NewTaskLocation!):
|
||||
UpdateTaskLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
UpdateTaskLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
updateTaskName(input: UpdateTaskName!):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
setTaskComplete(input: SetTaskComplete!):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
updateTaskDueDate(input: UpdateTaskDueDate!):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
|
||||
assignTask(input: AssignTaskInput):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK)
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
unassignTask(input: UnassignTaskInput):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK)
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
}
|
||||
|
||||
input NewTask {
|
||||
taskGroupID: String!
|
||||
taskGroupID: UUID!
|
||||
name: String!
|
||||
position: Float!
|
||||
}
|
||||
@ -441,54 +483,55 @@ input NewTaskLocation {
|
||||
}
|
||||
|
||||
input DeleteTaskInput {
|
||||
taskID: String!
|
||||
taskID: UUID!
|
||||
}
|
||||
|
||||
type DeleteTaskPayload {
|
||||
taskID: String!
|
||||
taskID: UUID!
|
||||
}
|
||||
|
||||
input UpdateTaskName {
|
||||
taskID: String!
|
||||
taskID: UUID!
|
||||
name: String!
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
createTaskChecklist(input: CreateTaskChecklist!):
|
||||
TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
deleteTaskChecklist(input: DeleteTaskChecklist!):
|
||||
DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST)
|
||||
updateTaskChecklistName(input: UpdateTaskChecklistName!):
|
||||
TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST)
|
||||
createTaskChecklistItem(input: CreateTaskChecklistItem!):
|
||||
TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!):
|
||||
TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!):
|
||||
TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
deleteTaskChecklistItem(input: DeleteTaskChecklistItem!):
|
||||
DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST)
|
||||
updateTaskChecklistLocation(input: UpdateTaskChecklistLocation!):
|
||||
UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST)
|
||||
|
||||
updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!):
|
||||
TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM)
|
||||
setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!):
|
||||
TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM)
|
||||
deleteTaskChecklistItem(input: DeleteTaskChecklistItem!):
|
||||
DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM)
|
||||
updateTaskChecklistItemLocation(input: UpdateTaskChecklistItemLocation!):
|
||||
UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM)
|
||||
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistItemLocation {
|
||||
checklistID: UUID!
|
||||
checklistItemID: UUID!
|
||||
taskChecklistID: UUID!
|
||||
taskChecklistItemID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
type UpdateTaskChecklistItemLocationPayload {
|
||||
checklistID: UUID!
|
||||
taskChecklistID: UUID!
|
||||
prevChecklistID: UUID!
|
||||
checklistItem: TaskChecklistItem!
|
||||
}
|
||||
|
||||
input UpdateTaskChecklistLocation {
|
||||
checklistID: UUID!
|
||||
taskChecklistID: UUID!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
@ -541,19 +584,19 @@ type DeleteTaskChecklistPayload {
|
||||
|
||||
extend type Mutation {
|
||||
createTaskGroup(input: NewTaskGroup!):
|
||||
TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
updateTaskGroupLocation(input: NewTaskGroupLocation!):
|
||||
TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP)
|
||||
updateTaskGroupName(input: UpdateTaskGroupName!):
|
||||
TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP)
|
||||
deleteTaskGroup(input: DeleteTaskGroupInput!):
|
||||
DeleteTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
DeleteTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP)
|
||||
duplicateTaskGroup(input: DuplicateTaskGroup!):
|
||||
DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP)
|
||||
sortTaskGroup(input: SortTaskGroup!):
|
||||
SortTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
SortTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP)
|
||||
deleteTaskGroupTasks(input: DeleteTaskGroupTasks!):
|
||||
DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP)
|
||||
}
|
||||
|
||||
input DeleteTaskGroupTasks {
|
||||
@ -612,19 +655,31 @@ type DeleteTaskGroupPayload {
|
||||
}
|
||||
|
||||
input NewTaskGroup {
|
||||
projectID: String!
|
||||
projectID: UUID!
|
||||
name: String!
|
||||
position: Float!
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
addTaskLabel(input: AddTaskLabelInput):
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
removeTaskLabel(input: RemoveTaskLabelInput):
|
||||
Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
toggleTaskLabel(input: ToggleTaskLabelInput!):
|
||||
ToggleTaskLabelPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK)
|
||||
|
||||
}
|
||||
|
||||
input AddTaskLabelInput {
|
||||
taskID: UUID!
|
||||
projectLabelID: UUID!
|
||||
}
|
||||
|
||||
input RemoveTaskLabelInput {
|
||||
taskID: UUID!
|
||||
taskLabelID: UUID!
|
||||
}
|
||||
|
||||
input ToggleTaskLabelInput {
|
||||
taskID: UUID!
|
||||
projectLabelID: UUID!
|
||||
@ -634,15 +689,6 @@ type ToggleTaskLabelPayload {
|
||||
active: Boolean!
|
||||
task: Task!
|
||||
}
|
||||
extend type Mutation {
|
||||
addTaskLabel(input: AddTaskLabelInput):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
removeTaskLabel(input: RemoveTaskLabelInput):
|
||||
Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
toggleTaskLabel(input: ToggleTaskLabelInput!):
|
||||
ToggleTaskLabelPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT)
|
||||
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
deleteTeam(input: DeleteTeam!):
|
||||
@ -716,6 +762,8 @@ extend type Mutation {
|
||||
UserAccount! @hasRole(roles: [ADMIN], level: ORG, type: ORG)
|
||||
deleteUserAccount(input: DeleteUserAccount!):
|
||||
DeleteUserAccountPayload! @hasRole(roles: [ADMIN], level: ORG, type: ORG)
|
||||
deleteInvitedUserAccount(input: DeleteInvitedUserAccount!):
|
||||
DeleteInvitedUserAccountPayload! @hasRole(roles: [ADMIN], level: ORG, type: ORG)
|
||||
|
||||
logoutUser(input: LogoutUser!): Boolean!
|
||||
clearProfileAvatar: UserAccount!
|
||||
@ -727,6 +775,31 @@ extend type Mutation {
|
||||
UpdateUserInfoPayload! @hasRole(roles: [ADMIN], level: ORG, type: ORG)
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
searchMembers(input: MemberSearchFilter!): [MemberSearchResult!]!
|
||||
}
|
||||
|
||||
input DeleteInvitedUserAccount {
|
||||
invitedUserID: UUID!
|
||||
}
|
||||
|
||||
type DeleteInvitedUserAccountPayload {
|
||||
invitedUser: InvitedUserAccount!
|
||||
}
|
||||
|
||||
input MemberSearchFilter {
|
||||
searchFilter: String!
|
||||
projectID: UUID
|
||||
}
|
||||
|
||||
|
||||
type MemberSearchResult {
|
||||
similarity: Int!
|
||||
id: String!
|
||||
user: UserAccount
|
||||
status: ShareStatus!
|
||||
}
|
||||
|
||||
type UpdateUserInfoPayload {
|
||||
user: UserAccount!
|
||||
}
|
||||
@ -758,7 +831,7 @@ type UpdateUserRolePayload {
|
||||
}
|
||||
|
||||
input NewRefreshToken {
|
||||
userId: String!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
input NewUserAccount {
|
||||
@ -771,7 +844,7 @@ input NewUserAccount {
|
||||
}
|
||||
|
||||
input LogoutUser {
|
||||
userID: String!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
input DeleteUserAccount {
|
||||
@ -783,3 +856,4 @@ type DeleteUserAccountPayload {
|
||||
ok: Boolean!
|
||||
userAccount: UserAccount!
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/jordanknott/taskcafe/internal/auth"
|
||||
"github.com/jordanknott/taskcafe/internal/db"
|
||||
"github.com/jordanknott/taskcafe/internal/logger"
|
||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/vektah/gqlparser/v2/gqlerror"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@ -23,10 +25,41 @@ func (r *labelColorResolver) ID(ctx context.Context, obj *db.LabelColor) (uuid.U
|
||||
}
|
||||
|
||||
func (r *mutationResolver) CreateProject(ctx context.Context, input NewProject) (*db.Project, error) {
|
||||
userID, ok := GetUserID(ctx)
|
||||
if !ok {
|
||||
return &db.Project{}, errors.New("user id is missing")
|
||||
}
|
||||
createdAt := time.Now().UTC()
|
||||
log.WithFields(log.Fields{"userID": input.UserID, "name": input.Name, "teamID": input.TeamID}).Info("creating new project")
|
||||
project, err := r.Repository.CreateProject(ctx, db.CreateProjectParams{input.TeamID, createdAt, input.Name})
|
||||
return &project, err
|
||||
logger.New(ctx).WithFields(log.Fields{"name": input.Name, "teamID": input.TeamID}).Info("creating new project")
|
||||
var project db.Project
|
||||
var err error
|
||||
if input.TeamID == nil {
|
||||
project, err = r.Repository.CreatePersonalProject(ctx, db.CreatePersonalProjectParams{
|
||||
CreatedAt: createdAt,
|
||||
Name: input.Name,
|
||||
})
|
||||
if err != nil {
|
||||
logger.New(ctx).WithError(err).Error("error while creating project")
|
||||
return &db.Project{}, err
|
||||
}
|
||||
logger.New(ctx).WithField("projectID", project.ProjectID).Info("creating personal project link")
|
||||
} else {
|
||||
project, err = r.Repository.CreateTeamProject(ctx, db.CreateTeamProjectParams{
|
||||
CreatedAt: createdAt,
|
||||
Name: input.Name,
|
||||
TeamID: *input.TeamID,
|
||||
})
|
||||
if err != nil {
|
||||
logger.New(ctx).WithError(err).Error("error while creating project")
|
||||
return &db.Project{}, err
|
||||
}
|
||||
}
|
||||
_, err = r.Repository.CreateProjectMember(ctx, db.CreateProjectMemberParams{ProjectID: project.ProjectID, UserID: userID, AddedAt: createdAt, RoleCode: "admin"})
|
||||
if err != nil {
|
||||
logger.New(ctx).WithError(err).Error("error while creating initial project member")
|
||||
return &db.Project{}, err
|
||||
}
|
||||
return &project, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) DeleteProject(ctx context.Context, input DeleteProject) (*DeleteProjectPayload, error) {
|
||||
@ -92,33 +125,87 @@ func (r *mutationResolver) UpdateProjectLabelColor(ctx context.Context, input Up
|
||||
return &label, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) CreateProjectMember(ctx context.Context, input CreateProjectMember) (*CreateProjectMemberPayload, error) {
|
||||
addedAt := time.Now().UTC()
|
||||
_, err := r.Repository.CreateProjectMember(ctx, db.CreateProjectMemberParams{ProjectID: input.ProjectID, UserID: input.UserID, AddedAt: addedAt, RoleCode: "member"})
|
||||
if err != nil {
|
||||
return &CreateProjectMemberPayload{Ok: false}, err
|
||||
}
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, input.UserID)
|
||||
if err != nil {
|
||||
return &CreateProjectMemberPayload{Ok: false}, err
|
||||
}
|
||||
var url *string
|
||||
if user.ProfileAvatarUrl.Valid {
|
||||
url = &user.ProfileAvatarUrl.String
|
||||
}
|
||||
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
|
||||
func (r *mutationResolver) InviteProjectMembers(ctx context.Context, input InviteProjectMembers) (*InviteProjectMembersPayload, error) {
|
||||
members := []Member{}
|
||||
invitedMembers := []InvitedMember{}
|
||||
for _, invitedMember := range input.Members {
|
||||
if invitedMember.Email != nil && invitedMember.UserID != nil {
|
||||
return &InviteProjectMembersPayload{Ok: false}, &gqlerror.Error{
|
||||
Message: "Both email and userID can not be used to invite a project member",
|
||||
Extensions: map[string]interface{}{
|
||||
"code": "403",
|
||||
},
|
||||
}
|
||||
} else if invitedMember.Email == nil && invitedMember.UserID == nil {
|
||||
return &InviteProjectMembersPayload{Ok: false}, &gqlerror.Error{
|
||||
Message: "Either email or userID must be set to invite a project member",
|
||||
Extensions: map[string]interface{}{
|
||||
"code": "403",
|
||||
},
|
||||
}
|
||||
}
|
||||
if invitedMember.UserID != nil {
|
||||
// Invite by user ID
|
||||
addedAt := time.Now().UTC()
|
||||
_, err := r.Repository.CreateProjectMember(ctx, db.CreateProjectMemberParams{ProjectID: input.ProjectID, UserID: *invitedMember.UserID, AddedAt: addedAt, RoleCode: "member"})
|
||||
if err != nil {
|
||||
return &InviteProjectMembersPayload{Ok: false}, err
|
||||
}
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, *invitedMember.UserID)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return &InviteProjectMembersPayload{Ok: false}, err
|
||||
|
||||
role, err := r.Repository.GetRoleForProjectMemberByUserID(ctx, db.GetRoleForProjectMemberByUserIDParams{UserID: input.UserID, ProjectID: input.ProjectID})
|
||||
if err != nil {
|
||||
return &CreateProjectMemberPayload{Ok: false}, err
|
||||
}
|
||||
var url *string
|
||||
if user.ProfileAvatarUrl.Valid {
|
||||
url = &user.ProfileAvatarUrl.String
|
||||
}
|
||||
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
|
||||
|
||||
role, err := r.Repository.GetRoleForProjectMemberByUserID(ctx, db.GetRoleForProjectMemberByUserIDParams{UserID: *invitedMember.UserID, ProjectID: input.ProjectID})
|
||||
if err != nil {
|
||||
return &InviteProjectMembersPayload{Ok: false}, err
|
||||
}
|
||||
members = append(members, Member{
|
||||
ID: *invitedMember.UserID,
|
||||
FullName: user.FullName,
|
||||
Username: user.Username,
|
||||
ProfileIcon: profileIcon,
|
||||
Role: &db.Role{Code: role.Code, Name: role.Name},
|
||||
})
|
||||
} else {
|
||||
// Invite by email
|
||||
|
||||
// if invited user does not exist, create entry
|
||||
invitedUser, err := r.Repository.GetInvitedUserByEmail(ctx, *invitedMember.Email)
|
||||
now := time.Now().UTC()
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
invitedUser, err = r.Repository.CreateInvitedUser(ctx, *invitedMember.Email)
|
||||
if err != nil {
|
||||
return &InviteProjectMembersPayload{Ok: false}, err
|
||||
}
|
||||
} else {
|
||||
return &InviteProjectMembersPayload{Ok: false}, err
|
||||
}
|
||||
}
|
||||
|
||||
_, err = r.Repository.CreateInvitedProjectMember(ctx, db.CreateInvitedProjectMemberParams{
|
||||
ProjectID: input.ProjectID,
|
||||
UserAccountInvitedID: invitedUser.UserAccountInvitedID,
|
||||
})
|
||||
if err != nil {
|
||||
return &InviteProjectMembersPayload{Ok: false}, err
|
||||
}
|
||||
logger.New(ctx).Info("adding invited member")
|
||||
invitedMembers = append(invitedMembers, InvitedMember{Email: *invitedMember.Email, InvitedOn: now})
|
||||
// send out invitation
|
||||
// add project invite entry
|
||||
// send out notification?
|
||||
|
||||
}
|
||||
}
|
||||
return &CreateProjectMemberPayload{Ok: true, Member: &Member{
|
||||
ID: input.UserID,
|
||||
FullName: user.FullName,
|
||||
Username: user.Username,
|
||||
ProfileIcon: profileIcon,
|
||||
Role: &db.Role{Code: role.Code, Name: role.Name},
|
||||
}}, nil
|
||||
return &InviteProjectMembersPayload{Ok: false, ProjectID: input.ProjectID, Members: members, InvitedMembers: invitedMembers}, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) DeleteProjectMember(ctx context.Context, input DeleteProjectMember) (*DeleteProjectMemberPayload, error) {
|
||||
@ -150,18 +237,18 @@ func (r *mutationResolver) DeleteProjectMember(ctx context.Context, input Delete
|
||||
func (r *mutationResolver) UpdateProjectMemberRole(ctx context.Context, input UpdateProjectMemberRole) (*UpdateProjectMemberRolePayload, error) {
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, input.UserID)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get user account")
|
||||
logger.New(ctx).WithError(err).Error("get user account")
|
||||
return &UpdateProjectMemberRolePayload{Ok: false}, err
|
||||
}
|
||||
_, err = r.Repository.UpdateProjectMemberRole(ctx, db.UpdateProjectMemberRoleParams{ProjectID: input.ProjectID,
|
||||
UserID: input.UserID, RoleCode: input.RoleCode.String()})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("update project member role")
|
||||
logger.New(ctx).WithError(err).Error("update project member role")
|
||||
return &UpdateProjectMemberRolePayload{Ok: false}, err
|
||||
}
|
||||
role, err := r.Repository.GetRoleForProjectMemberByUserID(ctx, db.GetRoleForProjectMemberByUserIDParams{UserID: user.UserID, ProjectID: input.ProjectID})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get role for project member")
|
||||
logger.New(ctx).WithError(err).Error("get role for project member")
|
||||
return &UpdateProjectMemberRolePayload{Ok: false}, err
|
||||
}
|
||||
var url *string
|
||||
@ -178,36 +265,40 @@ func (r *mutationResolver) UpdateProjectMemberRole(ctx context.Context, input Up
|
||||
return &UpdateProjectMemberRolePayload{Ok: true, Member: &member}, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) CreateTask(ctx context.Context, input NewTask) (*db.Task, error) {
|
||||
taskGroupID, err := uuid.Parse(input.TaskGroupID)
|
||||
func (r *mutationResolver) DeleteInvitedProjectMember(ctx context.Context, input DeleteInvitedProjectMember) (*DeleteInvitedProjectMemberPayload, error) {
|
||||
member, err := r.Repository.GetProjectMemberInvitedIDByEmail(ctx, input.Email)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("issue while parsing task group ID")
|
||||
return &db.Task{}, err
|
||||
return &DeleteInvitedProjectMemberPayload{}, err
|
||||
}
|
||||
createdAt := time.Now().UTC()
|
||||
log.WithFields(log.Fields{"positon": input.Position, "taskGroupID": taskGroupID}).Info("creating task")
|
||||
task, err := r.Repository.CreateTask(ctx, db.CreateTaskParams{taskGroupID, createdAt, input.Name, input.Position})
|
||||
err = r.Repository.DeleteInvitedProjectMemberByID(ctx, member.ProjectMemberInvitedID)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("issue while creating task")
|
||||
return &DeleteInvitedProjectMemberPayload{}, err
|
||||
}
|
||||
return &DeleteInvitedProjectMemberPayload{
|
||||
InvitedMember: &InvitedMember{Email: member.Email, InvitedOn: member.InvitedOn},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) CreateTask(ctx context.Context, input NewTask) (*db.Task, error) {
|
||||
createdAt := time.Now().UTC()
|
||||
logger.New(ctx).WithFields(log.Fields{"positon": input.Position, "taskGroupID": input.TaskGroupID}).Info("creating task")
|
||||
task, err := r.Repository.CreateTask(ctx, db.CreateTaskParams{input.TaskGroupID, createdAt, input.Name, input.Position})
|
||||
if err != nil {
|
||||
logger.New(ctx).WithError(err).Error("issue while creating task")
|
||||
return &db.Task{}, err
|
||||
}
|
||||
return &task, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) DeleteTask(ctx context.Context, input DeleteTaskInput) (*DeleteTaskPayload, error) {
|
||||
taskID, err := uuid.Parse(input.TaskID)
|
||||
if err != nil {
|
||||
return &DeleteTaskPayload{}, err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"taskID": taskID.String(),
|
||||
logger.New(ctx).WithFields(log.Fields{
|
||||
"taskID": input.TaskID,
|
||||
}).Info("deleting task")
|
||||
err = r.Repository.DeleteTaskByID(ctx, taskID)
|
||||
err := r.Repository.DeleteTaskByID(ctx, input.TaskID)
|
||||
if err != nil {
|
||||
return &DeleteTaskPayload{}, err
|
||||
}
|
||||
return &DeleteTaskPayload{taskID.String()}, nil
|
||||
return &DeleteTaskPayload{input.TaskID}, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskDescription(ctx context.Context, input UpdateTaskDescriptionInput) (*db.Task, error) {
|
||||
@ -226,11 +317,7 @@ func (r *mutationResolver) UpdateTaskLocation(ctx context.Context, input NewTask
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskName(ctx context.Context, input UpdateTaskName) (*db.Task, error) {
|
||||
taskID, err := uuid.Parse(input.TaskID)
|
||||
if err != nil {
|
||||
return &db.Task{}, err
|
||||
}
|
||||
task, err := r.Repository.UpdateTaskName(ctx, db.UpdateTaskNameParams{taskID, input.Name})
|
||||
task, err := r.Repository.UpdateTaskName(ctx, db.UpdateTaskNameParams{input.TaskID, input.Name})
|
||||
return &task, err
|
||||
}
|
||||
|
||||
@ -261,8 +348,8 @@ func (r *mutationResolver) UpdateTaskDueDate(ctx context.Context, input UpdateTa
|
||||
func (r *mutationResolver) AssignTask(ctx context.Context, input *AssignTaskInput) (*db.Task, error) {
|
||||
assignedDate := time.Now().UTC()
|
||||
assignedTask, err := r.Repository.CreateTaskAssigned(ctx, db.CreateTaskAssignedParams{input.TaskID, input.UserID, assignedDate})
|
||||
log.WithFields(log.Fields{
|
||||
"userID": assignedTask.UserID,
|
||||
logger.New(ctx).WithFields(log.Fields{
|
||||
"assignedUserID": assignedTask.UserID,
|
||||
"taskID": assignedTask.TaskID,
|
||||
"assignedTaskID": assignedTask.TaskAssignedID,
|
||||
}).Info("assigned task")
|
||||
@ -336,6 +423,16 @@ func (r *mutationResolver) CreateTaskChecklistItem(ctx context.Context, input Cr
|
||||
return &taskChecklistItem, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskChecklistLocation(ctx context.Context, input UpdateTaskChecklistLocation) (*UpdateTaskChecklistLocationPayload, error) {
|
||||
checklist, err := r.Repository.UpdateTaskChecklistPosition(ctx, db.UpdateTaskChecklistPositionParams{Position: input.Position, TaskChecklistID: input.TaskChecklistID})
|
||||
|
||||
if err != nil {
|
||||
return &UpdateTaskChecklistLocationPayload{}, err
|
||||
}
|
||||
|
||||
return &UpdateTaskChecklistLocationPayload{Checklist: &checklist}, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskChecklistItemName(ctx context.Context, input UpdateTaskChecklistItemName) (*db.TaskChecklistItem, error) {
|
||||
task, err := r.Repository.UpdateTaskChecklistItemName(ctx, db.UpdateTaskChecklistItemNameParams{TaskChecklistItemID: input.TaskChecklistItemID,
|
||||
Name: input.Name,
|
||||
@ -375,34 +472,20 @@ func (r *mutationResolver) DeleteTaskChecklistItem(ctx context.Context, input De
|
||||
}, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskChecklistLocation(ctx context.Context, input UpdateTaskChecklistLocation) (*UpdateTaskChecklistLocationPayload, error) {
|
||||
checklist, err := r.Repository.UpdateTaskChecklistPosition(ctx, db.UpdateTaskChecklistPositionParams{Position: input.Position, TaskChecklistID: input.ChecklistID})
|
||||
|
||||
if err != nil {
|
||||
return &UpdateTaskChecklistLocationPayload{}, err
|
||||
}
|
||||
|
||||
return &UpdateTaskChecklistLocationPayload{Checklist: &checklist}, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) UpdateTaskChecklistItemLocation(ctx context.Context, input UpdateTaskChecklistItemLocation) (*UpdateTaskChecklistItemLocationPayload, error) {
|
||||
currentChecklistItem, err := r.Repository.GetTaskChecklistItemByID(ctx, input.ChecklistItemID)
|
||||
currentChecklistItem, err := r.Repository.GetTaskChecklistItemByID(ctx, input.TaskChecklistItemID)
|
||||
|
||||
checklistItem, err := r.Repository.UpdateTaskChecklistItemLocation(ctx, db.UpdateTaskChecklistItemLocationParams{TaskChecklistID: input.ChecklistID, TaskChecklistItemID: input.ChecklistItemID, Position: input.Position})
|
||||
checklistItem, err := r.Repository.UpdateTaskChecklistItemLocation(ctx, db.UpdateTaskChecklistItemLocationParams{TaskChecklistID: input.TaskChecklistID, TaskChecklistItemID: input.TaskChecklistItemID, Position: input.Position})
|
||||
if err != nil {
|
||||
return &UpdateTaskChecklistItemLocationPayload{}, err
|
||||
}
|
||||
return &UpdateTaskChecklistItemLocationPayload{PrevChecklistID: currentChecklistItem.TaskChecklistID, ChecklistID: input.ChecklistID, ChecklistItem: &checklistItem}, err
|
||||
return &UpdateTaskChecklistItemLocationPayload{PrevChecklistID: currentChecklistItem.TaskChecklistID, TaskChecklistID: input.TaskChecklistID, ChecklistItem: &checklistItem}, err
|
||||
}
|
||||
|
||||
func (r *mutationResolver) CreateTaskGroup(ctx context.Context, input NewTaskGroup) (*db.TaskGroup, error) {
|
||||
createdAt := time.Now().UTC()
|
||||
projectID, err := uuid.Parse(input.ProjectID)
|
||||
if err != nil {
|
||||
return &db.TaskGroup{}, err
|
||||
}
|
||||
project, err := r.Repository.CreateTaskGroup(ctx,
|
||||
db.CreateTaskGroupParams{projectID, createdAt, input.Name, input.Position})
|
||||
db.CreateTaskGroupParams{input.ProjectID, createdAt, input.Name, input.Position})
|
||||
return &project, err
|
||||
}
|
||||
|
||||
@ -576,7 +659,7 @@ func (r *mutationResolver) ToggleTaskLabel(ctx context.Context, input ToggleTask
|
||||
createdAt := time.Now().UTC()
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
log.WithFields(log.Fields{"err": err}).Warning("no rows")
|
||||
logger.New(ctx).WithFields(log.Fields{"err": err}).Warning("no rows")
|
||||
_, err := r.Repository.CreateTaskLabelForTask(ctx, db.CreateTaskLabelForTaskParams{
|
||||
TaskID: input.TaskID,
|
||||
ProjectLabelID: input.ProjectLabelID,
|
||||
@ -609,17 +692,17 @@ func (r *mutationResolver) ToggleTaskLabel(ctx context.Context, input ToggleTask
|
||||
func (r *mutationResolver) DeleteTeam(ctx context.Context, input DeleteTeam) (*DeleteTeamPayload, error) {
|
||||
team, err := r.Repository.GetTeamByID(ctx, input.TeamID)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
logger.New(ctx).Error(err)
|
||||
return &DeleteTeamPayload{Ok: false}, err
|
||||
}
|
||||
projects, err := r.Repository.GetAllProjectsForTeam(ctx, input.TeamID)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
logger.New(ctx).Error(err)
|
||||
return &DeleteTeamPayload{Ok: false}, err
|
||||
}
|
||||
err = r.Repository.DeleteTeamByID(ctx, input.TeamID)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
logger.New(ctx).Error(err)
|
||||
return &DeleteTeamPayload{Ok: false}, err
|
||||
}
|
||||
|
||||
@ -674,18 +757,18 @@ func (r *mutationResolver) CreateTeamMember(ctx context.Context, input CreateTea
|
||||
func (r *mutationResolver) UpdateTeamMemberRole(ctx context.Context, input UpdateTeamMemberRole) (*UpdateTeamMemberRolePayload, error) {
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, input.UserID)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get user account")
|
||||
logger.New(ctx).WithError(err).Error("get user account")
|
||||
return &UpdateTeamMemberRolePayload{Ok: false}, err
|
||||
}
|
||||
_, err = r.Repository.UpdateTeamMemberRole(ctx, db.UpdateTeamMemberRoleParams{TeamID: input.TeamID,
|
||||
UserID: input.UserID, RoleCode: input.RoleCode.String()})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("update project member role")
|
||||
logger.New(ctx).WithError(err).Error("update project member role")
|
||||
return &UpdateTeamMemberRolePayload{Ok: false}, err
|
||||
}
|
||||
role, err := r.Repository.GetRoleForTeamMember(ctx, db.GetRoleForTeamMemberParams{UserID: user.UserID, TeamID: input.TeamID})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get role for project member")
|
||||
logger.New(ctx).WithError(err).Error("get role for project member")
|
||||
return &UpdateTeamMemberRolePayload{Ok: false}, err
|
||||
}
|
||||
var url *string
|
||||
@ -772,13 +855,22 @@ func (r *mutationResolver) DeleteUserAccount(ctx context.Context, input DeleteUs
|
||||
return &DeleteUserAccountPayload{UserAccount: &user, Ok: true}, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) LogoutUser(ctx context.Context, input LogoutUser) (bool, error) {
|
||||
userID, err := uuid.Parse(input.UserID)
|
||||
func (r *mutationResolver) DeleteInvitedUserAccount(ctx context.Context, input DeleteInvitedUserAccount) (*DeleteInvitedUserAccountPayload, error) {
|
||||
user, err := r.Repository.DeleteInvitedUserAccount(ctx, input.InvitedUserID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return &DeleteInvitedUserAccountPayload{}, err
|
||||
}
|
||||
return &DeleteInvitedUserAccountPayload{
|
||||
InvitedUser: &InvitedUserAccount{
|
||||
Email: user.Email,
|
||||
ID: user.UserAccountInvitedID,
|
||||
InvitedOn: user.InvitedOn,
|
||||
},
|
||||
}, err
|
||||
}
|
||||
|
||||
err = r.Repository.DeleteRefreshTokenByUserID(ctx, userID)
|
||||
func (r *mutationResolver) LogoutUser(ctx context.Context, input LogoutUser) (bool, error) {
|
||||
err := r.Repository.DeleteRefreshTokenByUserID(ctx, input.UserID)
|
||||
return true, err
|
||||
}
|
||||
|
||||
@ -842,9 +934,9 @@ func (r *notificationResolver) ID(ctx context.Context, obj *db.Notification) (uu
|
||||
}
|
||||
|
||||
func (r *notificationResolver) Entity(ctx context.Context, obj *db.Notification) (*NotificationEntity, error) {
|
||||
log.WithFields(log.Fields{"notificationID": obj.NotificationID}).Info("fetching entity for notification")
|
||||
logger.New(ctx).WithFields(log.Fields{"notificationID": obj.NotificationID}).Info("fetching entity for notification")
|
||||
entity, err := r.Repository.GetEntityForNotificationID(ctx, obj.NotificationID)
|
||||
log.WithFields(log.Fields{"entityID": entity.EntityID}).Info("fetched entity")
|
||||
logger.New(ctx).WithFields(log.Fields{"entityID": entity.EntityID}).Info("fetched entity")
|
||||
if err != nil {
|
||||
return &NotificationEntity{}, err
|
||||
}
|
||||
@ -876,7 +968,7 @@ func (r *notificationResolver) Actor(ctx context.Context, obj *db.Notification)
|
||||
if err != nil {
|
||||
return &NotificationActor{}, err
|
||||
}
|
||||
log.WithFields(log.Fields{"entityID": entity.ActorID}).Info("fetching actor")
|
||||
logger.New(ctx).WithFields(log.Fields{"entityID": entity.ActorID}).Info("fetching actor")
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, entity.ActorID)
|
||||
if err != nil {
|
||||
return &NotificationActor{}, err
|
||||
@ -903,7 +995,10 @@ func (r *projectResolver) ID(ctx context.Context, obj *db.Project) (uuid.UUID, e
|
||||
func (r *projectResolver) Team(ctx context.Context, obj *db.Project) (*db.Team, error) {
|
||||
team, err := r.Repository.GetTeamByID(ctx, obj.TeamID)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"teamID": obj.TeamID, "projectID": obj.ProjectID}).WithError(err).Error("issue while getting team for project")
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
logger.New(ctx).WithFields(log.Fields{"teamID": obj.TeamID, "projectID": obj.ProjectID}).WithError(err).Error("issue while getting team for project")
|
||||
return &team, err
|
||||
}
|
||||
return &team, nil
|
||||
@ -917,14 +1012,14 @@ func (r *projectResolver) Members(ctx context.Context, obj *db.Project) ([]Membe
|
||||
members := []Member{}
|
||||
projectMembers, err := r.Repository.GetProjectMembersForProjectID(ctx, obj.ProjectID)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get project members for project id")
|
||||
logger.New(ctx).WithError(err).Error("get project members for project id")
|
||||
return members, err
|
||||
}
|
||||
|
||||
for _, projectMember := range projectMembers {
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, projectMember.UserID)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get user account by ID")
|
||||
logger.New(ctx).WithError(err).Error("get user account by ID")
|
||||
return members, err
|
||||
}
|
||||
var url *string
|
||||
@ -933,7 +1028,7 @@ func (r *projectResolver) Members(ctx context.Context, obj *db.Project) ([]Membe
|
||||
}
|
||||
role, err := r.Repository.GetRoleForProjectMemberByUserID(ctx, db.GetRoleForProjectMemberByUserIDParams{UserID: user.UserID, ProjectID: obj.ProjectID})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get role for projet member by user ID")
|
||||
logger.New(ctx).WithError(err).Error("get role for projet member by user ID")
|
||||
return members, err
|
||||
}
|
||||
profileIcon := &ProfileIcon{url, &user.Initials, &user.ProfileBgColor}
|
||||
@ -944,6 +1039,18 @@ func (r *projectResolver) Members(ctx context.Context, obj *db.Project) ([]Membe
|
||||
return members, nil
|
||||
}
|
||||
|
||||
func (r *projectResolver) InvitedMembers(ctx context.Context, obj *db.Project) ([]InvitedMember, error) {
|
||||
members, err := r.Repository.GetInvitedMembersForProjectID(ctx, obj.ProjectID)
|
||||
if err != nil && err == sql.ErrNoRows {
|
||||
return []InvitedMember{}, nil
|
||||
}
|
||||
invited := []InvitedMember{}
|
||||
for _, member := range members {
|
||||
invited = append(invited, InvitedMember{Email: member.Email, InvitedOn: member.InvitedOn})
|
||||
}
|
||||
return invited, err
|
||||
}
|
||||
|
||||
func (r *projectResolver) Labels(ctx context.Context, obj *db.Project) ([]db.ProjectLabel, error) {
|
||||
labels, err := r.Repository.GetProjectLabelsForProject(ctx, obj.ProjectID)
|
||||
return labels, err
|
||||
@ -977,12 +1084,27 @@ func (r *queryResolver) Users(ctx context.Context) ([]db.UserAccount, error) {
|
||||
return r.Repository.GetAllUserAccounts(ctx)
|
||||
}
|
||||
|
||||
func (r *queryResolver) FindUser(ctx context.Context, input FindUser) (*db.UserAccount, error) {
|
||||
userID, err := uuid.Parse(input.UserID)
|
||||
func (r *queryResolver) InvitedUsers(ctx context.Context) ([]InvitedUserAccount, error) {
|
||||
invitedMembers, err := r.Repository.GetInvitedUserAccounts(ctx)
|
||||
if err != nil {
|
||||
return &db.UserAccount{}, err
|
||||
if err == sql.ErrNoRows {
|
||||
return []InvitedUserAccount{}, nil
|
||||
}
|
||||
return []InvitedUserAccount{}, err
|
||||
}
|
||||
account, err := r.Repository.GetUserAccountByID(ctx, userID)
|
||||
members := []InvitedUserAccount{}
|
||||
for _, invitedMember := range invitedMembers {
|
||||
members = append(members, InvitedUserAccount{
|
||||
ID: invitedMember.UserAccountInvitedID,
|
||||
Email: invitedMember.Email,
|
||||
InvitedOn: invitedMember.InvitedOn,
|
||||
})
|
||||
}
|
||||
return members, nil
|
||||
}
|
||||
|
||||
func (r *queryResolver) FindUser(ctx context.Context, input FindUser) (*db.UserAccount, error) {
|
||||
account, err := r.Repository.GetUserAccountByID(ctx, input.UserID)
|
||||
if err == sql.ErrNoRows {
|
||||
return &db.UserAccount{}, &gqlerror.Error{
|
||||
Message: "User not found",
|
||||
@ -995,11 +1117,7 @@ func (r *queryResolver) FindUser(ctx context.Context, input FindUser) (*db.UserA
|
||||
}
|
||||
|
||||
func (r *queryResolver) FindProject(ctx context.Context, input FindProject) (*db.Project, error) {
|
||||
userID, role, ok := GetUser(ctx)
|
||||
log.WithFields(log.Fields{"userID": userID, "role": role}).Info("find project user")
|
||||
if !ok {
|
||||
return &db.Project{}, nil
|
||||
}
|
||||
logger.New(ctx).Info("finding project user")
|
||||
project, err := r.Repository.GetProjectByID(ctx, input.ProjectID)
|
||||
if err == sql.ErrNoRows {
|
||||
return &db.Project{}, &gqlerror.Error{
|
||||
@ -1009,25 +1127,6 @@ func (r *queryResolver) FindProject(ctx context.Context, input FindProject) (*db
|
||||
},
|
||||
}
|
||||
}
|
||||
if role == auth.RoleAdmin {
|
||||
return &project, nil
|
||||
}
|
||||
|
||||
projectRoles, err := GetProjectRoles(ctx, r.Repository, input.ProjectID)
|
||||
log.WithFields(log.Fields{"projectID": input.ProjectID, "teamRole": projectRoles.TeamRole, "projectRole": projectRoles.ProjectRole}).Info("get project roles ")
|
||||
if err != nil {
|
||||
return &project, err
|
||||
}
|
||||
|
||||
if projectRoles.TeamRole == "" && projectRoles.ProjectRole == "" {
|
||||
return &db.Project{}, &gqlerror.Error{
|
||||
Message: "project not accessible",
|
||||
Extensions: map[string]interface{}{
|
||||
"code": "11-400",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return &project, nil
|
||||
}
|
||||
|
||||
@ -1039,54 +1138,55 @@ func (r *queryResolver) FindTask(ctx context.Context, input FindTask) (*db.Task,
|
||||
func (r *queryResolver) Projects(ctx context.Context, input *ProjectsFilter) ([]db.Project, error) {
|
||||
userID, orgRole, ok := GetUser(ctx)
|
||||
if !ok {
|
||||
log.Info("user id was not found from middleware")
|
||||
logger.New(ctx).Info("user id was not found from middleware")
|
||||
return []db.Project{}, nil
|
||||
}
|
||||
log.WithFields(log.Fields{"userID": userID}).Info("fetching projects")
|
||||
logger.New(ctx).Info("fetching projects")
|
||||
|
||||
if input != nil {
|
||||
return r.Repository.GetAllProjectsForTeam(ctx, *input.TeamID)
|
||||
}
|
||||
|
||||
var teams []db.Team
|
||||
var err error
|
||||
if orgRole == "admin" {
|
||||
log.Info("showing all projects for admin")
|
||||
return r.Repository.GetAllProjects(ctx)
|
||||
teams, err = r.Repository.GetAllTeams(ctx)
|
||||
} else {
|
||||
teams, err = r.Repository.GetTeamsForUserIDWhereAdmin(ctx, userID)
|
||||
}
|
||||
|
||||
teams, err := r.Repository.GetTeamsForUserIDWhereAdmin(ctx, userID)
|
||||
projects := make(map[string]db.Project)
|
||||
for _, team := range teams {
|
||||
log.WithFields(log.Fields{"teamID": team.TeamID}).Info("found team")
|
||||
logger.New(ctx).WithField("teamID", team.TeamID).Info("found team")
|
||||
teamProjects, err := r.Repository.GetAllProjectsForTeam(ctx, team.TeamID)
|
||||
if err != sql.ErrNoRows && err != nil {
|
||||
log.Info("issue getting team projects")
|
||||
return []db.Project{}, nil
|
||||
}
|
||||
for _, project := range teamProjects {
|
||||
log.WithFields(log.Fields{"projectID": project.ProjectID.String()}).Info("adding team project")
|
||||
logger.New(ctx).WithField("projectID", project.ProjectID).Info("adding team project")
|
||||
projects[project.ProjectID.String()] = project
|
||||
}
|
||||
}
|
||||
|
||||
visibleProjects, err := r.Repository.GetAllVisibleProjectsForUserID(ctx, userID)
|
||||
if err != nil {
|
||||
log.WithField("userID", userID).Info("error getting visible projects for user")
|
||||
logger.New(ctx).Info("error getting visible projects for user")
|
||||
return []db.Project{}, nil
|
||||
}
|
||||
for _, project := range visibleProjects {
|
||||
log.WithFields(log.Fields{"projectID": project.ProjectID.String()}).Info("found visible project")
|
||||
logger.New(ctx).WithField("projectID", project.ProjectID).Info("found visible project")
|
||||
if _, ok := projects[project.ProjectID.String()]; !ok {
|
||||
log.WithFields(log.Fields{"projectID": project.ProjectID.String()}).Info("adding visible project")
|
||||
logger.New(ctx).WithField("projectID", project.ProjectID).Info("adding visible project")
|
||||
projects[project.ProjectID.String()] = project
|
||||
}
|
||||
}
|
||||
log.WithFields(log.Fields{"projectLength": len(projects)}).Info("making projects")
|
||||
logger.New(ctx).WithField("projectLength", len(projects)).Info("making projects")
|
||||
allProjects := make([]db.Project, 0, len(projects))
|
||||
for _, project := range projects {
|
||||
log.WithFields(log.Fields{"projectID": project.ProjectID.String()}).Info("add project to final list")
|
||||
logger.New(ctx).WithField("projectID", project.ProjectID).Info("adding project to final list")
|
||||
allProjects = append(allProjects, project)
|
||||
}
|
||||
log.Info(allProjects)
|
||||
return allProjects, nil
|
||||
}
|
||||
|
||||
@ -1101,16 +1201,18 @@ func (r *queryResolver) FindTeam(ctx context.Context, input FindTeam) (*db.Team,
|
||||
func (r *queryResolver) Teams(ctx context.Context) ([]db.Team, error) {
|
||||
userID, orgRole, ok := GetUser(ctx)
|
||||
if !ok {
|
||||
log.Error("userID or orgRole does not exist!")
|
||||
logger.New(ctx).Error("userID or org role does not exist")
|
||||
return []db.Team{}, errors.New("internal error")
|
||||
}
|
||||
if orgRole == "admin" {
|
||||
|
||||
return r.Repository.GetAllTeams(ctx)
|
||||
}
|
||||
|
||||
teams := make(map[string]db.Team)
|
||||
adminTeams, err := r.Repository.GetTeamsForUserIDWhereAdmin(ctx, userID)
|
||||
if err != nil {
|
||||
logger.New(ctx).WithError(err).Error("error while getting teams for user ID")
|
||||
return []db.Team{}, err
|
||||
}
|
||||
|
||||
@ -1120,16 +1222,19 @@ func (r *queryResolver) Teams(ctx context.Context) ([]db.Team, error) {
|
||||
|
||||
visibleProjects, err := r.Repository.GetAllVisibleProjectsForUserID(ctx, userID)
|
||||
if err != nil {
|
||||
log.WithField("userID", userID).Info("error while getting visible projects")
|
||||
logger.New(ctx).WithError(err).Error("error while getting visible projects for user ID")
|
||||
return []db.Team{}, err
|
||||
}
|
||||
for _, project := range visibleProjects {
|
||||
log.WithFields(log.Fields{"projectID": project.ProjectID.String()}).Info("found visible project")
|
||||
logger.New(ctx).WithField("projectID", project.ProjectID).Info("found visible project")
|
||||
if _, ok := teams[project.ProjectID.String()]; !ok {
|
||||
log.WithFields(log.Fields{"projectID": project.ProjectID.String()}).Info("adding visible project")
|
||||
logger.New(ctx).WithField("projectID", project.ProjectID).Info("adding visible project")
|
||||
team, err := r.Repository.GetTeamByID(ctx, project.TeamID)
|
||||
if err != nil {
|
||||
log.WithField("teamID", project.TeamID).Info("error getting team by id")
|
||||
if err == sql.ErrNoRows {
|
||||
continue
|
||||
}
|
||||
logger.New(ctx).WithField("teamID", project.TeamID).WithError(err).Error("error getting team by id")
|
||||
return []db.Team{}, err
|
||||
}
|
||||
teams[project.TeamID.String()] = team
|
||||
@ -1157,7 +1262,7 @@ func (r *queryResolver) Me(ctx context.Context) (*MePayload, error) {
|
||||
}
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, userID)
|
||||
if err == sql.ErrNoRows {
|
||||
log.WithFields(log.Fields{"userID": userID}).Warning("can not find user for me query")
|
||||
logger.New(ctx).Warning("can not find user for me query")
|
||||
return &MePayload{}, nil
|
||||
} else if err != nil {
|
||||
return &MePayload{}, err
|
||||
@ -1185,7 +1290,7 @@ func (r *queryResolver) Me(ctx context.Context) (*MePayload, error) {
|
||||
|
||||
func (r *queryResolver) Notifications(ctx context.Context) ([]db.Notification, error) {
|
||||
userID, ok := GetUserID(ctx)
|
||||
log.WithFields(log.Fields{"userID": userID}).Info("fetching notifications")
|
||||
logger.New(ctx).Info("fetching notifications")
|
||||
if !ok {
|
||||
return []db.Notification{}, errors.New("user id is missing")
|
||||
}
|
||||
@ -1198,6 +1303,64 @@ func (r *queryResolver) Notifications(ctx context.Context) ([]db.Notification, e
|
||||
return notifications, nil
|
||||
}
|
||||
|
||||
func (r *queryResolver) SearchMembers(ctx context.Context, input MemberSearchFilter) ([]MemberSearchResult, error) {
|
||||
availableMembers, err := r.Repository.GetMemberData(ctx, *input.ProjectID)
|
||||
if err != nil {
|
||||
logger.New(ctx).WithField("projectID", input.ProjectID).WithError(err).Error("error while getting member data")
|
||||
return []MemberSearchResult{}, err
|
||||
}
|
||||
|
||||
invitedMembers, err := r.Repository.GetInvitedMembersForProjectID(ctx, *input.ProjectID)
|
||||
if err != nil {
|
||||
logger.New(ctx).WithField("projectID", input.ProjectID).WithError(err).Error("error while getting member data")
|
||||
return []MemberSearchResult{}, err
|
||||
}
|
||||
|
||||
sortList := []string{}
|
||||
masterList := map[string]MasterEntry{}
|
||||
for _, member := range availableMembers {
|
||||
sortList = append(sortList, member.Username)
|
||||
sortList = append(sortList, member.Email)
|
||||
masterList[member.Username] = MasterEntry{ID: member.UserID, MemberType: MemberTypeJoined}
|
||||
masterList[member.Email] = MasterEntry{ID: member.UserID, MemberType: MemberTypeJoined}
|
||||
}
|
||||
for _, member := range invitedMembers {
|
||||
sortList = append(sortList, member.Email)
|
||||
logger.New(ctx).WithField("Email", member.Email).Info("adding member")
|
||||
masterList[member.Email] = MasterEntry{ID: member.UserAccountInvitedID, MemberType: MemberTypeInvited}
|
||||
}
|
||||
|
||||
logger.New(ctx).WithField("searchFilter", input.SearchFilter).Info(sortList)
|
||||
rankedList := fuzzy.RankFind(input.SearchFilter, sortList)
|
||||
logger.New(ctx).Info(rankedList)
|
||||
results := []MemberSearchResult{}
|
||||
memberList := map[uuid.UUID]bool{}
|
||||
for _, rank := range rankedList {
|
||||
entry, _ := masterList[rank.Target]
|
||||
_, ok := memberList[entry.ID]
|
||||
logger.New(ctx).WithField("ok", ok).WithField("target", rank.Target).Info("checking rank")
|
||||
if !ok {
|
||||
if entry.MemberType == MemberTypeJoined {
|
||||
logger.New(ctx).WithFields(log.Fields{"source": rank.Source, "target": rank.Target}).Info("searching")
|
||||
entry := masterList[rank.Target]
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, entry.ID)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
continue
|
||||
}
|
||||
return []MemberSearchResult{}, err
|
||||
}
|
||||
results = append(results, MemberSearchResult{ID: user.UserID.String(), User: &user, Status: ShareStatusJoined, Similarity: rank.Distance})
|
||||
} else {
|
||||
logger.New(ctx).WithField("id", rank.Target).Info("adding target")
|
||||
results = append(results, MemberSearchResult{ID: rank.Target, Status: ShareStatusInvited, Similarity: rank.Distance})
|
||||
}
|
||||
memberList[entry.ID] = true
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func (r *refreshTokenResolver) ID(ctx context.Context, obj *db.RefreshToken) (uuid.UUID, error) {
|
||||
return obj.TokenID, nil
|
||||
}
|
||||
@ -1262,7 +1425,7 @@ func (r *taskResolver) Assigned(ctx context.Context, obj *db.Task) ([]Member, er
|
||||
if err == sql.ErrNoRows {
|
||||
role = db.Role{Code: "owner", Name: "Owner"}
|
||||
} else {
|
||||
log.WithFields(log.Fields{"userID": user.UserID}).WithError(err).Error("get role for project member")
|
||||
logger.New(ctx).WithError(err).Error("get role for project member")
|
||||
return taskMembers, err
|
||||
}
|
||||
}
|
||||
@ -1356,14 +1519,14 @@ func (r *teamResolver) Members(ctx context.Context, obj *db.Team) ([]Member, err
|
||||
|
||||
teamMembers, err := r.Repository.GetTeamMembersForTeamID(ctx, obj.TeamID)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get project members for project id")
|
||||
logger.New(ctx).Error("get project members for project id")
|
||||
return members, err
|
||||
}
|
||||
|
||||
for _, teamMember := range teamMembers {
|
||||
user, err := r.Repository.GetUserAccountByID(ctx, teamMember.UserID)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get user account by ID")
|
||||
logger.New(ctx).WithError(err).Error("get user account by ID")
|
||||
return members, err
|
||||
}
|
||||
var url *string
|
||||
@ -1372,7 +1535,7 @@ func (r *teamResolver) Members(ctx context.Context, obj *db.Team) ([]Member, err
|
||||
}
|
||||
role, err := r.Repository.GetRoleForTeamMember(ctx, db.GetRoleForTeamMemberParams{UserID: user.UserID, TeamID: obj.TeamID})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("get role for projet member by user ID")
|
||||
logger.New(ctx).WithError(err).Error("get role for projet member by user ID")
|
||||
return members, err
|
||||
}
|
||||
|
||||
@ -1400,8 +1563,7 @@ func (r *userAccountResolver) ID(ctx context.Context, obj *db.UserAccount) (uuid
|
||||
func (r *userAccountResolver) Role(ctx context.Context, obj *db.UserAccount) (*db.Role, error) {
|
||||
role, err := r.Repository.GetRoleForUserID(ctx, obj.UserID)
|
||||
if err != nil {
|
||||
log.Info("beep!")
|
||||
log.WithError(err).Error("get role for user id")
|
||||
logger.New(ctx).WithError(err).Error("get role for user id")
|
||||
return &db.Role{}, err
|
||||
}
|
||||
return &db.Role{Code: role.Code, Name: role.Name}, nil
|
||||
@ -1480,9 +1642,7 @@ func (r *Resolver) Task() TaskResolver { return &taskResolver{r} }
|
||||
func (r *Resolver) TaskChecklist() TaskChecklistResolver { return &taskChecklistResolver{r} }
|
||||
|
||||
// TaskChecklistItem returns TaskChecklistItemResolver implementation.
|
||||
func (r *Resolver) TaskChecklistItem() TaskChecklistItemResolver {
|
||||
return &taskChecklistItemResolver{r}
|
||||
}
|
||||
func (r *Resolver) TaskChecklistItem() TaskChecklistItemResolver { return &taskChecklistItemResolver{r} }
|
||||
|
||||
// TaskGroup returns TaskGroupResolver implementation.
|
||||
func (r *Resolver) TaskGroup() TaskGroupResolver { return &taskGroupResolver{r} }
|
||||
@ -1511,3 +1671,21 @@ type taskGroupResolver struct{ *Resolver }
|
||||
type taskLabelResolver struct{ *Resolver }
|
||||
type teamResolver struct{ *Resolver }
|
||||
type userAccountResolver struct{ *Resolver }
|
||||
|
||||
// !!! WARNING !!!
|
||||
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
|
||||
// one last chance to move it out of harms way if you want. There are two reasons this happens:
|
||||
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
|
||||
// it when you're done.
|
||||
// - You have helper methods in this file. Move them out to keep these resolver files clean.
|
||||
type MemberType string
|
||||
|
||||
const (
|
||||
MemberTypeInvited MemberType = "INVITED"
|
||||
MemberTypeJoined MemberType = "JOINED"
|
||||
)
|
||||
|
||||
type MasterEntry struct {
|
||||
MemberType MemberType
|
||||
ID uuid.UUID
|
||||
}
|
||||
|
@ -86,6 +86,13 @@ type UserAccount {
|
||||
member: MemberList!
|
||||
}
|
||||
|
||||
type InvitedUserAccount {
|
||||
id: ID!
|
||||
email: String!
|
||||
invitedOn: Time!
|
||||
member: MemberList!
|
||||
}
|
||||
|
||||
type Team {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
@ -93,13 +100,20 @@ type Team {
|
||||
members: [Member!]!
|
||||
}
|
||||
|
||||
|
||||
type InvitedMember {
|
||||
email: String!
|
||||
invitedOn: Time!
|
||||
}
|
||||
|
||||
type Project {
|
||||
id: ID!
|
||||
createdAt: Time!
|
||||
name: String!
|
||||
team: Team!
|
||||
team: Team
|
||||
taskGroups: [TaskGroup!]!
|
||||
members: [Member!]!
|
||||
invitedMembers: [InvitedMember!]!
|
||||
labels: [ProjectLabel!]!
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
enum ShareStatus {
|
||||
INVITED
|
||||
JOINED
|
||||
}
|
||||
|
||||
enum RoleLevel {
|
||||
ADMIN
|
||||
MEMBER
|
||||
@ -14,6 +19,9 @@ enum ObjectType {
|
||||
TEAM
|
||||
PROJECT
|
||||
TASK
|
||||
TASK_GROUP
|
||||
TASK_CHECKLIST
|
||||
TASK_CHECKLIST_ITEM
|
||||
}
|
||||
|
||||
directive @hasRole(roles: [RoleLevel!]!, level: ActionLevel!, type: ObjectType!) on FIELD_DEFINITION
|
||||
@ -21,8 +29,10 @@ directive @hasRole(roles: [RoleLevel!]!, level: ActionLevel!, type: ObjectType!)
|
||||
type Query {
|
||||
organizations: [Organization!]!
|
||||
users: [UserAccount!]!
|
||||
invitedUsers: [InvitedUserAccount!]!
|
||||
findUser(input: FindUser!): UserAccount!
|
||||
findProject(input: FindProject!): Project!
|
||||
findProject(input: FindProject!):
|
||||
Project! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT)
|
||||
findTask(input: FindTask!): Task!
|
||||
projects(input: ProjectsFilter): [Project!]!
|
||||
findTeam(input: FindTeam!): Team!
|
||||
@ -55,7 +65,7 @@ input ProjectsFilter {
|
||||
}
|
||||
|
||||
input FindUser {
|
||||
userId: String!
|
||||
userID: UUID!
|
||||
}
|
||||
|
||||
input FindProject {
|
||||
|
@ -7,8 +7,7 @@ extend type Mutation {
|
||||
}
|
||||
|
||||
input NewProject {
|
||||
userID: UUID!
|
||||
teamID: UUID!
|
||||
teamID: UUID
|
||||
name: String!
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user