Skip to content
Merged
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
1 change: 0 additions & 1 deletion src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default async function Page({
projectName={projectName}
versionName={versionName}
specificationName={specificationName}
user={user}
/>
),
}
Expand Down
18 changes: 13 additions & 5 deletions src/lib/components/OpenApiSpecificationSelectorComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@ import { useForceUpdate } from "../utils/Hooks";

interface OpenApiSpecificationSelectorComponentProps {
openApiSpecifications: IOpenApiSpecification[];
openAPISpecification?: string;
openAPISpecification?: string;
versionName: string;
projectName: string;
}

const OpenApiSpecificationSelectorComponent: React.FC<
OpenApiSpecificationSelectorComponentProps
> = ({ openApiSpecifications, openAPISpecification }) => {
> = ({ openApiSpecifications, openAPISpecification, projectName, versionName }) => {
const router = useRouter();
const firstOpenAPISpecification = openApiSpecifications[0];
if (
(!openAPISpecification || openAPISpecification.length == 0) &&
firstOpenAPISpecification
) {
router.push(
`/${projectName.replace("-openapi", "")}/${versionName}/${firstOpenAPISpecification.name}`
);
}

const handleVersionChange = (event: SelectChangeEvent) => {
const openApiSpecificationName = event.target.value;
const openApiSpecification = openApiSpecifications.find(
(x) => x.name === openApiSpecificationName
);
router.push(`/${getProject()?.replace("-openapi", "")}/${getVersion()}/${openApiSpecificationName}`);
};

Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/OpenApiSpecificationsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import OpenApiSpecificationSelectorComponent from "./OpenApiSpecificationSelecto
interface OpenApiSpecificationsComponentProps {
versionName: string;
projectName: string;
user: IUser;
openApiSpecificationRepository: IOpenApiSpecificationRepository;
specificationName?: string;
}
Expand All @@ -16,7 +15,6 @@ const OpenApiSpecificationsComponent: React.FC<
> = async ({
versionName,
openApiSpecificationRepository,
user,
projectName,
specificationName,
}) => {
Expand All @@ -31,6 +29,8 @@ const OpenApiSpecificationsComponent: React.FC<
<OpenApiSpecificationSelectorComponent
openApiSpecifications={openApiSpecifications}
openAPISpecification={specificationName}
projectName={projectName}
versionName={versionName}
/>
);
};
Expand Down
12 changes: 10 additions & 2 deletions src/lib/components/VersionSelectorComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@ import { useRouter } from "next/navigation";
interface VersionSelectorComponentProps {
versions: IVersion[];
version?: string;
projectName: string;
}

const VersionSelectorComponent: React.FC<VersionSelectorComponentProps> = ({
versions,
version
version,
projectName,
}) => {
const router = useRouter();
const firstVersion = versions[0];
if ((!version || version.length == 0) && firstVersion) {
router.push(
`/${projectName?.replace("-openapi", "")}/${firstVersion.name}`
);
}

const handleVersionChange = (event: SelectChangeEvent) => {
const versionName = event.target.value;
router.push(`/${getProject()!.replace("-openapi", "")}/${versionName}`);
router.push(`/${getProject()?.replace("-openapi", "")}/${versionName}`);
};

return (
Expand Down
8 changes: 7 additions & 1 deletion src/lib/components/VersionsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ const VersionsComponent: React.FC<VersionsComponentProps> = async ({
owner: "shapehq",
} as IGitHubProject);

return <VersionSelectorComponent versions={versions} version={versionName} />;
return (
<VersionSelectorComponent
versions={versions}
version={versionName}
projectName={projectName}
/>
);
};

export default VersionsComponent;
2 changes: 1 addition & 1 deletion src/lib/projects/GitHubOpenAPISpecificationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class GitHubOpenApiSpecificationRepository implements IOpenApiSpecificati
}

async getOpenAPISpecifications(version: IGitHubVersion): Promise<IOpenApiSpecification[]> {
const content = await this.gitHubClient.getContent(version.owner, version.repository)
const content = await this.gitHubClient.getContent(version.owner, version.repository, version.name)
return content.filter(e => {
return this.isOpenAPISpecification(e.name)
})
Expand Down