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

fix: set tags to multiline comments #172

Open
wants to merge 2 commits into
base: release-v2
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
8 changes: 4 additions & 4 deletions frontend/src/APIClients/AuthAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {
} from "@apollo/client";
import AUTHENTICATED_USER_KEY from "../constants/AuthConstants";
import { AuthenticatedUser } from "../types/AuthTypes";
// rest {
/* } rest
import baseAPIClient from "./BaseAPIClient";
import {
getLocalStorageObjProperty,
setLocalStorageObjProperty,
} from "../utils/LocalStorageUtils";
// } rest
} rest */
// graphql {
import { setLocalStorageObjProperty } from "../utils/LocalStorageUtils";
// } graphql
Expand Down Expand Up @@ -189,7 +189,7 @@ export default { login, logout, loginWithGoogle, register, refresh };

// } graphql

// rest {
/* } rest
const login = async (
email: string,
password: string,
Expand Down Expand Up @@ -295,4 +295,4 @@ const refresh = async (): Promise<boolean> => {
};

export default { login, logout, loginWithGoogle, register, resetPassword, refresh };
// } rest
} rest */
16 changes: 8 additions & 8 deletions frontend/src/APIClients/BaseAPIClient.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// typescript {
/* typescript {
import axios, { AxiosRequestConfig } from "axios";
// } typescript
// python {
} typescript */
/* python {
import axios, { AxiosResponse, AxiosRequestConfig } from "axios";
import { camelizeKeys, decamelizeKeys } from "humps";
// } python
python { */
// auth {
import jwt from "jsonwebtoken";

Expand All @@ -17,7 +17,7 @@ const baseAPIClient = axios.create({
baseURL: process.env.REACT_APP_BACKEND_URL,
});

