From b4c4271f66768763eb88d227029931f4056ec3a9 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Thu, 23 Feb 2023 22:34:36 +0530 Subject: [PATCH] style: kanban dropdowns, github integration loaders --- apps/app/components/breadcrumbs/index.tsx | 2 +- .../core/board-view/single-issue.tsx | 5 +- .../components/core/sidebar/links-list.tsx | 6 +- .../issues/view-select/assignee.tsx | 12 ++-- .../issues/view-select/priority.tsx | 5 +- .../components/issues/view-select/state.tsx | 5 +- apps/app/components/popup/index.tsx | 65 +++++++++++-------- apps/app/components/ui/custom-select.tsx | 14 ++-- apps/app/helpers/string.helper.ts | 3 + .../projects/[projectId]/cycles/[cycleId].tsx | 6 +- .../[projectId]/modules/[moduleId].tsx | 6 +- .../[workspaceSlug]/settings/integrations.tsx | 22 +++++-- 12 files changed, 91 insertions(+), 60 deletions(-) diff --git a/apps/app/components/breadcrumbs/index.tsx b/apps/app/components/breadcrumbs/index.tsx index ccd17fb4e..c561514fa 100644 --- a/apps/app/components/breadcrumbs/index.tsx +++ b/apps/app/components/breadcrumbs/index.tsx @@ -15,7 +15,7 @@ const Breadcrumbs = ({ children }: BreadcrumbsProps) => { <>
router.back()} > diff --git a/apps/app/components/core/board-view/single-issue.tsx b/apps/app/components/core/board-view/single-issue.tsx index 1e9c4ddd5..4c8e4bdf0 100644 --- a/apps/app/components/core/board-view/single-issue.tsx +++ b/apps/app/components/core/board-view/single-issue.tsx @@ -226,12 +226,13 @@ export const SingleBoardIssue: React.FC = ({ -
+
{properties.priority && selectedGroup !== "priority" && ( )} {properties.state && selectedGroup !== "state_detail.name" && ( @@ -239,6 +240,7 @@ export const SingleBoardIssue: React.FC = ({ issue={issue} partialUpdateIssue={partialUpdateIssue} isNotAllowed={isNotAllowed} + selfPositioned /> )} {properties.due_date && ( @@ -276,6 +278,7 @@ export const SingleBoardIssue: React.FC = ({ issue={issue} partialUpdateIssue={partialUpdateIssue} isNotAllowed={isNotAllowed} + selfPositioned /> )}
diff --git a/apps/app/components/core/sidebar/links-list.tsx b/apps/app/components/core/sidebar/links-list.tsx index 55f41775c..8553ee43c 100644 --- a/apps/app/components/core/sidebar/links-list.tsx +++ b/apps/app/components/core/sidebar/links-list.tsx @@ -29,7 +29,7 @@ export const LinksList: React.FC = ({ links, handleDeleteLink, userAuth } {links.map((link) => (
{!isNotAllowed && ( -
+ diff --git a/apps/app/components/issues/view-select/assignee.tsx b/apps/app/components/issues/view-select/assignee.tsx index ba7816471..e1dd2ee33 100644 --- a/apps/app/components/issues/view-select/assignee.tsx +++ b/apps/app/components/issues/view-select/assignee.tsx @@ -18,14 +18,14 @@ import { PROJECT_MEMBERS } from "constants/fetch-keys"; type Props = { issue: IIssue; partialUpdateIssue: (formData: Partial) => void; - position?: "left" | "right"; + selfPositioned?: boolean; isNotAllowed: boolean; }; export const ViewAssigneeSelect: React.FC = ({ issue, partialUpdateIssue, - position = "right", + selfPositioned = false, isNotAllowed, }) => { const router = useRouter(); @@ -50,7 +50,7 @@ export const ViewAssigneeSelect: React.FC = ({ partialUpdateIssue({ assignees_list: newData }); }} - className="group relative flex-shrink-0" + className={`group ${!selfPositioned ? "relative" : ""} flex-shrink-0`} disabled={isNotAllowed} > {({ open }) => ( @@ -86,11 +86,7 @@ export const ViewAssigneeSelect: React.FC = ({ leaveFrom="opacity-100" leaveTo="opacity-0" > - + {members?.map((member) => ( ) => void; - position?: "left" | "right"; + selfPositioned?: boolean; isNotAllowed: boolean; }; export const ViewPrioritySelect: React.FC = ({ issue, partialUpdateIssue, - position = "right", + selfPositioned = false, isNotAllowed, }) => ( = ({ } border-none`} noChevron disabled={isNotAllowed} + selfPositioned={selfPositioned} > {PRIORITIES?.map((priority) => ( diff --git a/apps/app/components/issues/view-select/state.tsx b/apps/app/components/issues/view-select/state.tsx index 0f516f2c9..704bef426 100644 --- a/apps/app/components/issues/view-select/state.tsx +++ b/apps/app/components/issues/view-select/state.tsx @@ -17,14 +17,14 @@ import { STATE_LIST } from "constants/fetch-keys"; type Props = { issue: IIssue; partialUpdateIssue: (formData: Partial) => void; - position?: "left" | "right"; + selfPositioned?: boolean; isNotAllowed: boolean; }; export const ViewStateSelect: React.FC = ({ issue, partialUpdateIssue, - position = "right", + selfPositioned = false, isNotAllowed, }) => { const router = useRouter(); @@ -67,6 +67,7 @@ export const ViewStateSelect: React.FC = ({ maxHeight="md" noChevron disabled={isNotAllowed} + selfPositioned={selfPositioned} > {states?.map((state) => ( diff --git a/apps/app/components/popup/index.tsx b/apps/app/components/popup/index.tsx index a59358f38..9c18eb916 100644 --- a/apps/app/components/popup/index.tsx +++ b/apps/app/components/popup/index.tsx @@ -8,7 +8,7 @@ import workspaceService from "services/workspace.service"; // hooks import useToast from "hooks/use-toast"; // ui -import { Button } from "components/ui"; +import { Button, Loader } from "components/ui"; // icons import GithubLogo from "public/logos/github-black.png"; import useSWR, { mutate } from "swr"; @@ -105,38 +105,49 @@ const OAuthPopUp = ({ integration }: any) => {

{integration.title} - {isInstalled ? ( - - Installed - - ) : ( - - Not - Installed - - )} + {workspaceIntegrations ? ( + isInstalled ? ( + + Installed + + ) : ( + + Not + Installed + + ) + ) : null}

- {isInstalled - ? "Activate GitHub integrations on individual projects to sync with specific repositories." - : "Connect with GitHub with your Plane workspace to sync project issues."} + {workspaceIntegrations + ? isInstalled + ? "Activate GitHub integrations on individual projects to sync with specific repositories." + : "Connect with GitHub with your Plane workspace to sync project issues." + : "Loading..."}

- {isInstalled ? ( - + + {workspaceIntegrations ? ( + isInstalled ? ( + + ) : ( + + ) ) : ( - + + + )}
); diff --git a/apps/app/components/ui/custom-select.tsx b/apps/app/components/ui/custom-select.tsx index a7d9df3d5..677d7dab5 100644 --- a/apps/app/components/ui/custom-select.tsx +++ b/apps/app/components/ui/custom-select.tsx @@ -15,7 +15,9 @@ type CustomSelectProps = { input?: boolean; noChevron?: boolean; buttonClassName?: string; + optionsClassName?: string; disabled?: boolean; + selfPositioned?: boolean; }; const CustomSelect = ({ @@ -29,13 +31,15 @@ const CustomSelect = ({ input = false, noChevron = false, buttonClassName = "", + optionsClassName = "", disabled = false, + selfPositioned = false, }: CustomSelectProps) => (
@@ -67,8 +71,8 @@ const CustomSelect = ({ leaveTo="transform opacity-0 scale-95" > = ({ children, value, className }) => ( - `${active || selected ? "bg-indigo-50" : ""} ${ + `${className} ${active || selected ? "bg-indigo-50" : ""} ${ selected ? "font-medium" : "" - } relative flex cursor-pointer select-none items-center gap-2 truncate p-2 text-gray-900 ${className}` + } relative flex cursor-pointer select-none items-center gap-2 truncate p-2 text-gray-900` } > {children} diff --git a/apps/app/helpers/string.helper.ts b/apps/app/helpers/string.helper.ts index 546a15634..f1c64bdf5 100644 --- a/apps/app/helpers/string.helper.ts +++ b/apps/app/helpers/string.helper.ts @@ -4,6 +4,9 @@ export const replaceUnderscoreIfSnakeCase = (str: string) => str.replace(/_/g, " export const capitalizeFirstLetter = (str: string) => str.charAt(0).toUpperCase() + str.slice(1); +export const truncateText = (str: string, length: number) => + str.length > length ? `${str.substring(0, length)}...` : str; + export const createSimilarString = (str: string) => { const shuffled = str .split("") diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx index 518fb06ff..771387877 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx @@ -23,6 +23,8 @@ import projectService from "services/project.service"; // ui import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; +// helpers +import { truncateText } from "helpers/string.helper"; // types import { CycleIssueResponse, UserAuth } from "types"; // fetch-keys @@ -135,7 +137,7 @@ const SingleCycle: React.FC = (props) => { label={ <> - {cycleDetails?.name} + {cycleDetails?.name && truncateText(cycleDetails.name, 40)} } className="ml-1.5" @@ -147,7 +149,7 @@ const SingleCycle: React.FC = (props) => { renderAs="a" href={`/${workspaceSlug}/projects/${activeProject?.id}/cycles/${cycle.id}`} > - {cycle.name} + {truncateText(cycle.name, 40)} ))} diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx index b0e8eeb59..7bfe0052e 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/modules/[moduleId].tsx @@ -27,6 +27,8 @@ import { ModuleDetailsSidebar } from "components/modules"; // ui import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; +// helpers +import { truncateText } from "helpers/string.helper"; // types import { IModule, ModuleIssueResponse, UserAuth } from "types"; @@ -130,7 +132,7 @@ const SingleModule: React.FC = (props) => { label={ <> - {moduleDetails?.name} + {moduleDetails?.name && truncateText(moduleDetails.name, 40)} } className="ml-1.5" @@ -142,7 +144,7 @@ const SingleModule: React.FC = (props) => { renderAs="a" href={`/${workspaceSlug}/projects/${projectId}/modules/${module.id}`} > - {module.name} + {truncateText(module.name, 40)} ))} diff --git a/apps/app/pages/[workspaceSlug]/settings/integrations.tsx b/apps/app/pages/[workspaceSlug]/settings/integrations.tsx index f3620c781..06e72be3b 100644 --- a/apps/app/pages/[workspaceSlug]/settings/integrations.tsx +++ b/apps/app/pages/[workspaceSlug]/settings/integrations.tsx @@ -13,6 +13,7 @@ import AppLayout from "layouts/app-layout"; // componentss import OAuthPopUp from "components/popup"; // ui +import { Loader } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; // types import type { NextPage, GetServerSideProps } from "next"; @@ -54,13 +55,20 @@ const WorkspaceIntegrations: NextPage = (props) => {

Manage the workspace integrations.

- {integrations?.map((integration) => ( - - ))} + {integrations ? ( + integrations.map((integration) => ( + + )) + ) : ( + + + + + )}