Skip to content

Commit

Permalink
chore: pull develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Psami-wondah committed Jun 7, 2024
2 parents ae3b4be + 1ab2153 commit a3c973c
Show file tree
Hide file tree
Showing 65 changed files with 2,603 additions and 720 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/1-dx/1-test-login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ describe("Login for a test user on DX", () => {
});

it("Is Logged in", function () {
cy.contains("CREATE REPORT").should("be.visible");
cy.contains("Welcome").should("be.visible");
});
});
8 changes: 5 additions & 3 deletions cypress/e2e/1-dx/2-datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ describe("Testing connecting data on DX", () => {

cy.get('[data-cy="cookie-btn"]').click();

cy.get('[data-cy="create-report-dropdown"]').click();
cy.get('[data-cy="appbar-connect-data"]').click();
cy.get('[data-cy="home-connect-dataset-button"]').click();
});

it("Can import data from External Search", () => {
cy.intercept(`${apiUrl}/external-sources/search?q=*`).as("getDefaultData");
cy.get('[data-cy="external-search-button"]').click();

cy.wait("@getDefaultData").then((interception) => {
cy.get('[data-cy="external-search-card-Kaggle"]').should(
Expand Down Expand Up @@ -129,6 +127,8 @@ describe("Testing connecting data on DX", () => {
// });

it("Can import data through local upload", () => {
cy.get('[data-cy="file-upload-tab"]').click();
cy.get('[data-cy="upload-option-button"').first().click();
cy.get('[data-cy="local-upload-input"]').as("fileInput");
cy.fixture("football-players.csv").then((fileContent) => {
cy.get("@fileInput").attachFile({
Expand All @@ -154,6 +154,8 @@ describe("Testing connecting data on DX", () => {
});

it("Can import another dataset through local upload", () => {
cy.get('[data-cy="file-upload-tab"]').click();
cy.get('[data-cy="upload-option-button"').first().click();
cy.get('[data-cy="local-upload-input"]').as("fileInput");
cy.fixture("grossing-movies.csv").then((fileContent) => {
cy.get("@fileInput").attachFile({
Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/1-dx/3-charts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ describe("Testing create chart on DX", () => {

cy.get('[data-cy="cookie-btn"]').click();

cy.get('[data-cy="create-report-dropdown"]').click();
cy.intercept("GET", `${apiUrl}/datasets?filter=*`).as("getDatasets");
cy.get('[data-cy="appbar-create-chart"]').click();
cy.get('[data-cy="home-create-chart-button"]').click();
cy.wait("@getDatasets");

cy.intercept("GET", `${apiUrl}/chart/sample-data/*`).as("getDataset");
Expand Down Expand Up @@ -190,10 +189,8 @@ describe("Testing Ai chart creation", () => {
cy.visit("/");

cy.get('[data-cy="cookie-btn"]').click();

cy.get('[data-cy="create-report-dropdown"]').click();
cy.intercept("GET", `${apiUrl}/datasets?filter=*`).as("getDatasets");
cy.get('[data-cy="appbar-create-chart"]').click();
cy.get('[data-cy="home-create-chart-button"]').click();
cy.wait("@getDatasets");

cy.intercept("GET", `${apiUrl}/chart/sample-data/*`).as("getDataset");
Expand Down
4 changes: 1 addition & 3 deletions cypress/e2e/1-dx/4-reports.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Testing reports on DX", () => {
});

it("Can Create report", () => {
cy.get('[data-cy="appbar-create-report/login"]').click();
cy.get('[data-cy="home-create-report-button"]').click();

cy.contains(
'[data-cy="report-template-card"]',
Expand Down Expand Up @@ -153,8 +153,6 @@ describe("Testing reports on DX", () => {

cy.visit("/");

cy.wait("@fetchReports");

cy.get('[data-cy="home-charts-tab"]').scrollIntoView().click();

cy.get('[data-cy="home-reports-tab"]').scrollIntoView().click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/1-dx/5-home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Home page tests", () => {
cy.location("pathname").should("include", "/about");
cy.get('[data-cy="empower-block-explore-reports-link"]').click();
cy.wait(2000);
cy.location("pathname").should("include", "/explore");
cy.location("pathname").should("include", "/");
cy.get('[data-cy="nav-about"]').click();
cy.wait(2000);

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"dependencies": {
"@auth0/auth0-react": "^2.2.1",
"@azure/msal-browser": "^3.16.0",
"@craco/craco": "^6.4.3",
"@devhammed/use-cookie": "^1.1.1",
"@draft-js-plugins/anchor": "^4.1.4",
Expand Down
4 changes: 2 additions & 2 deletions src/app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ export function MainRoutes() {
<RouteWithAppBar exact path="/why-dataXplorer">
<WhyDXModule />
</RouteWithAppBar>
<RouteWithAppBar exact path="/explore">
{/* <RouteWithAppBar exact path="/explore">
<ExploreAssetsModule />
</RouteWithAppBar>
</RouteWithAppBar> */}
<RouteWithAppBar exact path="/report/:page/:view?">
<ReportModule />
</RouteWithAppBar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import React from "react";
export default function Icon() {
return (
<svg
width="120"
height="53"
viewBox="0 0 120 53"
width="103"
height="54"
viewBox="0 0 103 54"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M17.6284 52.8814C10.1366 52.8814 4.62788 49.9434 0.66163 45.6834L7.0517 38.1916C9.69587 40.9826 12.8542 43.1861 17.408 43.1861C21.5212 43.1861 24.5326 40.6154 24.5326 36.5022V36.3553C24.5326 31.9484 20.8601 29.3777 14.2497 29.3777H11.1649L9.91622 22.6203L21.2274 10.0605H3.37925V0.585607H34.3013V9.03226L22.2557 21.6655C28.8661 22.9876 35.0358 27.1007 35.0358 35.9881V36.2084C35.0358 46.0506 28.0582 52.8814 17.6284 52.8814ZM63.7573 52V41.4233H41.6491L40.327 33.7112L64.4918 0.29181H73.8198V32.536H80.063V41.4233H73.8198V52H63.7573ZM52.0054 32.536H63.7573V15.9365L52.0054 32.536ZM101.476 52.8814C94.8659 52.8814 89.4306 50.4576 85.0237 46.3444L90.9731 38.4119C94.2783 41.2764 97.3632 43.0392 101.256 43.0392C106.03 43.0392 109.115 40.1747 109.115 35.4739V35.4005C109.115 30.8467 105.589 28.129 100.815 28.129C98.1711 28.129 95.7473 28.8635 93.7641 29.7449L87.8148 25.8521L89.2837 0.585607H117.415V10.134H98.0976L97.51 19.462C99.1994 19.0213 100.815 18.7275 103.239 18.7275C111.98 18.7275 119.545 23.4283 119.545 34.9598V35.1801C119.545 46.1241 112.126 52.8814 101.476 52.8814Z"
fill="black"
d="M9.84277 53V12.1623L1.98371 14.2923L0.294385 5.03772L13.0011 1.21836H20.346V53H9.84277ZM29.312 53V44.4065L44.4425 28.8352C49.8777 23.2531 51.8608 20.462 51.8608 16.7161C51.8608 12.8233 49.2167 10.6199 45.6911 10.6199C42.0921 10.6199 39.5948 12.6764 36.2896 16.7161L29.3854 10.1792C33.8658 4.08288 39.0807 0.851117 46.4991 0.851117C55.974 0.851117 62.6579 6.5067 62.6579 15.8347V15.9816C62.6579 23.1797 59.3526 27.2928 51.7139 34.7112L43.1204 43.4516H62.7313V53H29.312ZM84.9807 53.8814C77.4888 53.8814 71.9802 50.9434 68.0139 46.6834L74.404 39.1916C77.0482 41.9826 80.2065 44.1861 84.7603 44.1861C88.8735 44.1861 91.8849 41.6154 91.8849 37.5022V37.3553C91.8849 32.9484 88.2124 30.3777 81.602 30.3777H78.5171L77.2685 23.6203L88.5797 11.0605H70.7315V1.58561H101.654V10.0323L89.608 22.6655C96.2184 23.9876 102.388 28.1007 102.388 36.9881V37.2084C102.388 47.0506 95.4104 53.8814 84.9807 53.8814Z"
fill="#CFD4DA"
/>
</svg>
);
Expand Down
32 changes: 15 additions & 17 deletions src/app/components/AppBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,17 @@ export function AppBar() {
justify-content: flex-end;
`}
>
{" "}
<div css={navLinkcss("explore", navLocation)}>
<NavLink to="/" data-cy="nav-explore">
<b>Explore </b>
</NavLink>
</div>
<div css={navLinkcss("why-dataXplorer", navLocation)}>
<NavLink to="/why-dataXplorer" data-cy="nav-why">
<b>Why DataXplorer?</b>
</NavLink>
</div>
<div css={navLinkcss("explore", navLocation)}>
<NavLink to="/explore" data-cy="nav-explore">
<b>Explore </b>
</NavLink>
</div>
<div css={navLinkcss("about", navLocation)}>
<Link to="/about" data-cy="nav-about">
<b>About</b>
Expand Down Expand Up @@ -290,7 +291,6 @@ const ActionMenu = () => {
<div>
<div
css={`
gap: 1px;
display: flex;
position: relative;
Expand All @@ -307,34 +307,32 @@ const ActionMenu = () => {
:nth-child(1) {
width: ${isAuthenticated ? "146px" : "110px"};
height: 34px;
border-radius: ${isAuthenticated ? "24px 0px 0px 24px" : "24px"};
border-radius: 24px;
&:hover {
opacity: 1;
opacity: 0.8;
}
}
:nth-child(2) {
/* :nth-child(2) {
width: 41px;
height: 34px;
border-radius: 0px 24px 24px 0px;
background: ${openActionPopover ? "#b5b5db" : "#dadaf8"};
&:hover {
background: #b5b5db;
}
} */
}
svg {
${openActionPopover ? "transform: rotate(180deg)" : ""}
}
}
`}
>
<Link
to={isAuthenticated ? "/report/new/initial" : "/onboarding/login"}
>
<Link to={isAuthenticated ? "/" : "/onboarding/login"}>
<button data-cy="appbar-create-report/login">
{isAuthenticated ? "Create report" : "Log in"}
{isAuthenticated ? "MY DASHBOARD" : "Log in"}
</button>
</Link>
{isAuthenticated && (
{/* {isAuthenticated && (
<button
onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
setActionPopoverAnchorEl(
Expand All @@ -345,15 +343,15 @@ const ActionMenu = () => {
>
<KeyboardArrowDownIcon />
</button>
)}
)} */}
{isAuthenticated && (
<button
onClick={() => history.push("/user-management/profile")}
css={`
min-width: 33px;
height: 33px;
display: flex;
margin-left: 20px;
margin-left: 16px;
border-radius: 50%;
align-items: center;
background: #b5b5db;
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/Dialogs/deleteChartDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CloseOutlined from "@material-ui/icons/ClearOutlined";
import { createStyles, IconButton, makeStyles, Modal } from "@material-ui/core";

interface Props {
chartId?: string;
cardId?: string;
modalDisplay: boolean;
enableButton: boolean;
handleDelete: (id: string) => void;
Expand Down Expand Up @@ -39,7 +39,7 @@ export default function DeleteChartDialog(props: Props) {

const onInputEnter = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter" && e.currentTarget.value === "DELETE") {
props.handleDelete(props.chartId as string);
props.handleDelete(props.cardId as string);
}
};

Expand All @@ -51,7 +51,7 @@ export default function DeleteChartDialog(props: Props) {
>
<div className={classes.paper}>
<form
onSubmit={() => props.handleDelete(props.chartId as string)}
onSubmit={() => props.handleDelete(props.cardId as string)}
data-cy="delete-chart-item-form"
aria-label="form"
>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/Styled/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const Tab = {
display: flex;
justify-content: flex-start;
color: #000000;
margin: 4% 0%;
/* margin: 4% 0%; */
width: 30%;
gap: 40px;
cursor: pointer;
Expand Down
99 changes: 99 additions & 0 deletions src/app/hooks/useGoogleDrivePicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React from "react";
import useDrivePicker from "react-google-drive-picker";
import {
CallbackDoc,
PickerCallback,
} from "react-google-drive-picker/dist/typeDefs";
import axios from "axios";
import { useCookie } from "react-use";

interface Props {
onFileSubmit: (file: File) => void;
onCancel: () => void;
googleDriveToken: string | null;
setGoogleDriveToken: (
newValue: string,
options?: Cookies.CookieAttributes | undefined
) => void;
}

function useGoogleDrivePicker({
onCancel,
onFileSubmit,
googleDriveToken,
setGoogleDriveToken,
}: Props) {
const [openPicker, tokenFromPicker] = useDrivePicker();

const handleGoogleDriveFilePicker = async (
file: CallbackDoc,
accessToken: string
) => {
try {
const response = await axios({
url: `https://www.googleapis.com/drive/v3/files/${file.id}${
file.type === "file" ? "?alt=media" : "/export?mimeType=text/csv"
}`,
method: "GET",
headers: {
Authorization: `Bearer ${accessToken}`,
},
responseType: "blob", // important
});

const b = response?.data;
const gfile = new File([b], file.name, { type: "text/csv" });
onFileSubmit(gfile);
} catch (e) {
console.log(e, "handleGoogleDriveFilePicker error");
}
};
React.useEffect(() => {
if (process.env.REACT_APP_CYPRESS_TEST === "true") {
window.handleGoogleDriveFilePicker = function (file: any, token: string) {
handleGoogleDriveFilePicker(file, token);
};
}
}, []);

React.useEffect(() => {
if (tokenFromPicker) {
setGoogleDriveToken(tokenFromPicker.access_token, {
expires: new Date(new Date().getTime() + 3540 * 1000),
httpsOnly: true,
secure: true,
sameSite: "strict",
});
}
}, [tokenFromPicker]);

const getAccessTokenAndOpenPicker = async () => {
try {
//opens google drive picker
openPicker({
clientId: process.env.REACT_APP_GOOGLE_API_CLIENT_ID as string,
developerKey: process.env.REACT_APP_GOOGLE_API_DEV_KEY as string,
viewId: "SPREADSHEETS",
supportDrives: true,
token: googleDriveToken!,
setSelectFolderEnabled: true,
callbackFunction: (d: PickerCallback) => {
if (d.docs?.[0]) {
handleGoogleDriveFilePicker(
d.docs[0],
googleDriveToken! ?? tokenFromPicker?.access_token
);
} else if (d.action === "cancel") {
onCancel();
}
},
});
} catch (e) {
console.log(e, "error");
}
};

return { getAccessTokenAndOpenPicker };
}

export default useGoogleDrivePicker;
Loading

0 comments on commit a3c973c

Please sign in to comment.