// python {
/* python {
// Python API uses snake_case, frontend uses camelCase
// convert request and response data to/from snake_case and camelCase through axios interceptors
baseAPIClient.interceptors.response.use((response: AxiosResponse) => {
Expand All @@ -30,7 +30,7 @@ baseAPIClient.interceptors.response.use((response: AxiosResponse) => {
return response;
});

// } python
python { */
baseAPIClient.interceptors.request.use(async (config: AxiosRequestConfig) => {
const newConfig = { ...config };

Expand Down Expand Up @@ -67,15 +67,15 @@ baseAPIClient.interceptors.request.use(async (config: AxiosRequestConfig) => {
}

// } auth
// python {
/* python {
if (config.params) {
newConfig.params = decamelizeKeys(config.params);
}
if (config.data && !(config.data instanceof FormData)) {
newConfig.data = decamelizeKeys(config.data);
}

// } python
python { */
return newConfig;
});

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/APIClients/EntityAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ const getFile = async (uuid: string): Promise<string> => {
// no-auth {
const { data } = await baseAPIClient.get(`/entities/files/${uuid}`);
// } no-auth
// typescript {
/* typescript {
return data.fileURL
// } typescript
// python {
} typescript */
/* python {
return data.fileUrl;
// } python
python { */
} catch (error) {
return error;
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ const Login = (): React.ReactElement => {
login,
);
// } graphql
// rest {
/* } rest
const user: AuthenticatedUser = await authAPIClient.login(email, password);
// } rest
} rest */
setAuthenticatedUser(user);
};

Expand All @@ -89,14 +89,14 @@ const Login = (): React.ReactElement => {
setAuthenticatedUser(user);
};
// } graphql
// rest {
/* } rest
const onGoogleLoginSuccess = async (tokenId: string) => {
const user: AuthenticatedUser = await authAPIClient.loginWithGoogle(
tokenId,
);
setAuthenticatedUser(user);
};
// } rest
} rest */

if (authenticatedUser) {
return <Redirect to={HOME_PAGE} />;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/auth/Logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const Logout = (): React.ReactElement => {
logout,
);
// } graphql
// rest {
/* } rest
const success = await authAPIClient.logout(authenticatedUser?.id);
// } rest
} rest */
if (success) {
setAuthenticatedUser(null);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/auth/RefreshCredentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const RefreshCredentials = (): React.ReactElement => {
// graphql {
const success = await authAPIClient.refresh(refresh);
// } graphql
// rest {
/* } rest
const success = await authAPIClient.refresh();
// } rest
} rest */
if (!success) {
setAuthenticatedUser(null);
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/auth/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useContext } from "react";
// graphql {
import { gql, useMutation } from "@apollo/client";
// } graphql
// rest {
/* } rest
import authAPIClient from "../../APIClients/AuthAPIClient";
// } rest
} rest */
import AuthContext from "../../contexts/AuthContext";

// graphql {
Expand All @@ -28,9 +28,9 @@ const ResetPassword = (): React.ReactElement => {
// graphql {
await resetPassword({ variables: { email: authenticatedUser?.email } });
// } graphql
// rest {
/* } rest
await authAPIClient.resetPassword(authenticatedUser?.email);
// } rest
} rest */
};

return (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/auth/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ const Signup = (): React.ReactElement => {
register,
);
// } graphql
// rest {
/* } rest
const user: AuthenticatedUser = await authAPIClient.register(
firstName,
lastName,
email,
password,
);
// } rest
} rest */
setAuthenticatedUser(user);
};

Expand Down
24 changes: 13 additions & 11 deletions frontend/src/components/crud/CreateForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from "react";
// python {
/* python {
import { decamelizeKeys } from "humps";
// } python
python { */
import { JSONSchema7 } from "json-schema";
import { Form } from "@rjsf/bootstrap-4";
// graphql {
Expand All @@ -12,12 +12,12 @@ import {
EntityResponse,
} from "../../APIClients/EntityAPIClient";
// } graphql
// rest {
/* } rest
import EntityAPIClient, {
EntityRequest,
EntityResponse,
} from "../../APIClients/EntityAPIClient";
// } rest
} rest */

const schema: JSONSchema7 = {
title: "Create Entity",
Expand Down Expand Up @@ -147,24 +147,26 @@ const CreateForm = (): React.ReactElement => {
const result: EntityResponse | null =
graphQLResult.data?.createEntity ?? null;
// } graphql
// rest {
/* } rest
// no-file-storage {
const result = await EntityAPIClient.create({ formData });
// } no-file-storage
// file-storage {
const multipartFormData = new FormData();
// typescript {
/* typescript {
multipartFormData.append("body", JSON.stringify(formData));
// } typescript
// python {
} typescript */
/* python {
multipartFormData.append("body", JSON.stringify(decamelizeKeys(formData)));
// } python
python { */
if (fileField) {
multipartFormData.append("file", fileField);
}
const result = await EntityAPIClient.create({ formData: multipartFormData });
const result = await EntityAPIClient.create({
formData: multipartFormData,
});
// } file-storage
// } rest
} rest */
setData(result);
};
// no-file-storage {
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/components/crud/DisplayTableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// graphql {
import React, { useState } from "react";
// } graphql
// rest {
/* } rest
import React, { useState, useEffect } from "react";
// } rest
} rest */
import BTable from "react-bootstrap/Table";
import { HeaderGroup, useTable, Column } from "react-table";

Expand All @@ -13,12 +13,12 @@ import { gql, useApolloClient, useQuery } from "@apollo/client";

import { EntityResponse } from "../../APIClients/EntityAPIClient";
// } graphql
// rest {
/* } rest

import EntityAPIClient, {
EntityResponse,
} from "../../APIClients/EntityAPIClient";
// } rest
} rest */
import { downloadCSV } from "../../utils/CSVUtils";
// file-storage {
import { downloadFile } from "../../utils/FileUtils";
Expand Down Expand Up @@ -219,7 +219,7 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => {
},
});
// } graphql
// rest {
/* } rest
useEffect(() => {
const retrieveAndUpdateData = async () => {
const result = await EntityAPIClient.get();
Expand All @@ -229,7 +229,7 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => {
};
retrieveAndUpdateData();
}, []);
// } rest
} rest */

// file-storage {
const downloadEntityFile = async (fileUUID: string) => {
Expand All @@ -241,10 +241,10 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => {
downloadFile(data.file, "file");
// } graphql

// rest {
/* } rest
const data = await EntityAPIClient.getFile(fileUUID);
downloadFile(data, "file");
// } rest
} rest */
};

// } file-storage
Expand All @@ -256,10 +256,10 @@ const DisplayTableContainer: React.FC = (): React.ReactElement | null => {
});
downloadCSV(data.entitiesCSV, "export.csv");
// } graphql
// rest {
/* } rest
const csvString = await EntityAPIClient.getCSV();
downloadCSV(csvString, "export.csv");
// } rest
} rest */
// Use the following lines to download CSV using frontend CSV generation instead of API
// const csvString = await generateCSV<EntityData>({ data: entities });
// downloadCSV(csvString, "export.csv");
Expand Down
32 changes: 17 additions & 15 deletions frontend/src/components/crud/UpdateForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from "react";
// python {
/* python {
import { decamelizeKeys } from "humps";
// } python
python { */
import { JSONSchema7 } from "json-schema";
import { Form } from "@rjsf/bootstrap-4";
// graphql {
Expand All @@ -12,12 +12,12 @@ import {
EntityResponse,
} from "../../APIClients/EntityAPIClient";
// } graphql
// rest {
/* } rest
import EntityAPIClient, {
EntityRequest,
EntityResponse,
} from "../../APIClients/EntityAPIClient";
// } rest
} rest */

const schema: JSONSchema7 = {
title: "Update Entity",
Expand Down Expand Up @@ -163,27 +163,29 @@ const UpdateForm = (): React.ReactElement => {
const result: EntityResponse | null =
graphQLResult.data?.updateEntity ?? null;
// } graphql
// rest {
/* } rest
// no-file-storage {
const result = await EntityAPIClient.update(formData.id, { entityData });
// } no-file-storage
// file-storage {
const multipartFormData = new FormData();
// typescript {
/* typescript {
multipartFormData.append("body", JSON.stringify(entityData));
// } typescript
// python {
multipartFormData.append("body", JSON.stringify(decamelizeKeys(entityData)));
// } python
} typescript */
/* python {
multipartFormData.append(
"body",
JSON.stringify(decamelizeKeys(entityData)),
);
python { */
if (fileField) {
multipartFormData.append("file", fileField);
}
const result = await EntityAPIClient.update(
formData.id,
{ entityData: multipartFormData }
);
const result = await EntityAPIClient.update(formData.id, {
entityData: multipartFormData,
});
// } file-storage
// } rest
} rest */
setData(result);
};
// no-file-storage {
Expand Down
Loading