Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: preparing for launch #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions plugins/spa-apiscoringviewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@
"typescript:watch": "tsc --noEmit --watch"
},
"devDependencies": {
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@testing-library/jest-dom": "^6.2.1",
"@types/jest": "^29.5.11",
"@types/node": "^18.15.11",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@babel/preset-react": "^7.25.7",
"@babel/preset-typescript": "^7.25.7",
"@testing-library/jest-dom": "^6.5.0",
"@types/jest": "^29.5.13",
"@types/node": "^18.19.55",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"@types/testing-library__jest-dom": "^5.14.9",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@typescript-eslint/type-utils": "^6.19.1",
"eslint": "^8.56.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@typescript-eslint/type-utils": "^6.21.0",
"eslint": "^8.57.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"parcel": "latest",
"prettier": "latest",
"process": "^0.11.10",
"ts-jest": "^29.1.2",
"typescript": "^5.3.3"
"ts-jest": "^29.2.5",
"typescript": "^5.6.3"
},
"dependencies": {
"@jest/globals": "^29.7.0",
"@parcel/config-default": "^2.11.0",
"@parcel/core": "^2.11.0",
"@parcel/packager-ts": "^2.11.0",
"@parcel/transformer-js": "^2.11.0",
"@parcel/transformer-react-refresh-wrap": "^2.11.0",
"@parcel/transformer-typescript-types": "^2.11.0",
"@preconstruct/cli": "^2.8.3",
"@testing-library/react": "^14.1.2",
"@parcel/config-default": "^2.12.0",
"@parcel/core": "^2.12.0",
"@parcel/packager-ts": "^2.12.0",
"@parcel/transformer-js": "^2.12.0",
"@parcel/transformer-react-refresh-wrap": "^2.12.0",
"@parcel/transformer-typescript-types": "^2.12.0",
"@preconstruct/cli": "^2.8.9",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.5.2"
},
"preconstruct": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env node */
module.exports = {
ignorePatterns: [".parcel-cache", "dist", "node_modules"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["../../tsconfig.json"],
tsconfigRootDir: __dirname,
},
plugins: ["@typescript-eslint", "react-hooks"],
root: true,
rules: {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": [
"warn",
{
additionalHooks: "(useIsomorphicLayoutEffect)",
},
],
},
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
],
"dependencies": {
"@emotion/react": "^11.11.1",
"@mantine/core": "^6.0.15",
"@mantine/form": "^6.0.15",
"@mantine/hooks": "^6.0.15",
"@mantine/core": "^6.0.22",
"@mantine/form": "^6.0.22",
"@mantine/hooks": "^6.0.22",
"@parcel/optimizer-htmlnano": "^2.9.3",
"@sindresorhus/slugify": "^2.2.1",
"@tabler/icons-react": "^2.23.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type CertificationProps = { DataProvider: DataProviderType };

export default function CertificationPage({
DataProvider,
}: CertificationProps) {
}: Readonly<CertificationProps>) {
const [intelliJLoading, setIntelliJLoading] = useState(false);

function onClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IconPlayerPlay } from "@tabler/icons-react";
import isIntelliJ from "../../../utils/is-intellij";
import isVsCode from "../../../utils/is-vscode";

