diff --git a/apiserver/plane/api/views/oauth.py b/apiserver/plane/api/views/oauth.py index bcebfb294..994cb0466 100644 --- a/apiserver/plane/api/views/oauth.py +++ b/apiserver/plane/api/views/oauth.py @@ -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 ) @@ -106,9 +105,19 @@ def get_user_data(access_token: str) -> dict: resp = requests.get(url=url, headers=headers) - userData = resp.json() + user_data = resp.json() - return userData + 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 user_data class OauthEndpoint(BaseAPIView): @@ -116,7 +125,6 @@ class OauthEndpoint(BaseAPIView): 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) @@ -138,7 +146,6 @@ class OauthEndpoint(BaseAPIView): email = data.get("email", None) if email == None: - return Response( { "error": "Something went wrong. Please try again later or contact the support team." @@ -153,7 +160,6 @@ class OauthEndpoint(BaseAPIView): mobile_number = uuid.uuid4().hex email_verified = True else: - return Response( { "error": "Something went wrong. Please try again later or contact the support team." diff --git a/apps/app/components/account/github-login-button.tsx b/apps/app/components/account/github-login-button.tsx index e93abde88..80faecec5 100644 --- a/apps/app/components/account/github-login-button.tsx +++ b/apps/app/components/account/github-login-button.tsx @@ -34,7 +34,7 @@ export const GithubLoginButton: FC = (props) => { return ( @@ -166,7 +156,7 @@ const LabelsSettings: NextPage = (props) => {
@@ -227,7 +217,14 @@ const LabelsSettings: NextPage = (props) => { error={errors.name} />
- {isUpdating ? ( @@ -239,7 +236,11 @@ const LabelsSettings: NextPage = (props) => { {isSubmitting ? "Updating" : "Update"} ) : ( - )} diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/states.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/states.tsx index 52a095b2a..267f812a3 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/states.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/states.tsx @@ -1,10 +1,9 @@ import React, { useState } from "react"; import { useRouter } from "next/router"; -import useSWR from "swr"; -import { PencilSquareIcon, PlusIcon, TrashIcon } from "@heroicons/react/24/outline"; -import { IState } from "types"; +import useSWR from "swr"; + // services import stateService from "services/state.service"; import projectService from "services/project.service"; @@ -17,22 +16,18 @@ import { CreateUpdateStateInline, DeleteStateModal, StateGroup } from "component // ui import { Loader } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; +// icons +import { PencilSquareIcon, PlusIcon, TrashIcon } from "@heroicons/react/24/outline"; // helpers import { addSpaceIfCamelCase } from "helpers/string.helper"; -import { groupBy } from "helpers/array.helper"; +import { getStatesList, orderStateGroups } from "helpers/state.helper"; // types +import { UserAuth } from "types"; import type { NextPage, NextPageContext } from "next"; // fetch-keys import { PROJECT_DETAILS, STATE_LIST } from "constants/fetch-keys"; -type TStateSettingsProps = { - isMember: boolean; - isOwner: boolean; - isViewer: boolean; - isGuest: boolean; -}; - -const StatesSettings: NextPage = (props) => { +const StatesSettings: NextPage = (props) => { const { isMember, isOwner, isViewer, isGuest } = props; const [activeGroup, setActiveGroup] = useState(null); @@ -56,16 +51,14 @@ const StatesSettings: NextPage = (props) => { ? () => stateService.getStates(workspaceSlug as string, projectId as string) : null ); - - const groupedStates: { - [key: string]: IState[]; - } = groupBy(states ?? [], "group"); + const orderedStateGroups = orderStateGroups(states ?? {}); + const statesList = getStatesList(orderedStateGroups ?? {}); return ( <> state.id === selectDeleteState) ?? null} + data={statesList?.find((s) => s.id === selectDeleteState) ?? null} onClose={() => setSelectDeleteState(null)} /> = (props) => {
{states && projectDetails ? ( - Object.keys(groupedStates).map((key) => ( -
-
-

{key} states

- -
-
- {key === activeGroup && ( - { - setActiveGroup(null); - setSelectedState(null); - }} - workspaceSlug={workspaceSlug as string} - data={null} - selectedGroup={key as keyof StateGroup} - /> - )} - {groupedStates[key]?.map((state) => - state.id !== selectedState ? ( -
{ + if (orderedStateGroups[key].length !== 0) + return ( +
+
+

{key} states

+ - -
-
- ) : ( -
+ + Add + +
+
+ {key === activeGroup && ( { @@ -149,15 +105,60 @@ const StatesSettings: NextPage = (props) => { setSelectedState(null); }} workspaceSlug={workspaceSlug as string} - data={states?.find((state) => state.id === selectedState) ?? null} + data={null} selectedGroup={key as keyof StateGroup} /> -
- ) - )} -
-
- )) + )} + {orderedStateGroups[key].map((state) => + state.id !== selectedState ? ( +
+
+
+
{addSpaceIfCamelCase(state.name)}
+
+
+ + +
+
+ ) : ( +
+ { + setActiveGroup(null); + setSelectedState(null); + }} + workspaceSlug={workspaceSlug as string} + data={ + statesList?.find((state) => state.id === selectedState) ?? null + } + selectedGroup={key as keyof StateGroup} + /> +
+ ) + )} +
+
+ ); + }) ) : ( diff --git a/apps/app/pages/signin.tsx b/apps/app/pages/signin.tsx index 5ae6ebab6..0c14d541e 100644 --- a/apps/app/pages/signin.tsx +++ b/apps/app/pages/signin.tsx @@ -62,27 +62,30 @@ const SignInPage: NextPage = () => { } }; - const handleGithubSignIn = (githubToken: string) => { - setLoading(true); - authenticationService - .socialAuth({ - medium: "github", - credential: githubToken, - clientId: NEXT_PUBLIC_GITHUB_ID, - }) - .then(async () => { - await onSignInSuccess(); - }) - .catch((err) => { - console.log(err); - setToastAlert({ - title: "Error signing in!", - type: "error", - message: "Something went wrong. Please try again later or contact the support team.", + const handleGithubSignIn = useCallback( + (credential: string) => { + setLoading(true); + authenticationService + .socialAuth({ + medium: "github", + credential, + clientId: NEXT_PUBLIC_GITHUB_ID, + }) + .then(async () => { + await onSignInSuccess(); + }) + .catch((err) => { + console.log(err); + setToastAlert({ + title: "Error signing in!", + type: "error", + message: "Something went wrong. Please try again later or contact the support team.", + }); + setLoading(false); }); - setLoading(false); - }); - }; + }, + [onSignInSuccess, setToastAlert] + ); return ( { + async getStates(workspaceSlug: string, projectId: string): Promise { return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/states/`) .then((response) => response?.data) .catch((error) => { diff --git a/apps/app/types/state.d.ts b/apps/app/types/state.d.ts index c6da87925..5f69ae49f 100644 --- a/apps/app/types/state.d.ts +++ b/apps/app/types/state.d.ts @@ -13,3 +13,7 @@ export interface IState { sequence: number; group: "backlog" | "unstarted" | "started" | "completed" | "cancelled"; } + +export interface StateResponse { + [key: string]: IState[]; +} diff --git a/turbo.json b/turbo.json index b4658a0df..f20ceecdf 100644 --- a/turbo.json +++ b/turbo.json @@ -7,7 +7,9 @@ "NEXT_PUBLIC_DOCSEARCH_API_KEY", "NEXT_PUBLIC_DOCSEARCH_APP_ID", "NEXT_PUBLIC_DOCSEARCH_INDEX_NAME", - "NEXT_PUBLIC_SENTRY_DSN" + "NEXT_PUBLIC_SENTRY_DSN", + "SENTRY_AUTH_TOKEN", + "NEXT_PUBLIC_SENTRY_ENVIRONMENT" ], "pipeline": { "build": {