diff --git a/src/frontend/src/components/headerComponent/index.tsx b/src/frontend/src/components/headerComponent/index.tsx
index 039b8895c..2a7219fed 100644
--- a/src/frontend/src/components/headerComponent/index.tsx
+++ b/src/frontend/src/components/headerComponent/index.tsx
@@ -7,8 +7,17 @@ import { alertContext } from "../../contexts/alertContext";
import { AuthContext } from "../../contexts/authContext";
import { darkContext } from "../../contexts/darkContext";
import { TabsContext } from "../../contexts/tabsContext";
+import { gradients } from "../../utils/styleUtils";
import IconComponent from "../genericIconComponent";
import { Button } from "../ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "../ui/dropdown-menu";
import { Separator } from "../ui/separator";
import MenuBar from "./components/menuBar";
@@ -17,7 +26,7 @@ export default function Header(): JSX.Element {
const { dark, setDark } = useContext(darkContext);
const { notificationCenter } = useContext(alertContext);
const location = useLocation();
- const { logout, autoLogin, isAdmin } = useContext(AuthContext);
+ const { logout, autoLogin, isAdmin, userData } = useContext(AuthContext);
const { stars } = useContext(darkContext);
const navigate = useNavigate();
@@ -31,40 +40,6 @@ export default function Header(): JSX.Element {
{flows.findIndex((f) => tabId === f.id) !== -1 && tabId !== "" && (
)}
- {!autoLogin && location.pathname !== `/flow/${tabId}` && (
- {
- logout();
- navigate("/login");
- }}
- className="mx-5 cursor-pointer text-sm font-medium text-muted-foreground transition-colors hover:text-primary"
- >
- Sign out
-
- )}
-
- {location.pathname === "/admin" && (
- {
- navigate("/");
- }}
- className="cursor-pointer text-sm font-medium text-muted-foreground transition-colors hover:text-primary"
- >
- Home
-
- )}
-
- {isAdmin &&
- !autoLogin &&
- location.pathname !== "/admin" &&
- location.pathname !== `/flow/${tabId}` && (
- navigate("/admin")}
- >
- Admin page
-
- )}
@@ -156,6 +131,40 @@ export default function Header(): JSX.Element {
/>
)}
+ {!autoLogin && (
+ <>
+
+
+
+
+
+
+ My Account
+
+ {isAdmin && (
+ navigate("/admin")}>
+ Admin Page
+
+ )}
+ {
+ logout();
+ navigate("/login");
+ }}
+ >
+ Sign Out
+
+
+
+ >
+ )}
diff --git a/src/frontend/src/components/inputComponent/index.tsx b/src/frontend/src/components/inputComponent/index.tsx
index 987c53a8f..46acdc1b0 100644
--- a/src/frontend/src/components/inputComponent/index.tsx
+++ b/src/frontend/src/components/inputComponent/index.tsx
@@ -30,6 +30,7 @@ export default function InputComponent({
{isForm ? (
) : (
{
+ return (
+
+ );
+};
diff --git a/src/frontend/src/components/ui/skeleton.tsx b/src/frontend/src/components/ui/skeleton.tsx
new file mode 100644
index 000000000..6556585a4
--- /dev/null
+++ b/src/frontend/src/components/ui/skeleton.tsx
@@ -0,0 +1,15 @@
+import { cn } from "../../utils/utils"
+
+function Skeleton({
+ className,
+ ...props
+}: React.HTMLAttributes) {
+ return (
+
+ )
+}
+
+export { Skeleton }
diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx
index ac0d676e0..97ad50329 100644
--- a/src/frontend/src/contexts/tabsContext.tsx
+++ b/src/frontend/src/contexts/tabsContext.tsx
@@ -39,6 +39,7 @@ const TabsContextInitialValue: TabsContextType = {
save: () => {},
tabId: "",
setTabId: (index: string) => {},
+ isLoading: true,
flows: [],
removeFlow: (id: string) => {},
addFlow: async (flowData?: any) => "",
@@ -72,10 +73,12 @@ export const TabsContext = createContext(
export function TabsProvider({ children }: { children: ReactNode }) {
const { setErrorData, setNoticeData, setSuccessData } =
useContext(alertContext);
- const { getAuthentication } = useContext(AuthContext);
+ const { getAuthentication, isAuthenticated } = useContext(AuthContext);
const [tabId, setTabId] = useState("");
+ const [isLoading, setIsLoading] = useState(true);
+
const [flows, setFlows] = useState>([]);
const [id, setId] = useState(uid());
const { templates, reactFlowInstance } = useContext(typesContext);
@@ -86,6 +89,12 @@ export function TabsProvider({ children }: { children: ReactNode }) {
const [tabsState, setTabsState] = useState({});
const [getTweak, setTweak] = useState([]);
+ useEffect(() => {
+ if (!isAuthenticated) {
+ hardReset();
+ }
+ }, [isAuthenticated]);
+
const newNodeId = useRef(uid());
function incrementNodeId() {
newNodeId.current = uid();
@@ -116,11 +125,13 @@ export function TabsProvider({ children }: { children: ReactNode }) {
}
function refreshFlows() {
+ setIsLoading(true);
getTabsDataFromDB().then((DbData) => {
if (DbData && Object.keys(templates).length > 0) {
try {
processDBData(DbData);
updateStateWithDbData(DbData);
+ setIsLoading(false);
} catch (e) {}
}
});
@@ -229,6 +240,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
setTabId("");
setFlows([]);
+ setIsLoading(true);
setId(uid());
}
@@ -641,6 +653,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
paste,
getTweak,
setTweak,
+ isLoading,
}}
>
{children}
diff --git a/src/frontend/src/pages/MainPage/index.tsx b/src/frontend/src/pages/MainPage/index.tsx
index f3fe68a6c..f6f111185 100644
--- a/src/frontend/src/pages/MainPage/index.tsx
+++ b/src/frontend/src/pages/MainPage/index.tsx
@@ -3,13 +3,21 @@ import { Link, useNavigate } from "react-router-dom";
import { CardComponent } from "../../components/cardComponent";
import IconComponent from "../../components/genericIconComponent";
import Header from "../../components/headerComponent";
+import { SkeletonCardComponent } from "../../components/skeletonCardComponent";
import { Button } from "../../components/ui/button";
import { USER_PROJECTS_HEADER } from "../../constants/constants";
import { TabsContext } from "../../contexts/tabsContext";
import DropdownButton from "../../components/DropdownButtonComponent";
export default function HomePage(): JSX.Element {
- const { flows, setTabId, downloadFlows, uploadFlows, addFlow, removeFlow, uploadFlow } =
- useContext(TabsContext);
+ const {
+ flows,
+ setTabId,
+ downloadFlows,
+ uploadFlows,
+ addFlow,
+ removeFlow, uploadFlow,
+ isLoading,
+ } = useContext(TabsContext);
const dropdownOptions = [{name: "Import from JSON", onBtnClick: () => uploadFlow(true)}]
// Set a null id
@@ -18,6 +26,10 @@ export default function HomePage(): JSX.Element {
}, []);
const navigate = useNavigate();
+ useEffect(() => {
+ console.log(isLoading);
+ }, [isLoading]);
+
// Personal flows display
return (
<>
@@ -62,31 +74,40 @@ export default function HomePage(): JSX.Element {
Manage your personal projects. Download or upload your collection.
- {flows.map((flow, idx) => (
-
-
-
- }
- onDelete={() => {
- removeFlow(flow.id);
- }}
- />
- ))}
+ {isLoading && flows.length == 0 ? (
+ <>
+
+
+
+
+ >
+ ) : (
+ flows.map((flow, idx) => (
+
+
+
+ }
+ onDelete={() => {
+ removeFlow(flow.id);
+ }}
+ />
+ ))
+ )}
>
diff --git a/src/frontend/src/pages/loginPage/index.tsx b/src/frontend/src/pages/loginPage/index.tsx
index a3ac0fbcd..181486c99 100644
--- a/src/frontend/src/pages/loginPage/index.tsx
+++ b/src/frontend/src/pages/loginPage/index.tsx
@@ -90,6 +90,7 @@ export default function LoginPage(): JSX.Element {
{
handleInput({ target: { name: "username", value } });
}}
@@ -130,12 +131,12 @@ export default function LoginPage(): JSX.Element {
-
+
-