type ApiHeadingProps = Pick<Certification, "rating" | "ratingDescription"> &
type ApiHeadingProps = Pick<Certification, "score" | "ratingDescription"> &
PickRenameMulti<
ApiIdentifier,
{ apiName: "name"; apiProtocol: "protocol" }
Expand All @@ -39,12 +39,12 @@ type ApiHeadingProps = Pick<Certification, "rating" | "ratingDescription"> &
export default function ApiHeading({
name,
protocol,
rating,
score,
ratingDescription,
apiRevalidationMetadata,
revalidateApi,
definitionPath,
}: ApiHeadingProps) {
}: Readonly<ApiHeadingProps>) {
const onRevalidateApiClick = useCallback(() => {
if (typeof revalidateApi === "function") {
const payload: ModuleValidation = {
Expand All @@ -68,7 +68,7 @@ export default function ApiHeading({
}, [definitionPath, name, protocol, revalidateApi]);

return (
<Grid grow justify="space-between" align="center" mx={8}>
<Grid m={0} grow justify="space-between" align="center">
<Grid.Col span={4}>
<Flex gap="md" align="center">
<div>
Expand Down Expand Up @@ -109,9 +109,9 @@ export default function ApiHeading({
</Flex>
</Grid.Col>

{rating && (
{typeof score === "number" && (
<Grid.Col span="auto" data-testid="ApiHeading-CenterCol">
<Flex justify="flex-end" gap="md">
<Flex align="center" justify="flex-end" gap="md">
<MediaQuery smallerThan="sm" styles={{ display: "none" }}>
<span>
<span>
Expand All @@ -125,8 +125,7 @@ export default function ApiHeading({
</MediaQuery>

<ScoreLabel
rating={rating}
size="large"
score={score}
data-testid={`ApiHeading-Score-${name}-${protocol}`}
/>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@ import { Flex, ScrollArea, Tabs } from "@mantine/core";
import { IconError404 } from "@tabler/icons-react";
import { getLabelColor } from "../../../utils/get-label-color";
import Feedback from "../../../components/feedback";
import type { ApiIdentifier, CertificationPayload, ModulesMetadata, RevalidateModule } from "../../../types";
import type {
ApiIdentifier,
CertificationPayload,
ModulesMetadata,
RevalidateModule,
} from "../../../types";

type ApiTabsProps = {
certification: CertificationPayload;
modulesMetadata: ModulesMetadata;
apisRevalidationMetadata: ModulesMetadata;
revalidateModule?: RevalidateModule;
revalidateApi?: RevalidateModule;
};

export default function ApiTabs({
certification: {
Expand All @@ -23,15 +36,14 @@ export default function ApiTabs({
apisRevalidationMetadata,
revalidateModule,
revalidateApi,
}: {
certification: CertificationPayload;
modulesMetadata: ModulesMetadata;
apisRevalidationMetadata: ModulesMetadata;
revalidateModule?: RevalidateModule;
revalidateApi?: RevalidateModule;
}) {
const [selectedId, setSelectedId] = useState<string | null>(apis.length > 0 ? getApiId(apis[0]) : null);
const selectedApi = apis.find(({ apiName, apiProtocol }) => getApiId({ apiName, apiProtocol }) === selectedId);
}: Readonly<ApiTabsProps>) {
const [selectedId, setSelectedId] = useState<string | null>(
apis.length > 0 ? getApiId(apis[0]) : null
);
const selectedApi = apis.find(
({ apiName, apiProtocol }) =>
getApiId({ apiName, apiProtocol }) === selectedId
);

if (!selectedApi || apis.length === 0) {
return (
Expand All @@ -50,20 +62,27 @@ export default function ApiTabs({
onTabChange={setSelectedId}
data-testid="ApiTabs"
display="flex"
sx={{ flex: 1, flexDirection: "column", flexWrap: "nowrap" }}
sx={{
flex: 1,
flexDirection: "column",
flexWrap: "nowrap",
height: "100%",
}}
>
<Tabs.List>
{apis.map(({ apiName, apiProtocol, rating }) => {
{apis.map(({ apiName, apiProtocol, score }) => {
const id = getApiId({ apiName, apiProtocol });
return (
<Tabs.Tab
key={id}
value={id}
data-testid={`ApiTab-${id}`}
sx={
rating
typeof score === "number"
? (theme) => ({
"&[data-active]": { borderColor: getLabelColor(theme, rating) },
"&[data-active]": {
borderColor: getLabelColor(theme, score),
},
})
: {}
}
Expand All @@ -83,10 +102,16 @@ export default function ApiTabs({
const { apiName, apiProtocol } = api;
const tabId = getApiId({ apiName, apiProtocol });
const definitionPath =
apisMetadata.find(({ name, apiSpecType }) => name === apiName && apiProtocol === apiSpecType)
?.definitionPath ?? "";
const moduleMetadata = modulesMetadata[getModuleId(api)] ?? { loading: false };
const apiRevalidationMetadata = apisRevalidationMetadata[apiName] ?? { loading: false };
apisMetadata.find(
({ name, apiSpecType }) =>
name === apiName && apiProtocol === apiSpecType
)?.definitionPath ?? "";
const moduleMetadata = modulesMetadata[getModuleId(api)] ?? {
loading: false,
};
const apiRevalidationMetadata = apisRevalidationMetadata[
apiName
] ?? { loading: false };
return (
<Tabs.Panel key={tabId} value={tabId} w="100%">
<ScrollArea sx={{ height }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@
import ApiHeading from "../../components/api-heading";
import Validation from "../../components/validation";
import { Flex } from "@mantine/core";
import type { Certification, CertificationPayload, ModuleMetadata, RevalidateModule } from "../../../types";
import type {
Certification,
CertificationPayload,
ModuleMetadata,
RevalidateModule,
} from "../../../types";

type ApiValidationProps = {
api: Certification;
rootPath: CertificationPayload["rootPath"];
definitionPath: string;
moduleMetadata: ModuleMetadata;
apiRevalidationMetadata: ModuleMetadata;
revalidateModule?: RevalidateModule;
revalidateApi?: RevalidateModule;
};

export default function ApiValidation({
api,
Expand All @@ -15,22 +30,20 @@ export default function ApiValidation({
apiRevalidationMetadata,
revalidateModule,
revalidateApi,
}: {
api: Certification;
rootPath: CertificationPayload["rootPath"];
definitionPath: string;
moduleMetadata: ModuleMetadata;
apiRevalidationMetadata: ModuleMetadata;
revalidateModule?: RevalidateModule;
revalidateApi?: RevalidateModule;
}) {
const { apiName, apiProtocol, rating, ratingDescription, result } = api;
}: Readonly<ApiValidationProps>) {
const { apiName, apiProtocol, score, ratingDescription, result } = api;
return (
<Flex direction="column" gap={0} maw="100%" py="sm" data-testid={`ApiValidation-${apiName}-${apiProtocol}`}>
<Flex
direction="column"
gap="sm"
maw="100%"
py="sm"
data-testid={`ApiValidation-${apiName}-${apiProtocol}`}
>
<ApiHeading
name={apiName}
protocol={apiProtocol}
rating={rating}
score={score}
ratingDescription={ratingDescription}
definitionPath={definitionPath}
apiRevalidationMetadata={apiRevalidationMetadata}
Expand Down
Loading