Skip to content

Commit

Permalink
fix: merge conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
sriramveeraghanta committed Feb 8, 2023
2 parents d3b73dc + 56030b1 commit 7f406ce
Show file tree
Hide file tree
Showing 36 changed files with 867 additions and 322 deletions.
18 changes: 12 additions & 6 deletions apiserver/plane/api/views/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def get_tokens_for_user(user):

def validate_google_token(token, client_id):
try:

id_info = id_token.verify_oauth2_token(
token, google_auth_request.Request(), client_id
)
Expand Down Expand Up @@ -106,17 +105,26 @@ def get_user_data(access_token: str) -> dict:

resp = requests.get(url=url, headers=headers)

userData = resp.json()
user_data = resp.json()

response = requests.get(
url="https://api.github.com/user/emails", headers=headers
).json()

[
user_data.update({"email": item.get("email")})
for item in response
if item.get("primary") is True
]

return userData
return user_data


class OauthEndpoint(BaseAPIView):
permission_classes = [AllowAny]

def post(self, request):
try:

medium = request.data.get("medium", False)
id_token = request.data.get("credential", False)
client_id = request.data.get("clientId", False)
Expand All @@ -138,7 +146,6 @@ def post(self, request):

email = data.get("email", None)
if email == None:

return Response(
{
"error": "Something went wrong. Please try again later or contact the support team."
Expand All @@ -153,7 +160,6 @@ def post(self, request):
mobile_number = uuid.uuid4().hex
email_verified = True
else:

return Response(
{
"error": "Something went wrong. Please try again later or contact the support team."
Expand Down
2 changes: 1 addition & 1 deletion apps/app/components/account/github-login-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const GithubLoginButton: FC<GithubLoginButtonProps> = (props) => {

return (
<Link
href={`https://github.com/login/oauth/authorize?client_id=${NEXT_PUBLIC_GITHUB_ID}&redirect_uri=${loginCallBackURL}`}
href={`https://github.com/login/oauth/authorize?client_id=${NEXT_PUBLIC_GITHUB_ID}&redirect_uri=${loginCallBackURL}&scope=read:user,user:email`}
>
<button className="flex w-full items-center rounded bg-black px-3 py-2 text-sm text-white opacity-90 duration-300 hover:opacity-100">
<Image
Expand Down
1 change: 0 additions & 1 deletion apps/app/components/core/board-view/all-boards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { DragDropContext, DropResult } from "react-beautiful-dnd";
// hooks
import useIssueView from "hooks/use-issue-view";
// components
import StrictModeDroppable from "components/dnd/StrictModeDroppable";
import { SingleBoard } from "components/core/board-view/single-board";
// types
import { IIssue, IProjectMember, IState, UserAuth } from "types";
Expand Down
7 changes: 1 addition & 6 deletions apps/app/components/core/bulk-delete-issues-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ export const BulkDeleteIssuesModal: React.FC<Props> = ({ isOpen, setIsOpen }) =>
"delete_issue_ids",
selectedIssues.filter((i) => i !== val)
);
else {
const newToDelete = selectedIssues;
newToDelete.push(val);

setValue("delete_issue_ids", newToDelete);
}
else setValue("delete_issue_ids", [...selectedIssues, val]);
}}
>
<div className="relative m-1">
Expand Down
16 changes: 6 additions & 10 deletions apps/app/components/core/issues-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ import modulesService from "services/modules.service";
// hooks
import useIssueView from "hooks/use-issue-view";
// components
import { AllLists, AllBoards, ExistingIssuesListModal } from "components/core";
import { AllLists, AllBoards } from "components/core";
import { CreateUpdateIssueModal, DeleteIssueModal } from "components/issues";
// helpers
import { getStatesList } from "helpers/state.helper";
// types
import {
CycleIssueResponse,
IIssue,
IssueResponse,
IState,
ModuleIssueResponse,
UserAuth,
} from "types";
import { CycleIssueResponse, IIssue, IssueResponse, ModuleIssueResponse, UserAuth } from "types";
// fetch-keys
import {
CYCLE_ISSUES,
Expand Down Expand Up @@ -68,12 +63,13 @@ export const IssuesView: React.FC<Props> = ({

const { issueView, groupedByIssues, groupByProperty: selectedGroup } = useIssueView(issues);

const { data: states } = useSWR<IState[]>(
const { data: stateGroups } = useSWR(
workspaceSlug && projectId ? STATE_LIST(projectId as string) : null,
workspaceSlug
? () => stateService.getStates(workspaceSlug as string, projectId as string)
: null
);
const states = getStatesList(stateGroups ?? {});

const { data: members } = useSWR(
projectId ? PROJECT_MEMBERS(projectId as string) : null,
Expand Down
184 changes: 184 additions & 0 deletions apps/app/components/core/sidebar/sidebar-progress-stats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import React from "react";

import Image from "next/image";
import { useRouter } from "next/router";

import useSWR from "swr";

// headless ui
import { Tab } from "@headlessui/react";
// services
import issuesServices from "services/issues.service";
import projectService from "services/project.service";
// components
import SingleProgressStats from "components/core/sidebar/single-progress-stats";
// ui
import { Avatar } from "components/ui";
// icons
import User from "public/user.png";
// types
import { IIssue, IIssueLabels } from "types";
// fetch-keys
import { PROJECT_ISSUE_LABELS, PROJECT_MEMBERS } from "constants/fetch-keys";
// types
type Props = {
groupedIssues: any;
issues: IIssue[];
};

const stateGroupColours: {
[key: string]: string;
} = {
backlog: "#3f76ff",
unstarted: "#ff9e9e",
started: "#d687ff",
cancelled: "#ff5353",
completed: "#096e8d",
};

const SidebarProgressStats: React.FC<Props> = ({ groupedIssues, issues }) => {
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
const { data: issueLabels } = useSWR<IIssueLabels[]>(
workspaceSlug && projectId ? PROJECT_ISSUE_LABELS(projectId as string) : null,
workspaceSlug && projectId
? () => issuesServices.getIssueLabels(workspaceSlug as string, projectId as string)
: null
);

const { data: members } = useSWR(
workspaceSlug && projectId ? PROJECT_MEMBERS(workspaceSlug as string) : null,
workspaceSlug && projectId
? () => projectService.projectMembers(workspaceSlug as string, projectId as string)
: null
);
return (
<div className="flex flex-col items-center justify-center w-full gap-2 ">
<Tab.Group>
<Tab.List
as="div"
className="flex items-center justify-between w-full rounded bg-gray-100 text-xs"
>
<Tab
className={({ selected }) =>
`w-1/2 rounded py-1 ${selected ? "bg-gray-300" : "hover:bg-gray-200"}`
}
>
Assignees
</Tab>
<Tab
className={({ selected }) =>
`w-1/2 rounded py-1 ${selected ? "bg-gray-300 font-semibold" : "hover:bg-gray-200 "}`
}
>
Labels
</Tab>
<Tab
className={({ selected }) =>
`w-1/2 rounded py-1 ${selected ? "bg-gray-300 font-semibold" : "hover:bg-gray-200 "}`
}
>
States
</Tab>
</Tab.List>
<Tab.Panels className="flex items-center justify-between w-full">
<Tab.Panel as="div" className="w-full flex flex-col ">
{members?.map((member, index) => {
const totalArray = issues?.filter((i) => i.assignees?.includes(member.member.id));
const completeArray = totalArray?.filter((i) => i.state_detail.group === "completed");
if (totalArray.length > 0) {
return (
<SingleProgressStats
key={index}
title={
<>
<Avatar user={member.member} />
<span>{member.member.first_name}</span>
</>
}
completed={completeArray.length}
total={totalArray.length}
/>
);
}
})}
{issues?.filter((i) => i.assignees?.length === 0).length > 0 ? (
<SingleProgressStats
title={
<>
<div className="h-5 w-5 rounded-full border-2 border-white bg-white">
<Image
src={User}
height="100%"
width="100%"
className="rounded-full"
alt="User"
/>
</div>
<span>No assignee</span>
</>
}
completed={
issues?.filter(
(i) => i.state_detail.group === "completed" && i.assignees?.length === 0
).length
}
total={issues?.filter((i) => i.assignees?.length === 0).length}
/>
) : (
""
)}
</Tab.Panel>
<Tab.Panel as="div" className="w-full flex flex-col ">
{issueLabels?.map((issue, index) => {
const totalArray = issues?.filter((i) => i.labels?.includes(issue.id));
const completeArray = totalArray?.filter((i) => i.state_detail.group === "completed");
if (totalArray.length > 0) {
return (
<SingleProgressStats
key={index}
title={
<>
<span
className="block h-2 w-2 rounded-full "
style={{
backgroundColor: issue.color,
}}
/>
<span className="text-xs capitalize">{issue.name}</span>
</>
}
completed={completeArray.length}
total={totalArray.length}
/>
);
}
})}
</Tab.Panel>
<Tab.Panel as="div" className="w-full flex flex-col ">
{Object.keys(groupedIssues).map((group, index) => (
<SingleProgressStats
key={index}
title={
<>
<span
className="block h-2 w-2 rounded-full "
style={{
backgroundColor: stateGroupColours[group],
}}
/>
<span className="text-xs capitalize">{group}</span>
</>
}
completed={groupedIssues[group].length}
total={issues.length}
/>
))}
</Tab.Panel>
</Tab.Panels>
</Tab.Group>
</div>
);
};

export default SidebarProgressStats;
29 changes: 29 additions & 0 deletions apps/app/components/core/sidebar/single-progress-stats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";

import { CircularProgressbar } from "react-circular-progressbar";

type TSingleProgressStatsProps = {
title: any;
completed: number;
total: number;
};

const SingleProgressStats: React.FC<TSingleProgressStatsProps> = ({ title, completed, total }) => (
<>
<div className="flex items-center justify-between w-full py-3 text-xs border-b-[1px] border-gray-200">
<div className="flex items-center justify-start w-1/2 gap-2">{title}</div>
<div className="flex items-center justify-end w-1/2 gap-1 px-2">
<div className="flex h-5 justify-center items-center gap-1 ">
<span className="h-4 w-4 ">
<CircularProgressbar value={completed} maxValue={total} strokeWidth={10} />
</span>
<span className="w-8 text-right">{Math.floor((completed / total) * 100)}%</span>
</div>
<span>of</span>
<span>{total}</span>
</div>
</div>
</>
);

export default SingleProgressStats;
5 changes: 4 additions & 1 deletion apps/app/components/issues/select/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import stateService from "services/state.service";
import { Squares2X2Icon, PlusIcon } from "@heroicons/react/24/outline";
// icons
import { Combobox, Transition } from "@headlessui/react";
// helpers
import { getStatesList } from "helpers/state.helper";
// fetch keys
import { STATE_LIST } from "constants/fetch-keys";

Expand All @@ -27,12 +29,13 @@ export const IssueStateSelect: React.FC<Props> = ({ setIsOpen, value, onChange,
const router = useRouter();
const { workspaceSlug } = router.query;

const { data: states } = useSWR(
const { data: stateGroups } = useSWR(
workspaceSlug && projectId ? STATE_LIST(projectId) : null,
workspaceSlug && projectId
? () => stateService.getStates(workspaceSlug as string, projectId)
: null
);
const states = getStatesList(stateGroups ?? {});

const options = states?.map((state) => ({
value: state.id,
Expand Down
7 changes: 1 addition & 6 deletions apps/app/components/issues/sidebar-select/blocked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,7 @@ export const SidebarBlockedSelect: React.FC<Props> = ({
"blocked_issue_ids",
selectedIssues.filter((i) => i !== val)
);
else {
const newBlocked = selectedIssues;
newBlocked.push(val);

setValue("blocked_issue_ids", newBlocked);
}
else setValue("blocked_issue_ids", [...selectedIssues, val]);
}}
>
<div className="relative m-1">
Expand Down
7 changes: 1 addition & 6 deletions apps/app/components/issues/sidebar-select/blocker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,7 @@ export const SidebarBlockerSelect: React.FC<Props> = ({
"blocker_issue_ids",
selectedIssues.filter((i) => i !== val)
);
else {
const newBlockers = selectedIssues;
newBlockers.push(val);

setValue("blocker_issue_ids", newBlockers);
}
else setValue("blocker_issue_ids", [...selectedIssues, val]);
}}
>
<div className="relative m-1">
Expand Down
Loading

0 comments on commit 7f406ce

Please sign in to comment.