chore: optimizations and file name changes (#2845)
* fix: deepsource antipatterns * fix: deepsource exclude file patterns * chore: file name changes and removed unwanted variables * fix: changing version number for editor
This commit is contained in:
parent
d6abb87a3a
commit
fa8ae6b8ce
47 changed files with 381 additions and 349 deletions
|
|
@ -1,55 +0,0 @@
|
|||
import { TextArea } from "@plane/ui";
|
||||
import { Control, Controller, FieldErrors } from "react-hook-form";
|
||||
import { IApiToken } from "types/api_token";
|
||||
import { IApiFormFields } from "./types";
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
|
||||
interface IApiTokenDescription {
|
||||
generatedToken: IApiToken | null | undefined;
|
||||
control: Control<IApiFormFields, any>;
|
||||
focusDescription: boolean;
|
||||
setFocusTitle: Dispatch<SetStateAction<boolean>>;
|
||||
setFocusDescription: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export const ApiTokenDescription = ({
|
||||
generatedToken,
|
||||
control,
|
||||
focusDescription,
|
||||
setFocusTitle,
|
||||
setFocusDescription,
|
||||
}: IApiTokenDescription) => (
|
||||
<Controller
|
||||
control={control}
|
||||
name="description"
|
||||
render={({ field: { value, onChange } }) =>
|
||||
focusDescription ? (
|
||||
<TextArea
|
||||
id="description"
|
||||
name="description"
|
||||
autoFocus={true}
|
||||
onBlur={() => {
|
||||
setFocusDescription(false);
|
||||
}}
|
||||
value={value}
|
||||
defaultValue={value}
|
||||
onChange={onChange}
|
||||
placeholder="Description"
|
||||
className="mt-3"
|
||||
rows={3}
|
||||
/>
|
||||
) : (
|
||||
<p
|
||||
onClick={() => {
|
||||
if (generatedToken != null) return;
|
||||
setFocusTitle(false);
|
||||
setFocusDescription(true);
|
||||
}}
|
||||
className={`${value.length === 0 ? "text-custom-text-400/60" : "text-custom-text-300"} text-lg pt-3`}
|
||||
>
|
||||
{value.length != 0 ? value : "Description"}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
import { Menu, Transition } from "@headlessui/react";
|
||||
import { ToggleSwitch } from "@plane/ui";
|
||||
import { Dispatch, Fragment, SetStateAction } from "react";
|
||||
import { Control, Controller } from "react-hook-form";
|
||||
import { IApiFormFields } from "./types";
|
||||
|
||||
interface IApiTokenExpiry {
|
||||
neverExpires: boolean;
|
||||
selectedExpiry: number;
|
||||
setSelectedExpiry: Dispatch<SetStateAction<number>>;
|
||||
setNeverExpire: Dispatch<SetStateAction<boolean>>;
|
||||
renderExpiry: () => string;
|
||||
control: Control<IApiFormFields, any>;
|
||||
}
|
||||
|
||||
export const expiryOptions = [
|
||||
{
|
||||
title: "7 Days",
|
||||
days: 7,
|
||||
},
|
||||
{
|
||||
title: "30 Days",
|
||||
days: 30,
|
||||
},
|
||||
{
|
||||
title: "1 Month",
|
||||
days: 30,
|
||||
},
|
||||
{
|
||||
title: "3 Months",
|
||||
days: 90,
|
||||
},
|
||||
{
|
||||
title: "1 Year",
|
||||
days: 365,
|
||||
},
|
||||
];
|
||||
|
||||
export const ApiTokenExpiry = ({
|
||||
neverExpires,
|
||||
selectedExpiry,
|
||||
setSelectedExpiry,
|
||||
setNeverExpire,
|
||||
renderExpiry,
|
||||
control,
|
||||
}: IApiTokenExpiry) => (
|
||||
<>
|
||||
<Menu>
|
||||
<p className="text-sm font-medium mb-2"> Expiration Date</p>
|
||||
<Menu.Button className={"w-[40%]"} disabled={neverExpires}>
|
||||
<div className="py-3 w-full font-medium px-3 flex border border-custom-border-200 rounded-md justify-center items-baseline">
|
||||
<p className={`text-base ${neverExpires ? "text-custom-text-400/40" : ""}`}>
|
||||
{expiryOptions[selectedExpiry].title.toLocaleLowerCase()}
|
||||
</p>
|
||||
<p className={`text-sm mr-auto ml-2 text-custom-text-400${neverExpires ? "/40" : ""}`}>({renderExpiry()})</p>
|
||||
</div>
|
||||
</Menu.Button>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
enter="transition ease-out duration-100"
|
||||
enterFrom="transform opacity-0 scale-95"
|
||||
enterTo="transform opacity-100 scale-100"
|
||||
leave="transition ease-in duration-75"
|
||||
leaveFrom="transform opacity-100 scale-100"
|
||||
leaveTo="transform opacity-0 scale-95"
|
||||
>
|
||||
<Menu.Items className="absolute z-10 overflow-y-scroll whitespace-nowrap rounded-sm max-h-36 border origin-top-right mt-1 overflow-auto min-w-[10rem] border-custom-border-100 p-1 shadow-lg focus:outline-none bg-custom-background-100">
|
||||
{expiryOptions.map((option, index) => (
|
||||
<Menu.Item key={index}>
|
||||
{({ active }) => (
|
||||
<div className="py-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setSelectedExpiry(index);
|
||||
}}
|
||||
className={`w-full text-sm select-none truncate rounded px-3 py-1.5 text-left text-custom-text-300 hover:bg-custom-background-80 ${
|
||||
active ? "bg-custom-background-80" : ""
|
||||
}`}
|
||||
>
|
||||
{option.title}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.Items>
|
||||
</Transition>
|
||||
</Menu>
|
||||
|
||||
<div className="mt-4 mb-6 flex items-center">
|
||||
<span className="text-sm font-medium"> Never Expires</span>
|
||||
<Controller
|
||||
control={control}
|
||||
name="never_expires"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<ToggleSwitch
|
||||
className="ml-3"
|
||||
value={value}
|
||||
onChange={(val) => {
|
||||
onChange(val);
|
||||
setNeverExpire(val);
|
||||
}}
|
||||
size="sm"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
import { Input } from "@plane/ui";
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { Control, Controller, FieldErrors } from "react-hook-form";
|
||||
import { IApiToken } from "types/api_token";
|
||||
import { IApiFormFields } from "./types";
|
||||
|
||||
interface IApiTokenTitle {
|
||||
generatedToken: IApiToken | null | undefined;
|
||||
errors: FieldErrors<IApiFormFields>;
|
||||
control: Control<IApiFormFields, any>;
|
||||
focusTitle: boolean;
|
||||
setFocusTitle: Dispatch<SetStateAction<boolean>>;
|
||||
setFocusDescription: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export const ApiTokenTitle = ({
|
||||
generatedToken,
|
||||
errors,
|
||||
control,
|
||||
focusTitle,
|
||||
setFocusTitle,
|
||||
setFocusDescription,
|
||||
}: IApiTokenTitle) => (
|
||||
<Controller
|
||||
control={control}
|
||||
name="title"
|
||||
rules={{
|
||||
required: "Title is required",
|
||||
maxLength: {
|
||||
value: 255,
|
||||
message: "Title should be less than 255 characters",
|
||||
},
|
||||
}}
|
||||
render={({ field: { value, onChange, ref } }) =>
|
||||
focusTitle ? (
|
||||
<Input
|
||||
id="title"
|
||||
name="title"
|
||||
type="text"
|
||||
inputSize="md"
|
||||
onBlur={() => {
|
||||
setFocusTitle(false);
|
||||
}}
|
||||
onError={() => {
|
||||
console.log("error");
|
||||
}}
|
||||
autoFocus={true}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
ref={ref}
|
||||
hasError={!!errors.title}
|
||||
placeholder="Title"
|
||||
className="resize-none text-xl w-full"
|
||||
/>
|
||||
) : (
|
||||
<p
|
||||
onClick={() => {
|
||||
if (generatedToken != null) return;
|
||||
setFocusDescription(false);
|
||||
setFocusTitle(true);
|
||||
}}
|
||||
className={`${value.length === 0 ? "text-custom-text-400/60" : ""} font-medium text-[24px]`}
|
||||
>
|
||||
{value.length != 0 ? value : "Api Title"}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
export interface IApiFormFields {
|
||||
never_expires: boolean;
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import { Button } from "@plane/ui";
|
|||
//hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
//services
|
||||
import { ApiTokenService } from "services/api_token.service";
|
||||
import { APITokenService } from "services/api_token.service";
|
||||
//headless ui
|
||||
import { Dialog, Transition } from "@headlessui/react";
|
||||
|
||||
|
|
@ -17,10 +17,15 @@ type Props = {
|
|||
tokenId?: string;
|
||||
};
|
||||
|
||||
const apiTokenService = new ApiTokenService();
|
||||
const DeleteTokenModal: FC<Props> = ({ isOpen, handleClose, tokenId }) => {
|
||||
const apiTokenService = new APITokenService();
|
||||
|
||||
export const DeleteTokenModal: FC<Props> = (props) => {
|
||||
const { isOpen, handleClose, tokenId } = props;
|
||||
// states
|
||||
const [deleteLoading, setDeleteLoading] = useState<boolean>(false);
|
||||
// hooks
|
||||
const { setToastAlert } = useToast();
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, tokenId: tokenIdFromQuery } = router.query;
|
||||
|
||||
|
|
@ -107,5 +112,3 @@ const DeleteTokenModal: FC<Props> = ({ isOpen, handleClose, tokenId }) => {
|
|||
</Transition.Root>
|
||||
);
|
||||
};
|
||||
|
||||
export default DeleteTokenModal;
|
||||
|
|
|
|||
|
|
@ -8,10 +8,13 @@ import { Button } from "@plane/ui";
|
|||
// assets
|
||||
import emptyApiTokens from "public/empty-state/api-token.svg";
|
||||
|
||||
const ApiTokenEmptyState = () => {
|
||||
export const APITokenEmptyState = () => {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<div className={`flex items-center justify-center mx-auto rounded-sm border border-custom-border-200 bg-custom-background-90 py-10 px-16 w-full`}>
|
||||
<div
|
||||
className={`flex items-center justify-center mx-auto rounded-sm border border-custom-border-200 bg-custom-background-90 py-10 px-16 w-full`}
|
||||
>
|
||||
<div className="text-center flex flex-col items-center w-full">
|
||||
<Image src={emptyApiTokens} className="w-52 sm:w-60" alt="empty" />
|
||||
<h6 className="text-xl font-semibold mt-6 sm:mt-8 mb-3">No API Tokens</h6>
|
||||
|
|
@ -32,5 +35,3 @@ const ApiTokenEmptyState = () => {
|
|||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ApiTokenEmptyState;
|
||||
|
|
|
|||
|
|
@ -1,36 +1,53 @@
|
|||
import { Dispatch, SetStateAction, useState, FC } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { addDays, renderDateFormat } from "helpers/date-time.helper";
|
||||
import { IApiToken } from "types/api_token";
|
||||
import { csvDownload } from "helpers/download.helper";
|
||||
import { useRouter } from "next/router";
|
||||
import { Dispatch, SetStateAction, useState } from "react";
|
||||
import useToast from "hooks/use-toast";
|
||||
// helpers
|
||||
import { addDays, renderDateFormat } from "helpers/date-time.helper";
|
||||
import { csvDownload } from "helpers/download.helper";
|
||||
// types
|
||||
import { IApiToken } from "types/api_token";
|
||||
// hooks
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
import { ApiTokenService } from "services/api_token.service";
|
||||
import { ApiTokenTitle } from "./ApiTokenTitle";
|
||||
import { ApiTokenDescription } from "./ApiTokenDescription";
|
||||
import { ApiTokenExpiry, expiryOptions } from "./ApiTokenExpiry";
|
||||
import useToast from "hooks/use-toast";
|
||||
// services
|
||||
import { APITokenService } from "services/api_token.service";
|
||||
// components
|
||||
import { APITokenTitle } from "./token-title";
|
||||
import { APITokenDescription } from "./token-description";
|
||||
import { APITokenExpiry, EXPIRY_OPTIONS } from "./token-expiry";
|
||||
import { APITokenKeySection } from "./token-key-section";
|
||||
// ui
|
||||
import { Button } from "@plane/ui";
|
||||
import { ApiTokenKeySection } from "./ApiTokenKeySection";
|
||||
|
||||
interface IApiTokenForm {
|
||||
interface APITokenFormProps {
|
||||
generatedToken: IApiToken | null | undefined;
|
||||
setGeneratedToken: Dispatch<SetStateAction<IApiToken | null | undefined>>;
|
||||
setDeleteTokenModal: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
const apiTokenService = new ApiTokenService();
|
||||
export const ApiTokenForm = ({ generatedToken, setGeneratedToken, setDeleteTokenModal }: IApiTokenForm) => {
|
||||
export interface APIFormFields {
|
||||
never_expires: boolean;
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
const apiTokenService = new APITokenService();
|
||||
|
||||
export const APITokenForm: FC<APITokenFormProps> = (props) => {
|
||||
const { generatedToken, setGeneratedToken, setDeleteTokenModal } = props;
|
||||
// states
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [neverExpires, setNeverExpire] = useState<boolean>(false);
|
||||
const [focusTitle, setFocusTitle] = useState<boolean>(false);
|
||||
const [focusDescription, setFocusDescription] = useState<boolean>(false);
|
||||
const [selectedExpiry, setSelectedExpiry] = useState<number>(1);
|
||||
|
||||
// hooks
|
||||
const { setToastAlert } = useToast();
|
||||
const { theme: themStore } = useMobxStore();
|
||||
|
||||
// store
|
||||
const {
|
||||
theme: { sidebarCollapsed },
|
||||
} = useMobxStore();
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
||||
|
|
@ -48,11 +65,11 @@ export const ApiTokenForm = ({ generatedToken, setGeneratedToken, setDeleteToken
|
|||
|
||||
const getExpiryDate = (): string | null => {
|
||||
if (neverExpires === true) return null;
|
||||
return addDays({ date: new Date(), days: expiryOptions[selectedExpiry].days }).toISOString();
|
||||
return addDays({ date: new Date(), days: EXPIRY_OPTIONS[selectedExpiry].days }).toISOString();
|
||||
};
|
||||
|
||||
function renderExpiry(): string {
|
||||
return renderDateFormat(addDays({ date: new Date(), days: expiryOptions[selectedExpiry].days }), true);
|
||||
return renderDateFormat(addDays({ date: new Date(), days: EXPIRY_OPTIONS[selectedExpiry].days }), true);
|
||||
}
|
||||
|
||||
const downloadSecretKey = (token: IApiToken) => {
|
||||
|
|
@ -95,10 +112,10 @@ export const ApiTokenForm = ({ generatedToken, setGeneratedToken, setDeleteToken
|
|||
setFocusTitle(true);
|
||||
}
|
||||
})}
|
||||
className={`${themStore.sidebarCollapsed ? "xl:w-[50%] lg:w-[60%] " : "w-[60%]"} mx-auto py-8`}
|
||||
className={`${sidebarCollapsed ? "xl:w-[50%] lg:w-[60%] " : "w-[60%]"} mx-auto py-8`}
|
||||
>
|
||||
<div className="border-b border-custom-border-200 pb-4">
|
||||
<ApiTokenTitle
|
||||
<APITokenTitle
|
||||
generatedToken={generatedToken}
|
||||
control={control}
|
||||
errors={errors}
|
||||
|
|
@ -107,7 +124,7 @@ export const ApiTokenForm = ({ generatedToken, setGeneratedToken, setDeleteToken
|
|||
setFocusDescription={setFocusDescription}
|
||||
/>
|
||||
{errors.title && focusTitle && <p className=" text-red-600">{errors.title.message}</p>}
|
||||
<ApiTokenDescription
|
||||
<APITokenDescription
|
||||
generatedToken={generatedToken}
|
||||
control={control}
|
||||
focusDescription={focusDescription}
|
||||
|
|
@ -119,7 +136,7 @@ export const ApiTokenForm = ({ generatedToken, setGeneratedToken, setDeleteToken
|
|||
{!generatedToken && (
|
||||
<div className="mt-12">
|
||||
<>
|
||||
<ApiTokenExpiry
|
||||
<APITokenExpiry
|
||||
neverExpires={neverExpires}
|
||||
selectedExpiry={selectedExpiry}
|
||||
setSelectedExpiry={setSelectedExpiry}
|
||||
|
|
@ -133,7 +150,7 @@ export const ApiTokenForm = ({ generatedToken, setGeneratedToken, setDeleteToken
|
|||
</>
|
||||
</div>
|
||||
)}
|
||||
<ApiTokenKeySection
|
||||
<APITokenKeySection
|
||||
generatedToken={generatedToken}
|
||||
renderExpiry={renderExpiry}
|
||||
setDeleteTokenModal={setDeleteTokenModal}
|
||||
56
web/components/api-token/form/token-description.tsx
Normal file
56
web/components/api-token/form/token-description.tsx
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import { Dispatch, FC, SetStateAction } from "react";
|
||||
import { Control, Controller } from "react-hook-form";
|
||||
// ui
|
||||
import { TextArea } from "@plane/ui";
|
||||
// types
|
||||
import { IApiToken } from "types/api_token";
|
||||
import type { APIFormFields } from "./index";
|
||||
|
||||
interface APITokenDescriptionProps {
|
||||
generatedToken: IApiToken | null | undefined;
|
||||
control: Control<APIFormFields, any>;
|
||||
focusDescription: boolean;
|
||||
setFocusTitle: Dispatch<SetStateAction<boolean>>;
|
||||
setFocusDescription: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export const APITokenDescription: FC<APITokenDescriptionProps> = (props) => {
|
||||
const { generatedToken, control, focusDescription, setFocusTitle, setFocusDescription } = props;
|
||||
|
||||
return (
|
||||
<Controller
|
||||
control={control}
|
||||
name="description"
|
||||
render={({ field: { value, onChange } }) =>
|
||||
focusDescription ? (
|
||||
<TextArea
|
||||
id="description"
|
||||
name="description"
|
||||
autoFocus={true}
|
||||
onBlur={() => {
|
||||
setFocusDescription(false);
|
||||
}}
|
||||
value={value}
|
||||
defaultValue={value}
|
||||
onChange={onChange}
|
||||
placeholder="Description"
|
||||
className="mt-3"
|
||||
rows={3}
|
||||
/>
|
||||
) : (
|
||||
<p
|
||||
onClick={() => {
|
||||
if (generatedToken != null) return;
|
||||
setFocusTitle(false);
|
||||
setFocusDescription(true);
|
||||
}}
|
||||
role="button"
|
||||
className={`${value.length === 0 ? "text-custom-text-400/60" : "text-custom-text-300"} text-lg pt-3`}
|
||||
>
|
||||
{value.length != 0 ? value : "Description"}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
111
web/components/api-token/form/token-expiry.tsx
Normal file
111
web/components/api-token/form/token-expiry.tsx
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import { Dispatch, Fragment, SetStateAction, FC } from "react";
|
||||
import { Control, Controller } from "react-hook-form";
|
||||
import { Menu, Transition } from "@headlessui/react";
|
||||
// ui
|
||||
import { ToggleSwitch } from "@plane/ui";
|
||||
// types
|
||||
import { APIFormFields } from "./index";
|
||||
|
||||
interface APITokenExpiryProps {
|
||||
neverExpires: boolean;
|
||||
selectedExpiry: number;
|
||||
setSelectedExpiry: Dispatch<SetStateAction<number>>;
|
||||
setNeverExpire: Dispatch<SetStateAction<boolean>>;
|
||||
renderExpiry: () => string;
|
||||
control: Control<APIFormFields, any>;
|
||||
}
|
||||
|
||||
export const EXPIRY_OPTIONS = [
|
||||
{
|
||||
title: "7 Days",
|
||||
days: 7,
|
||||
},
|
||||
{
|
||||
title: "30 Days",
|
||||
days: 30,
|
||||
},
|
||||
{
|
||||
title: "1 Month",
|
||||
days: 30,
|
||||
},
|
||||
{
|
||||
title: "3 Months",
|
||||
days: 90,
|
||||
},
|
||||
{
|
||||
title: "1 Year",
|
||||
days: 365,
|
||||
},
|
||||
];
|
||||
|
||||
export const APITokenExpiry: FC<APITokenExpiryProps> = (props) => {
|
||||
const { neverExpires, selectedExpiry, setSelectedExpiry, setNeverExpire, renderExpiry, control } = props;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Menu>
|
||||
<p className="text-sm font-medium mb-2"> Expiration Date</p>
|
||||
<Menu.Button className={"w-[40%]"} disabled={neverExpires}>
|
||||
<div className="py-3 w-full font-medium px-3 flex border border-custom-border-200 rounded-md justify-center items-baseline">
|
||||
<p className={`text-base ${neverExpires ? "text-custom-text-400/40" : ""}`}>
|
||||
{EXPIRY_OPTIONS[selectedExpiry].title.toLocaleLowerCase()}
|
||||
</p>
|
||||
<p className={`text-sm mr-auto ml-2 text-custom-text-400${neverExpires ? "/40" : ""}`}>
|
||||
({renderExpiry()})
|
||||
</p>
|
||||
</div>
|
||||
</Menu.Button>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
enter="transition ease-out duration-100"
|
||||
enterFrom="transform opacity-0 scale-95"
|
||||
enterTo="transform opacity-100 scale-100"
|
||||
leave="transition ease-in duration-75"
|
||||
leaveFrom="transform opacity-100 scale-100"
|
||||
leaveTo="transform opacity-0 scale-95"
|
||||
>
|
||||
<Menu.Items className="absolute z-10 overflow-y-scroll whitespace-nowrap rounded-sm max-h-36 border origin-top-right mt-1 overflow-auto min-w-[10rem] border-custom-border-100 p-1 shadow-lg focus:outline-none bg-custom-background-100">
|
||||
{EXPIRY_OPTIONS.map((option, index) => (
|
||||
<Menu.Item key={index}>
|
||||
{({ active }) => (
|
||||
<div className="py-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setSelectedExpiry(index);
|
||||
}}
|
||||
className={`w-full text-sm select-none truncate rounded px-3 py-1.5 text-left text-custom-text-300 hover:bg-custom-background-80 ${
|
||||
active ? "bg-custom-background-80" : ""
|
||||
}`}
|
||||
>
|
||||
{option.title}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.Items>
|
||||
</Transition>
|
||||
</Menu>
|
||||
|
||||
<div className="mt-4 mb-6 flex items-center">
|
||||
<span className="text-sm font-medium"> Never Expires</span>
|
||||
<Controller
|
||||
control={control}
|
||||
name="never_expires"
|
||||
render={({ field: { onChange, value } }) => (
|
||||
<ToggleSwitch
|
||||
className="ml-3"
|
||||
value={value}
|
||||
onChange={(val) => {
|
||||
onChange(val);
|
||||
setNeverExpire(val);
|
||||
}}
|
||||
size="sm"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,16 +1,22 @@
|
|||
import { Button } from "@plane/ui";
|
||||
import useToast from "hooks/use-toast";
|
||||
import { Dispatch, SetStateAction, FC } from "react";
|
||||
// icons
|
||||
import { Copy } from "lucide-react";
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
// ui
|
||||
import { Button } from "@plane/ui";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
// types
|
||||
import { IApiToken } from "types/api_token";
|
||||
|
||||
interface IApiTokenKeySection {
|
||||
interface APITokenKeySectionProps {
|
||||
generatedToken: IApiToken | null | undefined;
|
||||
renderExpiry: () => string;
|
||||
setDeleteTokenModal: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export const ApiTokenKeySection = ({ generatedToken, renderExpiry, setDeleteTokenModal }: IApiTokenKeySection) => {
|
||||
export const APITokenKeySection: FC<APITokenKeySectionProps> = (props) => {
|
||||
const { generatedToken, renderExpiry, setDeleteTokenModal } = props;
|
||||
// hooks
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
return generatedToken ? (
|
||||
69
web/components/api-token/form/token-title.tsx
Normal file
69
web/components/api-token/form/token-title.tsx
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { Dispatch, FC, SetStateAction } from "react";
|
||||
import { Control, Controller, FieldErrors } from "react-hook-form";
|
||||
// ui
|
||||
import { Input } from "@plane/ui";
|
||||
// types
|
||||
import { IApiToken } from "types/api_token";
|
||||
import type { APIFormFields } from "./index";
|
||||
|
||||
interface APITokenTitleProps {
|
||||
generatedToken: IApiToken | null | undefined;
|
||||
errors: FieldErrors<APIFormFields>;
|
||||
control: Control<APIFormFields, any>;
|
||||
focusTitle: boolean;
|
||||
setFocusTitle: Dispatch<SetStateAction<boolean>>;
|
||||
setFocusDescription: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export const APITokenTitle: FC<APITokenTitleProps> = (props) => {
|
||||
const { generatedToken, errors, control, focusTitle, setFocusTitle, setFocusDescription } = props;
|
||||
|
||||
return (
|
||||
<Controller
|
||||
control={control}
|
||||
name="title"
|
||||
rules={{
|
||||
required: "Title is required",
|
||||
maxLength: {
|
||||
value: 255,
|
||||
message: "Title should be less than 255 characters",
|
||||
},
|
||||
}}
|
||||
render={({ field: { value, onChange, ref } }) =>
|
||||
focusTitle ? (
|
||||
<Input
|
||||
id="title"
|
||||
name="title"
|
||||
type="text"
|
||||
inputSize="md"
|
||||
onBlur={() => {
|
||||
setFocusTitle(false);
|
||||
}}
|
||||
onError={() => {
|
||||
console.log("error");
|
||||
}}
|
||||
autoFocus
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
ref={ref}
|
||||
hasError={!!errors.title}
|
||||
placeholder="Title"
|
||||
className="resize-none text-xl w-full"
|
||||
/>
|
||||
) : (
|
||||
<p
|
||||
onClick={() => {
|
||||
if (generatedToken != null) return;
|
||||
setFocusDescription(false);
|
||||
setFocusTitle(true);
|
||||
}}
|
||||
role="button"
|
||||
className={`${value.length === 0 ? "text-custom-text-400/60" : ""} font-medium text-[24px]`}
|
||||
>
|
||||
{value.length != 0 ? value : "Api Title"}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
4
web/components/api-token/index.ts
Normal file
4
web/components/api-token/index.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export * from "./delete-token-modal";
|
||||
export * from "./empty-state";
|
||||
export * from "./token-list-item";
|
||||
export * from "./form";
|
||||
|
|
@ -10,7 +10,7 @@ interface IApiTokenListItem {
|
|||
token: IApiToken;
|
||||
}
|
||||
|
||||
export const ApiTokenListItem = ({ token, workspaceSlug }: IApiTokenListItem) => (
|
||||
export const APITokenListItem = ({ token, workspaceSlug }: IApiTokenListItem) => (
|
||||
<Link href={`/${workspaceSlug}/settings/api-tokens/${token.id}`} key={token.id}>
|
||||
<div className="border-b flex flex-col relative justify-center items-start border-custom-border-200 py-5 hover:cursor-pointer">
|
||||
<XCircle className="absolute right-5 opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto justify-self-center stroke-custom-text-400 h-[15px] w-[15px]" />
|
||||
|
|
@ -151,7 +151,7 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = (props) => {
|
|||
value={value}
|
||||
setShouldShowAlert={setShowAlert}
|
||||
setIsSubmitting={setIsSubmitting}
|
||||
dragDropEnabled={true}
|
||||
dragDropEnabled
|
||||
customClassName={isAllowed ? "min-h-[150px] shadow-sm" : "!p-0 !pt-2 text-custom-text-200"}
|
||||
noBorder={!isAllowed}
|
||||
onChange={(description: Object, description_html: string) => {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
|
|||
</div>
|
||||
<span>{errors.name ? errors.name.message : null}</span>
|
||||
<RichTextEditor
|
||||
dragDropEnabled={true}
|
||||
dragDropEnabled
|
||||
cancelUploadImage={fileService.cancelUpload}
|
||||
uploadFile={fileService.getUploadFileFunction(workspaceSlug)}
|
||||
deleteFile={fileService.deleteImage}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
: "text-custom-text-400 hover:text-custom-text-200"
|
||||
}`}
|
||||
>
|
||||
<mode.icon className={`h-4 w-4 flex-shrink-0 -my-1 `} />
|
||||
<mode.icon className="h-4 w-4 flex-shrink-0 -my-1" />
|
||||
{mode.title}
|
||||
</div>
|
||||
</CustomSelect.Option>
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ export const IssueProperty: React.FC<IIssueProperty> = observer((props) => {
|
|||
value={issue?.state_detail || null}
|
||||
onChange={(data) => handleStateChange(data)}
|
||||
disabled={false}
|
||||
hideDropdownArrow={true}
|
||||
hideDropdownArrow
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -128,7 +128,7 @@ export const IssueProperty: React.FC<IIssueProperty> = observer((props) => {
|
|||
<IssuePropertyAssignee
|
||||
projectId={issue?.project_detail?.id || null}
|
||||
value={issue?.assignees || null}
|
||||
hideDropdownArrow={true}
|
||||
hideDropdownArrow
|
||||
onChange={(val) => handleAssigneeChange(val)}
|
||||
disabled={false}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export const ProjectSettingLabelGroup: React.FC<Props> = observer((props) => {
|
|||
<CreateUpdateLabelInline
|
||||
labelForm={isEditLabelForm}
|
||||
setLabelForm={setEditLabelForm}
|
||||
isUpdating={true}
|
||||
isUpdating
|
||||
labelToUpdate={label}
|
||||
onClose={() => {
|
||||
setEditLabelForm(false);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export const ProjectSettingLabelItem: React.FC<Props> = (props) => {
|
|||
<CreateUpdateLabelInline
|
||||
labelForm={isEditLabelForm}
|
||||
setLabelForm={setEditLabelForm}
|
||||
isUpdating={true}
|
||||
isUpdating
|
||||
labelToUpdate={label}
|
||||
onClose={() => {
|
||||
setEditLabelForm(false);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ export const ProjectSettingsLabelList: React.FC = observer(() => {
|
|||
<Droppable
|
||||
droppableId={LABELS_ROOT}
|
||||
isCombineEnabled={!isDraggingGroup}
|
||||
ignoreContainerClipping={true}
|
||||
ignoreContainerClipping
|
||||
isDropDisabled={isUpdating}
|
||||
>
|
||||
{(droppableProvided, droppableSnapshot) => (
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import OnboardingStepIndicator from "components/account/step-indicator";
|
|||
// hooks
|
||||
import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown";
|
||||
// icons
|
||||
import { Check, ChevronDown, Plus, User2, X, XCircle } from "lucide-react";
|
||||
import { Check, ChevronDown, Plus, User2, XCircle } from "lucide-react";
|
||||
// types
|
||||
import { IUser, IWorkspace, TOnboardingSteps, TUserWorkspaceRole } from "types";
|
||||
// constants
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ export const TourSidebar: React.FC<Props> = ({ step, setStep }) => (
|
|||
: "text-custom-text-200 border-transparent"
|
||||
}`}
|
||||
onClick={() => setStep(option.key)}
|
||||
role="button"
|
||||
>
|
||||
<option.Icon className="h-4 w-4" aria-hidden="true" />
|
||||
{option.key}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ type Props = {
|
|||
user?: IUser;
|
||||
};
|
||||
|
||||
const timeZoneOptions = TIME_ZONES.map((timeZone) => ({
|
||||
value: timeZone.value,
|
||||
query: timeZone.label + " " + timeZone.value,
|
||||
content: timeZone.label,
|
||||
}));
|
||||
// const timeZoneOptions = TIME_ZONES.map((timeZone) => ({
|
||||
// value: timeZone.value,
|
||||
// query: timeZone.label + " " + timeZone.value,
|
||||
// content: timeZone.label,
|
||||
// }));
|
||||
|
||||
const useCases = [
|
||||
"Build Products",
|
||||
|
|
@ -51,7 +51,7 @@ const fileService = new FileService();
|
|||
export const UserDetails: React.FC<Props> = observer((props) => {
|
||||
const { user } = props;
|
||||
const [isRemoving, setIsRemoving] = useState(false);
|
||||
const [selectedUsecase, setSelectedUsecase] = useState<number | null>();
|
||||
// const [selectedUsecase, setSelectedUsecase] = useState<number | null>();
|
||||
const [isImageUploadModalOpen, setIsImageUploadModalOpen] = useState(false);
|
||||
const {
|
||||
user: userStore,
|
||||
|
|
@ -210,7 +210,7 @@ export const UserDetails: React.FC<Props> = observer((props) => {
|
|||
</form>
|
||||
</div>
|
||||
<div className="md:w-11/12 relative flex justify-end bottom-0 ml-auto">
|
||||
<Image src={IssuesSvg} className="w-2/3 h-[w-2/3] object-cover" />
|
||||
<Image src={IssuesSvg} className="w-2/3 h-[w-2/3] object-cover" alt="issue-image" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export const Workspace: React.FC<Props> = (props) => {
|
|||
|
||||
await workspaceStore
|
||||
.createWorkspace(formData)
|
||||
.then(async (res) => {
|
||||
.then(async () => {
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
title: "Success!",
|
||||
|
|
@ -137,13 +137,12 @@ export const Workspace: React.FC<Props> = (props) => {
|
|||
<Controller
|
||||
control={control}
|
||||
name="slug"
|
||||
render={({ field: { value, onChange, ref } }) => (
|
||||
render={({ field: { value, ref } }) => (
|
||||
<div className="flex items-center relative rounded-md bg-onboarding-background-200">
|
||||
<Input
|
||||
id="slug"
|
||||
name="slug"
|
||||
type="text"
|
||||
prefix="asdasdasdas"
|
||||
value={value.toLocaleLowerCase().trim().replace(/ /g, "-")}
|
||||
onChange={(e) => {
|
||||
const host = window.location.host;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const EmptyState: React.FC<Props> = ({
|
|||
secondaryButton,
|
||||
disabled = false,
|
||||
}) => (
|
||||
<div className={`flex items-center lg:p-20 md:px-10 px-5 justify-center h-full w-full`}>
|
||||
<div className="flex items-center lg:p-20 md:px-10 px-5 justify-center h-full w-full">
|
||||
<div className="relative h-full w-full max-w-6xl">
|
||||
<Image src={image} className="w-52 sm:w-60" alt={primaryButton?.text} layout="fill" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export const ProjectMemberList: React.FC = observer(() => {
|
|||
className="max-w-[234px] w-full border-none bg-transparent text-sm focus:outline-none"
|
||||
placeholder="Search"
|
||||
value={searchQuery}
|
||||
autoFocus={true}
|
||||
autoFocus
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ export const ProjectSidebarListItem: React.FC<Props> = observer((props) => {
|
|||
</span>
|
||||
)}
|
||||
|
||||
{!isCollapsed && <p className={`truncate text-custom-sidebar-text-200`}>{project.name}</p>}
|
||||
{!isCollapsed && <p className="truncate text-custom-sidebar-text-200">{project.name}</p>}
|
||||
</div>
|
||||
{!isCollapsed && (
|
||||
<ChevronDown
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ type EmptySpaceItemProps = {
|
|||
|
||||
const EmptySpaceItem: React.FC<EmptySpaceItemProps> = ({ title, description, Icon, action }) => (
|
||||
<>
|
||||
<li className="cursor-pointer" onClick={action}>
|
||||
<li className="cursor-pointer" onClick={action} role="button">
|
||||
<div className={`group relative flex ${description ? "items-start" : "items-center"} space-x-3 py-4`}>
|
||||
<div className="flex-shrink-0">
|
||||
<span className="inline-flex h-10 w-10 items-center justify-center rounded-lg bg-custom-primary">
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import React, { FC, useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import { Dialog, Transition } from "@headlessui/react";
|
||||
// icons
|
||||
import { AlertTriangle } from "lucide-react";
|
||||
// ui
|
||||
import { Button } from "@plane/ui";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
import { AlertTriangle } from "lucide-react";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { FC, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
interface IDeleteWebhook {
|
||||
isOpen: boolean;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ export const WebHookForm: FC<IWebHookForm> = observer((props) => {
|
|||
}
|
||||
|
||||
reset({ ...getValues(), ...allWebhookOptions });
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [watch && watch(WEBHOOK_EVENTS)]);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -68,17 +68,13 @@ export const WorkspaceDetails: FC = observer(() => {
|
|||
|
||||
await updateWorkspace(currentWorkspace.slug, payload)
|
||||
.then((res) => {
|
||||
trackEvent(
|
||||
'UPDATE_WORKSPACE',
|
||||
res
|
||||
)
|
||||
trackEvent("UPDATE_WORKSPACE", res);
|
||||
setToastAlert({
|
||||
title: "Success",
|
||||
type: "success",
|
||||
message: "Workspace updated successfully",
|
||||
})
|
||||
}
|
||||
)
|
||||
});
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
};
|
||||
|
||||
|
|
@ -89,7 +85,7 @@ export const WorkspaceDetails: FC = observer(() => {
|
|||
|
||||
fileService.deleteFile(currentWorkspace.id, url).then(() => {
|
||||
updateWorkspace(currentWorkspace.slug, { logo: "" })
|
||||
.then((res) => {
|
||||
.then(() => {
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
title: "Success!",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue