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

Shorten urls, firestore integration, share link through social media and minor fixes #31

Merged
merged 82 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
7bd27bb
removed unnused imports
Rodriguespn Jan 9, 2024
0fd1139
resolve merge conflicty
Rodriguespn Jan 11, 2024
e2be491
resolve merge conflict
Rodriguespn Jan 11, 2024
1d65048
fixed spell errors on README
Rodriguespn Jan 11, 2024
01d4474
searchbar with logo and footer v1.0
Rodriguespn Jan 11, 2024
2d8b999
aligned logo with search buttons and minor styling fixes
Rodriguespn Jan 11, 2024
c8e59ba
changed analyze text, added icons to the buttons and text to footer
Rodriguespn Jan 11, 2024
b9643e4
fixed footer margins
Rodriguespn Jan 11, 2024
a1d4e26
solved conflict issues
Rodriguespn Jan 14, 2024
aee2967
removed unused imports and comments unused variables
Rodriguespn Jan 14, 2024
cb2a438
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 14, 2024
6fe29df
removed unused imports and comments unused variables
Rodriguespn Jan 14, 2024
da0d19b
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 15, 2024
82c44ef
resolved merge conflicts and firebase hosting setup
Rodriguespn Jan 15, 2024
c0fbb4d
Feature/landing page (#5)
Rodriguespn Jan 15, 2024
3bee18f
Merge branch 'development' of github.com:WardAnalytics/WardGraph into…
Rodriguespn Jan 15, 2024
63ab775
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 15, 2024
d928bc3
resolved merge conflicts
Rodriguespn Jan 15, 2024
b66255e
Initial deployment graph app (#7)
Rodriguespn Jan 15, 2024
9d365a4
Merge branch 'development' of github.com:WardAnalytics/WardGraph into…
Rodriguespn Jan 15, 2024
50d2740
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 15, 2024
938d8d2
Merge branch 'main' into development
Rodriguespn Jan 15, 2024
8f856e9
Feature/firebase (#9)
Rodriguespn Jan 15, 2024
ecf392f
Merge branch 'development' of github.com:WardAnalytics/WardGraph into…
Rodriguespn Jan 15, 2024
9500da0
ignores .env.development and .env.production
Rodriguespn Jan 15, 2024
f121d1b
Configure github actions to PR and main merge (#13)
Rodriguespn Jan 15, 2024
eafe7a6
merge conflicts resolved
Rodriguespn Jan 15, 2024
920dc76
Feature/firebase (#15)
Rodriguespn Jan 15, 2024
b7bdb8e
Merge branch 'development' of github.com:WardAnalytics/WardGraph into…
Rodriguespn Jan 15, 2024
22a2e9f
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 15, 2024
7d1b958
resolved merge conflicts between main and development
Rodriguespn Jan 15, 2024
6a89337
New hotbar and bug fixing (#22)
Rodriguespn Jan 15, 2024
11cad36
Merge branch 'main' into development
Rodriguespn Jan 15, 2024
cda9e88
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 15, 2024
9cee603
resolved pull conflicts
Rodriguespn Jan 15, 2024
7dff989
resolved merge conflicts
Rodriguespn Jan 15, 2024
fc9a1d1
Merge/update development (#24)
Rodriguespn Jan 15, 2024
b289f33
Merge branch 'development' of github.com:WardAnalytics/WardGraph into…
Rodriguespn Jan 16, 2024
9d7e765
Merge branch 'main' into development
Rodriguespn Jan 16, 2024
12172e6
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 16, 2024
f014dc4
Merge branch 'main' into development
Rodriguespn Jan 16, 2024
eba6c57
Merge branch 'development' of github.com:WardAnalytics/WardGraph into…
Rodriguespn Jan 16, 2024
c7b54a4
New default addresses for I'm feeling lucky feature (#28)
Rodriguespn Jan 16, 2024
1551dd0
Merge branch 'development' of github.com:WardAnalytics/WardGraph into…
Rodriguespn Jan 16, 2024
fcdac35
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 16, 2024
6f099bd
Merge branch 'main' into development
Rodriguespn Jan 16, 2024
5491e98
comment on .env.example
Rodriguespn Jan 16, 2024
898a822
shorten url, store it on Firestore and redirect short url
Rodriguespn Jan 16, 2024
1196774
changed the layout of the redirect short url page
Rodriguespn Jan 16, 2024
d836891
replaced social media logos for react-icons ones
Rodriguespn Jan 16, 2024
be0f0e2
minor issue fix on social media logos
Rodriguespn Jan 16, 2024
a6222ac
fixed not copying short link first time and new animation when short …
Rodriguespn Jan 16, 2024
e68b713
Merge branch 'main' into feature/shorten-urls
Rodriguespn Jan 16, 2024
355f85f
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 16, 2024
ff09a39
Merge branch 'main' into development
Rodriguespn Jan 16, 2024
44d2a22
resolve merged conflicts with main
Rodriguespn Jan 16, 2024
18239b1
resolve merged conflicts with main
Rodriguespn Jan 16, 2024
75d832e
removed unnecessary imports
Rodriguespn Jan 16, 2024
3ef10a6
add preview image
Rodriguespn Jan 16, 2024
2bfe3cf
Merge branch 'main' into feature/shorten-urls
Rodriguespn Jan 16, 2024
942af34
new created_at field on short url database
Rodriguespn Jan 16, 2024
b16a917
Merge branch 'feature/shorten-urls' of github.com:WardAnalytics/WardG…
Rodriguespn Jan 16, 2024
054fef9
changed github actions env variables to dev evironment
Rodriguespn Jan 16, 2024
f9b508f
changed link preview image
Rodriguespn Jan 16, 2024
f5d99a6
changed link preview image
Rodriguespn Jan 16, 2024
57d3b13
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 17, 2024
19c18e3
Merge branch 'main' into feature/shorten-urls
Rodriguespn Jan 17, 2024
81e0037
add share link dialog with social media
Rodriguespn Jan 17, 2024
88e3a01
Merge branch 'main' of github.com:WardAnalytics/WardGraph
Rodriguespn Jan 18, 2024
5106040
Merge branch 'main' into development
Rodriguespn Jan 18, 2024
062229b
resolve merge conflict
Rodriguespn Jan 18, 2024
fc8ca12
copy url through a button
Rodriguespn Jan 18, 2024
19116eb
copy link message on button click
Rodriguespn Jan 19, 2024
34c6276
removed unused imports
Rodriguespn Jan 19, 2024
5bc40be
installed different uuid package and short url bug
Rodriguespn Jan 19, 2024
e83c747
removed unused imports
Rodriguespn Jan 19, 2024
dfbe7be
Improve styling on share
tubarao312 Jan 19, 2024
b2a5c9a
changed react-icons to heroicons
Rodriguespn Jan 19, 2024
aef1c31
fixed bug on short redirect
Rodriguespn Jan 19, 2024
79ae87d
read shorturl key from window url
Rodriguespn Jan 19, 2024
79f985d
improved share dialog design
Rodriguespn Jan 19, 2024
911695c
Merge branch 'main' into feature/shorten-urls
tubarao312 Jan 19, 2024
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: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# For connection with the backend
VITE_WARD_API_BASE_URL=https://wardanalyticsapi.com
VITE_WARD_API_KEY=

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ name: Deploy to Firebase Hosting on PR
env:
VITE_WARD_API_BASE_URL: "https://wardanalyticsapi.com"
VITE_WARD_API_KEY: ${{ secrets.WARD_API_KEY }}
VITE_FIREBASE_API_KEY: "AIzaSyD1LUGU2RM-bhxKgeYdnzItbwBC0VSTOV0"
VITE_FIREBASE_AUTH_DOMAIN: "graphapp-bca04.firebaseapp.com"
VITE_FIREBASE_PROJECT_ID: "graphapp-bca04"
VITE_FIREBASE_STORAGE_BUCKET: "graphapp-bca04.appspot.com"
VITE_FIREBASE_MESSAGING_SENDER_ID: "1030502540585"
VITE_FIREBASE_APP_ID: "1:1030502540585:web:cfe727695aad44d0494338"
VITE_FIREBASE_API_KEY: "AIzaSyBZCnEQus6G42SodGNRf6o2zmBnGN0nXes"
VITE_FIREBASE_AUTH_DOMAIN: "graphapp-dev.firebaseapp.com"
VITE_FIREBASE_PROJECT_ID: "graphapp-dev"
VITE_FIREBASE_STORAGE_BUCKET: "graphapp-dev.appspot.com"
VITE_FIREBASE_MESSAGING_SENDER_ID: "897485812844"
VITE_FIREBASE_APP_ID: "1:897485812844:web:039de3b976c1559fded449"
# For Google Analytics
VITE_FIREBASE_MEASUREMENT_ID: "G-RYB03B2Q13"
VITE_FIREBASE_MEASUREMENT_ID: "G-V2S9JPMH7S"

jobs:
build_and_preview:
Expand Down
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<!doctype html>
<html lang="en">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="./src/assets/ward-logo-blue.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta property="og:image"
content="https://firebasestorage.googleapis.com/v0/b/graphapp-bca04.appspot.com/o/Screenshot%20from%202024-01-16%2023-18-32-overlay.png?alt=media&token=e573d2ab-db72-4e10-80e4-a51b695aeb3c" />
<title>Ward Graph</title>
</head>

Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-draggable": "^4.4.6",
"react-icons": "^5.0.1",
"react-query": "^3.39.3",
"react-share": "^5.0.3",
"reactflow": "^11.10.1",
"uuid": "^9.0.1",
"vite-plugin-environment": "^1.1.3",
"yarn": "^1.22.21"
},
Expand All @@ -36,6 +39,7 @@
"@types/dotenv": "^8.2.0",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.15",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react": "^4.2.0",
Expand Down
10 changes: 10 additions & 0 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ import { FC, lazy } from "react";
import { RouteObject, useRoutes } from "react-router-dom";

const GraphTemplate = lazy(() => import("./templates/GraphTemplate"));
const RedirectShortUrl = lazy(() => import("./templates/RedirectShortUrl"))

// TODO: Replace the last route with a 404 page
const PublicRoutes: RouteObject[] = [
{
path: "/",
element: <GraphTemplate />,
},
{
path: "/short/:key",
element: <RedirectShortUrl />,
},
{
path: "*",
element: <GraphTemplate />,
},
];

const Routes: FC = () => {
Expand Down
1 change: 0 additions & 1 deletion src/assets/discord.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/github.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/linkedin.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Graph/AnalysisWindow/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const Header: FC<HeaderProps> = ({
</h1>

{/* Clipboard and Block Explorer icons - only shown in expanded mode */}
<CopyToClipboardIcon address={address} />
<CopyToClipboardIcon textToCopy={address} />
{analysisData && (
<BlockExplorerAddressIcon
blockchain={analysisData.blockchain}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { FC, useState } from "react";
import { ClipboardIcon } from "@heroicons/react/24/outline";
import { FC, useState } from "react";

interface CopyToClipboardIconProps {
address: string;
textToCopy: string;
}

/** This component is an icon that copies the address to the clipboard.
* It uses the navigator.clipboard API to copy the address to the clipboard.
/** This component is an icon that copies a piece of text to the clipboard.
* It uses the navigator.clipboard API to copy the text to the clipboard.
*
* @param address: The address to copy
* @param textToCopy: The text to copy
*/

const CopyToClipboardIcon: FC<CopyToClipboardIconProps> = ({ address }) => {
// Function for copying the address to the clipboard
const CopyToClipboardIcon: FC<CopyToClipboardIconProps> = ({ textToCopy }) => {
// Function for copying text to the clipboard
const [isCopied, setIsCopied] = useState(false);
const copyToClipboard = async () => {
try {
await navigator.clipboard.writeText(address);
await navigator.clipboard.writeText(textToCopy);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 500);
} catch (err) {
Expand All @@ -26,9 +26,8 @@ const CopyToClipboardIcon: FC<CopyToClipboardIconProps> = ({ address }) => {

return (
<ClipboardIcon
className={`h-5 w-5 cursor-pointer transition-all duration-200 ${
isCopied ? "text-blue-500" : "text-gray-400 hover:text-gray-500"
}`}
className={`h-5 w-5 cursor-pointer transition-all duration-200 ${isCopied ? "text-blue-500" : "text-gray-400 hover:text-gray-500"
}`}
aria-hidden="true"
onClick={copyToClipboard}
/>
Expand Down
33 changes: 26 additions & 7 deletions src/components/Graph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ import {
convertNodeListToRecord,
} from "./graph_calculations";

import { logEvent } from "firebase/analytics";
import { default as firebase } from "../../firebase/firebase";
import analytics from "../../firebase/analytics";
import firestore, { StoreUrlObject } from "../../firebase/firestore";
import generateShortUrl from "../../utils/generateShortUrl";
import DraggableWindow from "./AnalysisWindow/AnalysisWindow";
import Hotbar from "./Hotbar";
import LandingPage from "./LandingPage/LandingPage";
Expand All @@ -54,7 +55,6 @@ import TransactionTooltip, {
TransactionTooltipProps,
} from "./TransactionTooltip";


/* Pan on drag settings */
const panOnDrag = [1, 2];

Expand All @@ -75,7 +75,8 @@ interface GraphContextProps {
getEdgeHandleID: (edgeID: string) => string;
setFocusedAddressData: (data: AddressAnalysis | null) => void;
setHoveredTransferData: (data: TransactionTooltipProps | null) => void;
copyLink: () => void;
getSharingLink: () => string;
copyLink: (url: string) => void;
doLayout: () => void;
setNodeHighlight: (address: string, highlight: boolean) => void;
getNodeCount: () => number;
Expand Down Expand Up @@ -513,8 +514,25 @@ const GraphProvided: FC<GraphProvidedProps> = ({
)}&paths=${addressPaths.join(",")}`;
}

function copyLink(): void {
navigator.clipboard.writeText(getLink());
async function copyLink(shortenedUrl: string): Promise<void> {
const link = getLink();
const key = shortenedUrl.split("/").pop()!;

console.log("link: ", shortenedUrl);

const storeUrlObj: StoreUrlObject = {
originalUrl: link,
key: key,
};

await firestore.storeUrl(storeUrlObj).then(async (id) => {
if (id) {
await navigator.clipboard.writeText(shortenedUrl);
analytics.logAnalyticsEvent("copy_link", {
link: shortenedUrl,
});
}
});
}

// Getting the node count so that we can show the legend dynamically ---------
Expand All @@ -533,6 +551,7 @@ const GraphProvided: FC<GraphProvidedProps> = ({
setFocusedAddressData,
setHoveredTransferData,
doLayout,
getSharingLink: generateShortUrl,
copyLink,
setNodeHighlight,
getNodeCount,
Expand Down Expand Up @@ -629,7 +648,7 @@ const Graph: FC = () => {
const onSetSearchedAddress = (newAddress: string) => {
setSearchedAddresses([newAddress]);

logEvent(firebase.analytics, "search_address", {
analytics.logAnalyticsEvent("search_address", {
address: newAddress,
});
};
Expand Down
60 changes: 38 additions & 22 deletions src/components/Graph/Hotbar/Hotbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FC, useContext } from "react";
import { RectangleGroupIcon, ShareIcon } from "@heroicons/react/24/solid";
import { FC, useContext, useMemo, useState } from "react";

import { GraphContext } from "../Graph";
import ShareDialog from "../LandingPage/ShareDialog";

interface HotbarButton {
onClick?: () => void;
Expand All @@ -10,7 +11,19 @@ interface HotbarButton {
}

const Hotbar: FC = () => {
const { doLayout, copyLink } = useContext(GraphContext);
const { doLayout, copyLink, getSharingLink } = useContext(GraphContext);

const [isShareDialogOpen, setIsShareDialogOpen] = useState(false);

const shareUrl = useMemo(() => getSharingLink(), []);

const onShareUrl = () => {
copyLink(shareUrl);
}

const openShareDialog = () => {
setIsShareDialogOpen(true);
}

const Buttons: HotbarButton[] = [
{
Expand All @@ -20,28 +33,31 @@ const Hotbar: FC = () => {
},
{
Icon: ShareIcon,
name: "Copy Link",
onClick: copyLink,
},
];
name: "Share",
onClick: openShareDialog
}
]

return (
<div className="flex h-fit w-fit flex-col gap-y-1 rounded-lg bg-gray-800 p-2">
{Buttons.map((button) => {
return (
<button
className="group flex flex-row items-center"
key={button.name}
onClick={button.onClick}
>
<button.Icon className="h-10 w-10 rounded-lg p-1 text-blue-100 transition-all duration-200 hover:bg-gray-700 hover:text-blue-300" />
<h1 className="absolute ml-[3.25rem] mt-0.5 w-max rounded-lg bg-gray-800 px-3 py-2 text-sm font-medium text-blue-300 opacity-0 shadow-sm transition-opacity duration-300 group-hover:opacity-100 dark:bg-gray-700">
{button.name}
</h1>
</button>
);
})}
</div>
<>
<div className="flex h-fit w-fit flex-col gap-y-1 rounded-lg bg-gray-800 p-2">
{Buttons.map((button) => {
return (
<button
className="group flex flex-row items-center"
key={button.name}
onClick={button.onClick}
>
<button.Icon className="h-10 w-10 rounded-lg p-1 text-blue-100 transition-all duration-200 hover:bg-gray-700 hover:text-blue-300" />
<h1 className="absolute ml-[3.25rem] mt-0.5 w-max rounded-lg bg-gray-800 px-3 py-2 text-sm font-medium text-blue-300 opacity-0 shadow-sm transition-opacity duration-300 group-hover:opacity-100 dark:bg-gray-700">
{button.name}
</h1>
</button>
);
})}
</div>
<ShareDialog shareUrl={shareUrl} isOpen={isShareDialogOpen} setIsOpen={setIsShareDialogOpen} onShareUrl={onShareUrl} />
</>
);
};

Expand Down
38 changes: 20 additions & 18 deletions src/components/Graph/LandingPage/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,33 @@ const PossibleAddresses: string[] = [
"0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
"0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97",
"0xd24400ae8BfEBb18cA49Be86258a3C749cf46853"
];
]

interface LandingPageProps {
setSearchedAddress: (address: string) => void;
setSearchedAddress: (address: string) => void
}

const LandingPage: FC<LandingPageProps> = ({ setSearchedAddress }) => {
function selectRandomAddress() {
const randomIndex = Math.floor(Math.random() * PossibleAddresses.length);
setSearchedAddress(PossibleAddresses[randomIndex]);
const randomIndex = Math.floor(Math.random() * PossibleAddresses.length)
setSearchedAddress(PossibleAddresses[randomIndex])
}

return (
<div className="flex max-w-screen-sm flex-col items-center gap-y-10">
<img src={logo} alt="Ward Logo" className="w-2/3" />
<Searchbar className="w-full" onSearchAddress={setSearchedAddress} />
<h3
className="flex cursor-pointer flex-row items-center gap-x-2 text-sm text-blue-500"
onClick={selectRandomAddress}
>
<SparklesIcon className="h-5 w-5 text-blue-500" aria-hidden="true" />
I'm feeling lucky
</h3>
</div>
);
};
<>
<div className="flex max-w-screen-sm flex-col items-center gap-y-10">
<img src={logo} alt="Ward Logo" className="w-2/3" />
<Searchbar className="w-2/3 sm:w-full" onSearchAddress={setSearchedAddress} />
<h3
className="flex cursor-pointer flex-row items-center gap-x-2 text-sm text-blue-500"
onClick={selectRandomAddress}
>
<SparklesIcon className="h-5 w-5 text-blue-500" aria-hidden="true" />
I'm feeling lucky
</h3>
</div>
</>
)
}

export default LandingPage;
export default LandingPage
Loading