Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Fixed some linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Oct 17, 2023
1 parent 10cdfa7 commit bb476c7
Show file tree
Hide file tree
Showing 32 changed files with 88 additions and 75 deletions.
2 changes: 2 additions & 0 deletions ui/ui-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"private": true,
"version": "0.1.0",
"type": "module",
"license": "Apache-2.0",
"repository": "https://github.com/Apicurio/apicurio-api-designer.git",
"scripts": {
"postinstall": "node .fix_yaml.cjs",
"clean": "rimraf dist",
Expand Down
6 changes: 2 additions & 4 deletions ui/ui-app/src/app/auth/oidc/oidcAuth.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { UserManager } from "oidc-client-ts";
import { ApiDesignerConfigType } from "@app/contexts/config";
import { getApiDesignerConfig } from "@utils/config.utils.ts";

const OIDC_CONFIG_OPTIONS: string[] = ["url", "clientId", "redirectUri"];

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const apiDesignerConfig: ApiDesignerConfigType = (ApiDesignerConfig || window["ApiDesignerConfig"]) as ApiDesignerConfigType;
const apiDesignerConfig: ApiDesignerConfigType = getApiDesignerConfig();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function only(items: string[], allOptions: any): any {
const rval: any = {};
items.forEach(item => {
Expand Down
4 changes: 1 addition & 3 deletions ui/ui-app/src/app/components/ArtifactTypeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ const icon = (type: string | undefined): string => {
* Properties
*/
export type ArtifactTypeIconProps = {
className?: string;
type: string;
isShowIcon: boolean;
isShowLabel: boolean;
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const ArtifactTypeIcon: FunctionComponent<ArtifactTypeIconProps> = ({ className, type, isShowIcon, isShowLabel }: ArtifactTypeIconProps) => {
const getTitle = (): string => {
let title: string = type;
Expand Down
6 changes: 2 additions & 4 deletions ui/ui-app/src/app/contexts/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createContext, useContext } from "react";
import { getApiDesignerConfig } from "@utils/config.utils.ts";

export type EditorsType = {
url: string;
Expand All @@ -25,7 +26,6 @@ export type ApisType = {

export type AuthType = {
type: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options?: any;
};

Expand All @@ -36,9 +36,7 @@ export type ApiDesignerConfigType = {
auth: AuthType;
};

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const apiDesignerConfig: ApiDesignerConfigType = (ApiDesignerConfig || window["ApiDesignerConfig"]) as ApiDesignerConfigType;
const apiDesignerConfig: ApiDesignerConfigType = getApiDesignerConfig();

export const ApiDesignerConfigContext = createContext<ApiDesignerConfigType | undefined>(
apiDesignerConfig
Expand Down
1 change: 0 additions & 1 deletion ui/ui-app/src/app/pages/components/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export * from "./BrowserDataWarning";
export * from "./DesignDescription";
export * from "./ErrorModal";
Expand Down
3 changes: 1 addition & 2 deletions ui/ui-app/src/app/pages/components/editor/EditorContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import {
Text,
TextContent
} from "@patternfly/react-core";
import { NavLink } from "../common/NavLink";
import { DesignDescription } from "../common/DesignDescription";
import { ArtifactTypes, Design, DesignEvent } from "@models/designs";
import { LocalStorageService, useLocalStorageService } from "@services/LocalStorageService.ts";
import { DesignsService, useDesignsService } from "@services/DesignsService.ts";
import { DropdownSeparator } from "@patternfly/react-core/deprecated";
import { If, ToggleIcon, ArtifactTypeIcon } from "@app/components";
import { DesignDescription, NavLink } from "@app/pages";

/**
* Properties
Expand Down
1 change: 0 additions & 1 deletion ui/ui-app/src/app/pages/components/editor/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export * from "./CompareModal";
export * from "./EditorContext";
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
EmptyStateIcon
} from "@patternfly/react-core";
import { AddCircleOIcon } from "@patternfly/react-icons";
import { ImportDropdown, ImportFrom } from "./ImportDropdown";
import { ImportDropdown, ImportFrom } from "@app/pages";

/**
* Properties
Expand Down
18 changes: 10 additions & 8 deletions ui/ui-app/src/app/pages/components/home/DesignsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React, { FunctionComponent, useEffect, useState } from "react";
import { Alert, AlertActionCloseButton, Card, CardBody } from "@patternfly/react-core";
import { ImportFrom } from "./ImportDropdown";
import { DesignsEmptyState } from "./DesignsEmptyState";
import { DesignsEmptyStateFiltered } from "./DesignsEmptyStateFiltered";
import { DesignsToolbar } from "./DesignsToolbar";
import { DesignList } from "./DesignList";
import { DeleteDesignModal } from "./DeleteDesignModal";
import { RenameModal } from "../common/RenameModal";
import { PageConfig, usePageConfig } from "@app/pages";
import {
DeleteDesignModal,
DesignList,
DesignsEmptyState,
DesignsEmptyStateFiltered,
DesignsToolbar,
ImportFrom,
PageConfig, RenameModal,
usePageConfig
} from "@app/pages";
import {
Design,
DesignsSearchCriteria,
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-app/src/app/pages/components/home/DesignsToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
ToolbarContent,
ToolbarItem
} from "@patternfly/react-core";
import { ImportDropdown, ImportFrom } from "./ImportDropdown";
import { DesignsSearchCriteria, DesignsSearchResults, Paging } from "@models/designs";
import { ImportDropdown, ImportFrom } from "@app/pages";


/**
Expand Down
6 changes: 1 addition & 5 deletions ui/ui-app/src/app/pages/components/home/ImportDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { FunctionComponent, useState } from "react";
import { ObjectDropdown } from "@app/components";
import { ImportFrom } from "@app/pages";

type ImportDropdownItem = {
label: string,
shortLabel: string,
handler: () => void;
};

export enum ImportFrom {
FILE,
URL
}

/**
* Properties
*/
Expand Down
5 changes: 5 additions & 0 deletions ui/ui-app/src/app/pages/components/home/ImportFrom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

export enum ImportFrom {
FILE,
URL
}
2 changes: 1 addition & 1 deletion ui/ui-app/src/app/pages/components/home/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export * from "./DesignEventType";
export * from "./DesignsEmptyStateFiltered";
export * from "./DesignsToolbar";
Expand All @@ -15,5 +14,6 @@ export * from "./CreateDesignModal";
export * from "./DesignDetailsPanel";
export * from "./UrlUpload";
export * from "./ImportDesignModal";
export * from "./ImportFrom";
export * from "./type-options";
export * from "./version-options";
1 change: 0 additions & 1 deletion ui/ui-app/src/app/pages/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export * from "./common";
export * from "./editor";
export * from "./home";
8 changes: 2 additions & 6 deletions ui/ui-app/src/app/pages/context/PageConfigContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent, useContext } from "react";
import React, { FunctionComponent } from "react";
import { ServiceConfig, ServiceConfigContext } from "@services/ServiceConfigContext.tsx";
import { EditorConfig, EditorConfigContext } from "@editors/EditorConfigContext.ts";

Expand Down Expand Up @@ -31,11 +31,7 @@ const defaultPageConfig: PageConfig = {
}
};

const PageConfigContext: React.Context<PageConfig> = React.createContext(defaultPageConfig);

export const usePageConfig: () => PageConfig = (): PageConfig => {
return useContext(PageConfigContext);
};
export const PageConfigContext: React.Context<PageConfig> = React.createContext(defaultPageConfig);

/**
* Properties
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-app/src/app/pages/context/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export * from "./PageConfigContext";
export * from "./usePageConfig";
6 changes: 6 additions & 0 deletions ui/ui-app/src/app/pages/context/usePageConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useContext } from "react";
import { PageConfig, PageConfigContext } from "@app/pages";

export const usePageConfig: () => PageConfig = (): PageConfig => {
return useContext(PageConfigContext);
};
1 change: 0 additions & 1 deletion ui/ui-app/src/app/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export * from "./HomePage";
export * from "./EditorPage";
export * from "./components";
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-app/src/editors/AsyncApiEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const AsyncApiEditor: DesignEditor = ({ content, onChange, className }: A
return () => {
window.removeEventListener("message", eventListener, false);
};
}, []);
});

const editorAppUrl = (): string => {
return cfg.asyncApiEditorUrl;
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-app/src/editors/OpenApiEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const OpenApiEditor: DesignEditor = ({ content, onChange, className }: Op
return () => {
window.removeEventListener("message", eventListener, false);
};
}, []);
});

const editorAppUrl = (): string => {
return cfg.openApiEditorUrl;
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-app/src/editors/ProtoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Editor as DesignEditor, EditorProps } from "./editor-types";
import Editor, { Monaco } from "@monaco-editor/react";
import { editor } from "monaco-editor";
import IStandaloneCodeEditor = editor.IStandaloneCodeEditor;
import { designContentToString } from "./TextEditor";
import { designContentToString } from "@utils/content.utils.ts";

const protoBufThemeData = {
base: "vs",
Expand Down
23 changes: 1 addition & 22 deletions ui/ui-app/src/editors/TextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,7 @@ import Editor from "@monaco-editor/react";
import { editor } from "monaco-editor";
import IStandaloneCodeEditor = editor.IStandaloneCodeEditor;
import { Editor as DesignEditor, EditorProps } from "./editor-types";
import { ContentTypes, DesignContent } from "@models/designs";
import { contentToString } from "@utils/content.utils.ts";


export const designContentToString = (content: DesignContent): string => {
return contentToString(content.data);
};


export const designContentToLanguage = (content: DesignContent): string => {
if (content.contentType === ContentTypes.APPLICATION_YAML) {
return "yaml";
} else if (content.contentType === ContentTypes.APPLICATION_XML) {
return "xml";
} else if (content.contentType === ContentTypes.TEXT_XML) {
return "xml";
} else if (content.contentType === ContentTypes.APPLICATION_WSDL) {
return "xml";
}
return "json";
};

import { designContentToLanguage, designContentToString } from "@utils/content.utils.ts";

/**
* Simple text editor. This is a fallback editor for any text based content
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-app/src/services/BrowserDesignsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import Dexie from "dexie";
import { v4 as uuidv4 } from "uuid";
import { DesignsService } from "./DesignsService";
import { limit } from "@utils/design.utils.ts";
import { limit } from "@utils/design.utils";


const db = new Dexie("designsDB");
Expand Down
5 changes: 3 additions & 2 deletions ui/ui-app/src/services/DesignsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
DesignsSort,
Paging, RenameDesign,
} from "@models/designs";
import { ServiceConfig, useServiceConfig } from "./ServiceConfigContext";
import { ServiceConfig } from "./ServiceConfigContext";
import { useBrowserDesignsService } from "./BrowserDesignsService";
import { createEndpoint, createOptions, httpDelete, httpGet, httpPostWithReturn, httpPut } from "@utils/rest.utils.ts";
import { createEndpoint, createOptions, httpDelete, httpGet, httpPostWithReturn, httpPut } from "@utils/rest.utils";
import { useServiceConfig } from "@services/useServiceConfig";

function limit(value: string | undefined, size: number): string {
if (value != undefined && value.length > size) {
Expand Down
3 changes: 2 additions & 1 deletion ui/ui-app/src/services/NavigationService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NavigateFunction, useNavigate } from "react-router-dom";
import { ServiceConfig, useServiceConfig } from "./ServiceConfigContext";
import { useServiceConfig } from "@services/useServiceConfig";
import { ServiceConfig } from "@services/ServiceConfigContext";

export const navigateTo: (path: string, svcConfig: ServiceConfig, navigateFunc: NavigateFunction) => void = (path: string, svcConfig: ServiceConfig, navigateFunc: NavigateFunction) => {
const to: string = `${svcConfig.navigation.basename}${path}`;
Expand Down
6 changes: 1 addition & 5 deletions ui/ui-app/src/services/ServiceConfigContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from "react";
import React from "react";

export type DesignsServiceConfigType = {
type: string;
Expand Down Expand Up @@ -40,7 +40,3 @@ export const ServiceConfigContext: React.Context<ServiceConfig> = React.createCo
getUsername: defaultGetUsername
}
});

export const useServiceConfig: () => ServiceConfig = (): ServiceConfig => {
return useContext(ServiceConfigContext);
};
2 changes: 1 addition & 1 deletion ui/ui-app/src/services/UrlService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createOptions, httpGet } from "@utils/rest.utils.ts";
import { createOptions, httpGet } from "@utils/rest.utils";

const githubRegex: RegExp = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+)$/;

Expand Down
1 change: 1 addition & 0 deletions ui/ui-app/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from "./NavigationService";
export * from "./ServiceConfigContext";
export * from "./TemplatesService";
export * from "./UrlService";
export * from "./useServiceConfig";
6 changes: 6 additions & 0 deletions ui/ui-app/src/services/useServiceConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useContext } from "react";
import { ServiceConfig, ServiceConfigContext } from "@services/ServiceConfigContext";

export const useServiceConfig: () => ServiceConfig = (): ServiceConfig => {
return useContext(ServiceConfigContext);
};
14 changes: 14 additions & 0 deletions ui/ui-app/src/utils/config.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiDesignerConfigType } from "@app/contexts/config.ts";

export function getApiDesignerConfig(): ApiDesignerConfigType {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (ApiDesignerConfig) { return ApiDesignerConfig as ApiDesignerConfigType; }

const gw: any = window as any;
if (gw["ApiDesignerConfig"]) {
return gw["ApiDesignerConfig"] as ApiDesignerConfigType;
}

throw new Error("ApiDesignerConfig not found.");
}
18 changes: 18 additions & 0 deletions ui/ui-app/src/utils/content.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,21 @@ export function contentToString(content: any): string {
return JSON.stringify(content as string, null, 4);
}
}

export const designContentToString = (content: DesignContent): string => {
return contentToString(content.data);
};


export const designContentToLanguage = (content: DesignContent): string => {
if (content.contentType === ContentTypes.APPLICATION_YAML) {
return "yaml";
} else if (content.contentType === ContentTypes.APPLICATION_XML) {
return "xml";
} else if (content.contentType === ContentTypes.TEXT_XML) {
return "xml";
} else if (content.contentType === ContentTypes.APPLICATION_WSDL) {
return "xml";
}
return "json";
};
1 change: 1 addition & 0 deletions ui/ui-app/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./config.utils";
export * from "./content.utils";
export * from "./design.utils";
export * from "./object.utils";
Expand Down

0 comments on commit bb476c7

Please sign in to comment.