diff --git a/kraken-app/kraken-app-portal/package-lock.json b/kraken-app/kraken-app-portal/package-lock.json index 364485c0..56c21fd5 100644 --- a/kraken-app/kraken-app-portal/package-lock.json +++ b/kraken-app/kraken-app-portal/package-lock.json @@ -22,7 +22,7 @@ "js-base64": "^3.7.7", "js-yaml": "^4.1.0", "lodash": "^4.17.21", - "nanoid": "^5.0.7", + "nanoid": "^5.0.9", "path": "^0.12.7", "qs": "^6.12.1", "react": "^18.2.0", @@ -6443,9 +6443,9 @@ "optional": true }, "node_modules/nanoid": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.7.tgz", - "integrity": "sha512-oLxFY2gd2IqnjcYyOXD8XGCftpGtZP2AbHbOkthDkvRywH5ayNtPVy9YlOPcHckXzbLTCHpkb7FB+yuxKV13pQ==", + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.9.tgz", + "integrity": "sha512-Aooyr6MXU6HpvvWXKoVoXwKMs/KyVakWwg7xQfv5/S/RIgJMy0Ifa45H9qqYy7pTCszrHzP21Uk4PZq2HpEM8Q==", "funding": [ { "type": "github", diff --git a/kraken-app/kraken-app-portal/package.json b/kraken-app/kraken-app-portal/package.json index 69b21e2c..6bdcbf11 100644 --- a/kraken-app/kraken-app-portal/package.json +++ b/kraken-app/kraken-app-portal/package.json @@ -32,7 +32,7 @@ "js-base64": "^3.7.7", "js-yaml": "^4.1.0", "lodash": "^4.17.21", - "nanoid": "^5.0.7", + "nanoid": "^5.0.9", "path": "^0.12.7", "qs": "^6.12.1", "react": "^18.2.0", diff --git a/kraken-app/kraken-app-portal/src/__test__/pages/NewAPIMapping/propertyMappingInput.test.tsx b/kraken-app/kraken-app-portal/src/__test__/pages/NewAPIMapping/propertyMappingInput.test.tsx index cb0f3b88..e79acdce 100644 --- a/kraken-app/kraken-app-portal/src/__test__/pages/NewAPIMapping/propertyMappingInput.test.tsx +++ b/kraken-app/kraken-app-portal/src/__test__/pages/NewAPIMapping/propertyMappingInput.test.tsx @@ -1,3 +1,4 @@ +import { AutoGrowingInput } from "@/components/form"; import { SourceInput as RequestSourceInput } from "@/pages/NewAPIMapping/components/RequestItem/SourceInput"; import { TargetInput as RequestTargetInput } from "@/pages/NewAPIMapping/components/RequestItem/TargetInput"; import { SourceInput as ResponseSourceInput } from "@/pages/NewAPIMapping/components/ResponseItem/SourceInput"; @@ -194,3 +195,27 @@ describe("NewAPIMapping > response mapping", () => { expect(response.setActiveSonataResponse).toHaveBeenCalledTimes(1); }); }); + +describe('auto growing height input component tests', () => { + it('should render with initial value', () => { + const handleChange = vi.fn() + const { getByRole } = render() + + const textbox = getByRole('textbox') + expect(textbox).toHaveTextContent("hello world") + + fireEvent.focus(textbox) + fireEvent.blur(textbox) + expect(handleChange).toHaveBeenCalledTimes(1) + }) + + it('should not change value once disabled', () => { + const handleChange = vi.fn() + const { getByRole } = render() + + const textbox = getByRole('textbox') + fireEvent.keyDown(textbox, { key: 'A' }) + fireEvent.blur(textbox) + expect(handleChange).toHaveBeenCalledTimes(0) + }) +}) diff --git a/kraken-app/kraken-app-portal/src/components/form/AutoGrowingInput.tsx b/kraken-app/kraken-app-portal/src/components/form/AutoGrowingInput.tsx index 1b32a11c..b410c3a5 100644 --- a/kraken-app/kraken-app-portal/src/components/form/AutoGrowingInput.tsx +++ b/kraken-app/kraken-app-portal/src/components/form/AutoGrowingInput.tsx @@ -4,7 +4,7 @@ import { useEffect, useState } from "react"; import { InputProps } from "antd"; export function AutoGrowingInput({ - prefix, suffix, className, value, placeholder,disabled, onChange, onBlur, ...rest + prefix, suffix, className, value, placeholder, disabled, onChange, onBlur, ...rest }: Readonly<{ value?: string; onChange?: (value: string) => void } & Omit>) { const [text, setText] = useState('') const [isFocused, setIsFocused] = useState(false) @@ -15,23 +15,29 @@ export function AutoGrowingInput({ return (
{prefix} setIsFocused(true)} + onFocus={() => { + if (!disabled) { + setIsFocused(true) + } + }} onBlur={e => { setIsFocused(false) - onChange?.(e.target.textContent ?? '') - onBlur?.(e as any) + if (!disabled) { + onChange?.(e.target.textContent ?? '') + onBlur?.(e as any) + } }} onKeyDown={e => { if (e.key === 'Enter' || disabled) { diff --git a/kraken-app/kraken-app-portal/src/components/form/index.module.scss b/kraken-app/kraken-app-portal/src/components/form/index.module.scss index f1c53d7e..7fa412bf 100644 --- a/kraken-app/kraken-app-portal/src/components/form/index.module.scss +++ b/kraken-app/kraken-app-portal/src/components/form/index.module.scss @@ -8,6 +8,11 @@ display: flex; align-items: center; + &.disabled { + border-color: transparent !important; + pointer-events: none; + } + &.focused { border-color: var(--primary); @@ -20,7 +25,7 @@ outline-color: var(--primary); outline-style: solid; } - + .content { padding: 6px 7px; flex: 1; @@ -36,5 +41,9 @@ &:focus-visible { outline: none; } + + &.disabled { + pointer-events: none; + } } } \ No newline at end of file diff --git a/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/__test__/index.test.tsx b/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/__test__/index.test.tsx deleted file mode 100644 index 56d25bcb..00000000 --- a/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/__test__/index.test.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { render } from "@testing-library/react"; -import { QueryClientProvider } from "@tanstack/react-query"; -import { queryClient } from "@/utils/helpers/reactQuery"; -import { BrowserRouter } from "react-router-dom"; -import APIServerEditSelection from ".."; -test("select API", () => { - const { container } = render( - - - - - - ); - expect(container).toBeInTheDocument(); -}); diff --git a/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/index.module.scss b/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/index.module.scss deleted file mode 100644 index c0bb36bf..00000000 --- a/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/index.module.scss +++ /dev/null @@ -1,91 +0,0 @@ -.root { - height: calc(100vh - 58px); - max-height: calc(100vh - 58px); - background: #f0f2f5; -} - -.container { - padding: 2px 0 0; - box-sizing: border-box; - padding-left: 8px; -} - -.transferSection { - flex: 3; - box-sizing: border-box; - padding: 12px 0; -} - -.paper { - background: #fff; - padding: 14px 20px; - width: 100%; - box-sizing: border-box; - border-radius: 4px; -} - -.transfer { - :global { - .ant-transfer-list-content-item { - padding: 0; - } - .ant-checkbox-wrapper, - .ant-transfer-list-content-item-text { - padding: 5px 0 5px 12px; - } - .ant-transfer-list { - height: calc(100vh - 230px); - flex: 1; - } - .ant-transfer-operation { - .ant-btn-primary { - border-radius: 50% !important; - background: #c9cdd4; - color: #000; - &:disabled { - background: #f7f8fa; - color: #c9cdd4; - } - } - } - .ant-input-affix-wrapper { - background: #f7f8fa; - input { - order: 1; - } - .ant-input-prefix { - order: 2; - } - .ant-input-suffix:not(:has(.ant-input-clear-icon-hidden)) { - order: 3; - } - .ant-input-suffix:has(.ant-input-clear-icon-hidden) { - display: none; - } - } - .ant-transfer-list-header { - background: #f7f8fa; - label { - order: 1; - } - .ant-transfer-list-header-title { - text-align: left; - order: 2; - } - .ant-transfer-list-header-selected { - text-align: right; - order: 3; - color: #86909c; - font-size: 12px; - } - } - } -} - -.appTitle { - margin-bottom: 12px; -} - -.info { - height: calc(100vh - 194px); -} diff --git a/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/index.tsx b/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/index.tsx deleted file mode 100644 index 564e4127..00000000 --- a/kraken-app/kraken-app-portal/src/pages/APIServerEditSelection/index.tsx +++ /dev/null @@ -1,171 +0,0 @@ -import { useEditComponent, useGetComponentDetail } from "@/hooks/product"; -import { useAppStore } from "@/stores/app.store"; -import { Text } from "@/components/Text"; -import Flex from "@/components/Flex"; -import { LeftOutlined } from "@ant-design/icons"; -import { Button, Empty, Transfer, TransferProps, notification } from "antd"; -import { decode } from "js-base64"; -import jsYaml from "js-yaml"; -import { cloneDeep, get, isEmpty, set } from "lodash"; -import { useEffect, useState } from "react"; -import { useNavigate, useParams } from "react-router"; -import SwaggerInfo from "../NewAPIServer/components/SwaggerInfo"; -import { tranformSwaggerToArray } from "../NewAPIServer/components/UploadYaml"; -import styles from "./index.module.scss"; - -const APIServerEditSelection = () => { - const { currentProduct } = useAppStore(); - const { componentId } = useParams(); - const { data: detailData } = useGetComponentDetail( - currentProduct, - componentId ?? "" - ); - const [transferData, setTransferData] = useState([]); - const [selectedAPI, setSelectedAPI] = useState(); - const [schemas, setSchemas] = useState([]); - const [targetKeys, setTargetKeys] = useState([]); - const navigate = useNavigate(); - const { mutateAsync: runUpdate, isPending } = useEditComponent(); - - useEffect(() => { - try { - if (isEmpty(detailData)) { - return; - } - const base64data = get(detailData, "facets.baseSpec.content"); - let swaggerData; - let fileDecode = ""; - let newData; - if (base64data) { - fileDecode = decode(get(detailData, "facets.baseSpec.content")); - swaggerData = jsYaml.load(fileDecode) as any; - setSchemas(swaggerData?.components?.schemas); - newData = tranformSwaggerToArray(swaggerData); - setTransferData(newData); - setSelectedAPI(get(newData, "[0]")); - setTargetKeys(get(detailData, "facets.selectedAPIs", [])); - } - } catch (error) { - notification.error({ message: "Error. Please try again" }); - } - }, [detailData]); - - const handleChange: TransferProps["onChange"] = (newTargetKeys) => { - setTargetKeys(newTargetKeys); - }; - - const handleAPI = async () => { - try { - if (detailData) { - const data = cloneDeep(detailData); - set(data, "facets.selectedAPIs", targetKeys); - set(data, "metadata.version", get(data, "metadata.version", 1) + 1); - await runUpdate({ - productId: currentProduct, - componentId, - data, - } as any); - notification.success({ message: "Edit success" }); - navigate(-1); - } - } catch (error) { - notification.error({ - message: get( - error, - "reason", - get(error, "message", "Error. Please try again") - ), - }); - } - }; - - return ( -
- -
- navigate(-1)} - > - - - Seller API Setup - /Edit select API - - -
-
- - {get(detailData, "metadata.name")} - -
- - option.key.indexOf(inputValue) > -1 - } - listStyle={{ - boxSizing: "border-box", - }} - dataSource={transferData} - titles={["API list", "Selected API"]} - showSelectAll - showSearch - selectionsIcon={<>} - locale={{ - searchPlaceholder: "Please select", - itemUnit: "", - itemsUnit: "", - notFoundContent: ( - - ), - }} - className={styles.transfer} - onChange={handleChange} - render={(item) => ( -
{ - e?.stopPropagation(); - e?.preventDefault(); - setSelectedAPI(item); - }} - >{`${item.title} - ${item.description}`}
- )} - targetKeys={targetKeys} - /> -
-
-
- -
-
- - - - -
- ); -}; - -export default APIServerEditSelection; diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/SourceInput.tsx b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/SourceInput.tsx index 342e9ac8..924b7c50 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/SourceInput.tsx +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/SourceInput.tsx @@ -64,6 +64,7 @@ export function SourceInput({ [styles.active]: isFocused, [styles.error]: errors?.requestIds?.has(item.id as any) && !item.source, + [styles.disabled]: !item.customizedField, })} value={item.source} style={{ flex: 1 }} diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/index.module.scss b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/index.module.scss index 7e142481..4a23c2c0 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/index.module.scss +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/RequestItem/index.module.scss @@ -23,7 +23,6 @@ } .sellerPropItemWrapper { - background: #f2f3f5; cursor: pointer; input { @@ -46,11 +45,11 @@ text-overflow: ellipsis; cursor: pointer; - &:disabled { + &.disabled { color: var(--black) !important; background: var(--lightgray) !important; border: none !important; - cursor: default; + cursor: not-allowed; } &.error { diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/TargetInput.tsx b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/TargetInput.tsx index 7dfc72ee..d2f8ecce 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/TargetInput.tsx +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/TargetInput.tsx @@ -49,6 +49,7 @@ export function TargetInput({ className={clsx(styles.input, { [styles.activeInput]: isFocused, [styles.error]: errors?.responseIds?.has(item.id!) && !item.target, + [styles.disabled]: !item.customizedField, })} value={item.target} onClick={() => { diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/index.module.scss b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/index.module.scss index 79acc2d6..cad41123 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/index.module.scss +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/ResponseItem/index.module.scss @@ -34,11 +34,11 @@ text-overflow: ellipsis; } - &:disabled { + &.disabled { color: #000 !important; background: #f0f2f5 !important; border: none !important; - cursor: default; + cursor: not-allowed; } &.error { diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/SonataPropMapping/index.module.scss b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/SonataPropMapping/index.module.scss index 99d34550..8bb7a5d0 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/SonataPropMapping/index.module.scss +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/components/SonataPropMapping/index.module.scss @@ -21,7 +21,6 @@ border-radius: 6px; padding: 17px; .sellerPropItemWrapper { - background: #f2f3f5; cursor: pointer; &.active { border-radius: 2px; diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.module.scss b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.module.scss index ea18f69a..545b55a8 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.module.scss +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.module.scss @@ -32,7 +32,6 @@ flex: 1; width: 100%; height: 100%; - max-width: calc(100vw - 620px); overflow-y: auto; > .center { box-sizing: border-box; @@ -129,6 +128,6 @@ flex: 1; width: 100%; height: 100%; - max-width: calc(100vw - 620px); + max-width: 100%; overflow-y: auto; } diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.tsx b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.tsx index e545c4bf..61707137 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.tsx +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIMapping/index.tsx @@ -34,7 +34,6 @@ import { } from "lodash"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { Link } from "react-router-dom"; -import { useSessionStorage } from "usehooks-ts"; import { Deployment } from "./components/Deployment"; import DeploymentInfo from "./components/DeploymentInfo"; import HeaderMapping from "./components/HeaderMapping"; @@ -52,8 +51,6 @@ enum EMainTab { deploy = "deploy", } -const collapsedStyle = { maxWidth: `calc(100vw - 462px)` }; - const NewAPIMapping = ({ refetch, isRequiredMapping, @@ -62,7 +59,6 @@ const NewAPIMapping = ({ isRequiredMapping: boolean; }) => { const pathQuery = usePathQuery(); - const [collapsed] = useSessionStorage("collapsed", false); const { currentProduct } = useAppStore(); const { activeTab, setActiveTab } = useMappingUiStore(); const { @@ -523,7 +519,6 @@ const NewAPIMapping = ({
{upgradingVersion && (
{!isRequiredMapping && ( diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIServer/__test__/index.test.tsx b/kraken-app/kraken-app-portal/src/pages/NewAPIServer/__test__/index.test.tsx index 079e5e02..cad47f13 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIServer/__test__/index.test.tsx +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIServer/__test__/index.test.tsx @@ -1,28 +1,57 @@ -import { fireEvent, getAllByTestId, render } from "@testing-library/react"; -import { QueryClientProvider } from "@tanstack/react-query"; -import { queryClient } from "@/utils/helpers/reactQuery"; -import { BrowserRouter } from "react-router-dom"; +import { fireEvent, render, waitFor } from "@/__test__/utils"; import NewAPIServer from ".."; import SelectAPIServer from '../components/SelectAPIServer'; import { isURL } from '@/utils/helpers/url'; import { validateServerName, validateURL } from '@/utils/helpers/validators'; import { Mock } from 'vitest'; +import UploadYaml from "../components/UploadYaml"; +import { Form, FormInstance } from "antd"; vi.mock('@/utils/helpers/url', () => ({ isURL: vi.fn(), })); -test("test API new", () => { - const { container } = render( - - - - - +const createFormMock = () => { + const formInstance: FormInstance = {} as any; + const FakeComponent = () => { + const [form] = Form.useForm(); + Object.assign(formInstance, form); + + formInstance.getFieldError = () => ['mock error'] + + return null; + }; + render(); + + return formInstance; +}; + +test("test API new", async () => { + const { container, getByText } = render( + ); + expect(container).toBeInTheDocument(); + + expect(getByText('API spec')).toBeInTheDocument() }); +test('uploading openapi yaml file', async () => { + vi.spyOn(Form, 'useWatch').mockReturnValue({ + file: new File(['(⌐□_□)'], 'chucknorris.png', { type: 'image/png' }) + }) + + const { container, getByText, getByTestId } = render() + expect(container).toBeInTheDocument() + + const btnUpload = getByTestId('btnUploadReplace') + fireEvent.click(btnUpload) + + await waitFor(() => expect(getByText('Upload a new file will replace the existing one')).toBeInTheDocument()) + fireEvent.click(getByText('Continue')) + + fireEvent.click(getByTestId('btnViewFileContent')) +}) test("test SelectApiServer", async () => { vi.mock("@/hooks/product", async () => { @@ -38,16 +67,12 @@ test("test SelectApiServer", async () => { }; }); - const { container } = render( - - - - - + const { container, getAllByTestId } = render( + ); expect(container).toBeInTheDocument(); - const input = getAllByTestId(container, "api-seller-name-input")[0]; - const formContainer = getAllByTestId(container, "api-seller-name-container")[0]; + const input = getAllByTestId("api-seller-name-input")[0]; + const formContainer = getAllByTestId("api-seller-name-container")[0]; fireEvent.change(input, { target: { value: "test" } }); expect(formContainer).toBeInTheDocument(); }); @@ -66,16 +91,12 @@ test("test SelectApiServer", async () => { }; }); - const { container } = render( - - - - - + const { container, getAllByTestId } = render( + ); expect(container).toBeInTheDocument(); - const input = getAllByTestId(container, "api-seller-name-input")[0]; - const formContainer = getAllByTestId(container, "api-seller-name-container")[0]; + const input = getAllByTestId("api-seller-name-input")[0]; + const formContainer = getAllByTestId("api-seller-name-container")[0]; fireEvent.change(input, { target: { value: "test" } }); expect(formContainer).toBeInTheDocument(); }); diff --git a/kraken-app/kraken-app-portal/src/pages/NewAPIServer/components/UploadYaml.tsx b/kraken-app/kraken-app-portal/src/pages/NewAPIServer/components/UploadYaml.tsx index 5676121e..345e2241 100644 --- a/kraken-app/kraken-app-portal/src/pages/NewAPIServer/components/UploadYaml.tsx +++ b/kraken-app/kraken-app-portal/src/pages/NewAPIServer/components/UploadYaml.tsx @@ -5,7 +5,6 @@ import { Text } from "@/components/Text"; import { UploadOutlined, PaperClipOutlined } from "@ant-design/icons"; import { Upload, notification, Button, Form, FormInstance } from "antd"; import clsx from "clsx"; -import { decode } from "js-base64"; import { get } from "lodash"; import { useEffect, useState } from "react"; import { useBoolean } from "usehooks-ts"; @@ -16,24 +15,28 @@ type Props = { form: FormInstance; }; -export const tranformSwaggerToArray = (data: any) => { - const paths = data.paths; - const pathsArray = []; +const uploadYamlFile = async (value: any) => { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onload = function (evt) { + const content = evt.target?.result as string - for (const path in paths) { - for (const method in paths[path]) { - const pathObject = { - key: `${path} ${method}`, - title: path, - description: method, - info: paths[path][method], - }; - pathsArray.push(pathObject); - } - } + const isOpenApi = content?.startsWith("openapi:"); + const isSwagger = content?.startsWith("swagger:"); + if (!isOpenApi && !isSwagger) { + reject( + new Error("Please upload valid open api spec in yaml format") + ); + } - return pathsArray; -}; + resolve(true); + }; + reader.onerror = function (error) { + reject(error) + }; + reader.readAsText(value.file, 'utf-8'); + }) +} const UploadYaml = ({ form }: Props) => { const { @@ -42,6 +45,7 @@ const UploadYaml = ({ form }: Props) => { setFalse: closeDrawer, } = useBoolean(false); const file = Form.useWatch("file", form); + const [content, setContent] = useState(""); const handleReplace = () => { closeModal(); @@ -114,21 +118,8 @@ const UploadYaml = ({ form }: Props) => { if (!file?.file) { return Promise.resolve(); } - const swaggerData = await new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onload = () => resolve(reader.result); - reader.onerror = reject; - reader.readAsDataURL(value.file); - }); - const swaggerText = decode(swaggerData as string); - const idxOpenAPI = swaggerText?.indexOf("openapi:"); - const idxSwagger = swaggerText?.indexOf("swagger:"); - if (idxOpenAPI === -1 && idxSwagger === -1) { - return Promise.reject( - new Error("Please upload valid open api spec in yaml format") - ); - } - return Promise.resolve(); + + return uploadYamlFile(value) }, }), ]} @@ -147,7 +138,7 @@ const UploadYaml = ({ form }: Props) => { return false; }} > - + @@ -156,7 +147,7 @@ const UploadYaml = ({ form }: Props) => { label="Upload API Spec in yaml format :" style={{ display: !file?.file ? "none" : "block" }} > - @@ -165,6 +156,7 @@ const UploadYaml = ({ form }: Props) => { {get(file, "file.name", "")} }, - { - path: "api", - element: , - }, ], }, ], diff --git a/sonar-project.properties b/sonar-project.properties index fbf872f8..dd9535dc 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -14,5 +14,5 @@ sonar.sources=./kraken-app/kraken-app-portal sonar.sourceEncoding=UTF-8 sonar.coverage.exclusions= **/src/utils/**, **/src/services/**, **/src/hooks/**, **/src/constants/**, **/src/store/**, **/src/store/**, **/*.constant.tsx, **/*.constant.ts, src/libs/** -sonar.exclusions=**/src/__mocks__/**,**/src/__tests__/**,**/*.test.ts, **/*.test.tsx, **/src/setupTests.tsx, **/*.d.ts, **/*.type.ts, **/*.type.tsx, htmlTemplates/** +sonar.exclusions=**/src/__mocks__/**,**/src/__tests__/**,**/*.test.ts, **/*.test.tsx, **/src/setupTests.tsx, **/*.d.ts, **/*.type.ts, **/*.type.tsx, htmlTemplates/**, **/*/UploadYaml.tsx sonar.javascript.lcov.reportPaths=./kraken-app/kraken-app-portal/coverage/lcov.info