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

Updated download starter project API #33

Merged
merged 2 commits into from
Jun 13, 2022
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
150 changes: 0 additions & 150 deletions __tests__/integration/api.spec.ts

This file was deleted.

48 changes: 0 additions & 48 deletions pages/api/download-subdirectory.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styles from './DevfilePageProjects.module.css';
import type { Project, DefaultProps, Devfile } from 'custom-types';
import { DevfilePageProjectDisplay } from '@src/components';
import { download, UnsupportedLinkError, getUserRegion } from '@src/util/client';
import { getUserRegion } from '@src/util/client';
import {
Alert,
AlertActionLink,
Expand Down Expand Up @@ -72,11 +72,11 @@ export const DevfilePageProjects: React.FC<DevfilePageProjectsProps> = ({

const router = useRouter();

async function triggerDownload(project: Project): Promise<void> {
async function downloadStarterProject(devfile: Devfile, project: Project): Promise<void> {
setDownloading(true);

try {
await download(project);
window.open(`${devfile.registryLink}/starter-projects/${project.name}`);

if (analytics) {
const region = getUserRegion(router.locale);
Expand All @@ -96,22 +96,13 @@ export const DevfilePageProjects: React.FC<DevfilePageProjectsProps> = ({
);
}
} catch (error) {
if (error instanceof UnsupportedLinkError) {
setErrorAlert({
name: 'Unsupported Link',
error: error.toString(),
message: error.message,
alertType: 'warning',
});
} else {
setErrorAlert({
name: 'Download Error',
error: (error as Error).toString(),
message:
'Internal error has occurred during download. Please try again or report as issue. \n',
alertType: 'danger',
});
}
setErrorAlert({
name: 'Download Error',
error: (error as Error).toString(),
message:
'Internal error has occurred during download. Please try again or report as issue. \n',
alertType: 'danger',
});

if (analytics) {
const region = getUserRegion(router.locale);
Expand Down Expand Up @@ -179,7 +170,7 @@ export const DevfilePageProjects: React.FC<DevfilePageProjectsProps> = ({
data-testid="download-button"
className={styles.button}
isLoading={downloading}
onClick={(): Promise<void> => triggerDownload(selectedProject)}
onClick={(): Promise<void> => downloadStarterProject(devfile, selectedProject)}
variant="tertiary"
>
Download
Expand Down
120 changes: 0 additions & 120 deletions src/util/client/downloadHelperFuncs.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/util/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Sort in alphabetical order
*/
export * from './apiWrapper';
export * from './downloadHelperFuncs';
export * from './filterElemFuncs';
export * from './getCSSStyles';
export * from './getUserRegion';
Expand Down