From 797ddfa046c70bea55313ee48e66bdb1c362608b Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Tue, 28 Sep 2021 17:15:32 +0100 Subject: [PATCH] Less flashing from loading page on org/ssh key pages --- migrations/2021-08-31-214501_create_crates_table/up.sql | 1 + chartered-frontend/src/pages/Loading.tsx | 12 +++++++++++- chartered-frontend/src/pages/organisations/ListOrganisations.tsx | 70 +++++++++++++++++++++++++++++++++++++++++++++------------------------- chartered-frontend/src/pages/ssh-keys/ListSshKeys.tsx | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------- 4 files changed, 123 insertions(+), 113 deletions(-) diff --git a/migrations/2021-08-31-214501_create_crates_table/up.sql b/migrations/2021-08-31-214501_create_crates_table/up.sql index fd57f0a..4f94311 100644 --- a/migrations/2021-08-31-214501_create_crates_table/up.sql +++ a/migrations/2021-08-31-214501_create_crates_table/up.sql @@ -5,6 +5,7 @@ ); INSERT INTO users (id, uuid, username) VALUES (1, X'936DA01F9ABD4D9D80C702AF85C822A8', "admin"); +INSERT INTO users (id, uuid, username) VALUES (2, X'936DA01F9ABD4D9D80C702AF85C822A9', "billy"); CREATE TABLE organisations ( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, diff --git a/chartered-frontend/src/pages/Loading.tsx b/chartered-frontend/src/pages/Loading.tsx index 90055d1..a92e405 100644 --- a/chartered-frontend/src/pages/Loading.tsx +++ a/chartered-frontend/src/pages/Loading.tsx @@ -1,6 +1,16 @@ import React = require("react"); -export default function Loading() { +export function LoadingSpinner() { + return ( +
+
+ Loading... +
+
+ ); +} + +export default function LoadingPage() { return (
diff --git a/chartered-frontend/src/pages/organisations/ListOrganisations.tsx b/chartered-frontend/src/pages/organisations/ListOrganisations.tsx index bcafc46..7e00c09 100644 --- a/chartered-frontend/src/pages/organisations/ListOrganisations.tsx +++ a/chartered-frontend/src/pages/organisations/ListOrganisations.tsx @@ -6,7 +6,7 @@ import { useAuth } from "../../useAuth"; import { RoundedPicture, useAuthenticatedRequest } from "../../util"; import ErrorPage from "../ErrorPage"; -import Loading from "../Loading"; +import { LoadingSpinner } from "../Loading"; interface Response { organisations: ResponseOrganisations[]; @@ -27,8 +27,6 @@ if (error) { return ; - } else if (!list) { - return ; } return ( @@ -39,38 +37,40 @@

Your Organisations

- {list.organisations.length === 0 ? ( -
- You don't belong to any organisations yet. -
- ) : ( - - - {list.organisations.map((v, i) => ( - - - - - - ))} - -
- - -
- {v.name} -
-
- - {v.description} - -
-
- )} + {!list ? : <> + {list.organisations.length === 0 ? ( +
+ You don't belong to any organisations yet. +
+ ) : ( + + + {list.organisations.map((v, i) => ( + + + + + + ))} + +
+ + +
+ {v.name} +
+
+ + {v.description} + +
+
+ )} + }
; - } else if (!sshKeys) { - return ; } const deleteKey = async () => { @@ -99,81 +97,82 @@
- {sshKeys.keys.length == 0 ? ( -
You haven't added any SSH keys yet
- ) : ( - <> - )} -
- - - {sshKeys.keys.map((key) => ( - - + + + + ))} + +
-
{key.name}
-
{key.fingerprint}
-
-
- Added{" "} - - {new Date(key.created_at).toLocaleString()} - - } - > - - - - -
- dateMonthAgo - ? "success" - : "danger" - : "muted" - }`} - > - Last used{" "} - {key.last_used_at ? ( - - {new Date(key.last_used_at).toLocaleString()} - - } + {!sshKeys ? : <> + {sshKeys.keys.length == 0 ? ( +
You haven't added any SSH keys yet.
+ ) : ( +
+ + + {sshKeys.keys.map((key) => ( + + - - - - ))} - -
+
{key.name}
+
{key.fingerprint}
+
+
+ Added{" "} + + {new Date(key.created_at).toLocaleString()} + + } + > + + + + +
+ dateMonthAgo + ? "success" + : "danger" + : "muted" + }`} > - - - - - ) : ( - <>never - )} - -
-
- -
-
+ Last used{" "} + {key.last_used_at ? ( + + {new Date(key.last_used_at).toLocaleString()} + + } + > + + + + + ) : ( + <>never + )} +
+
+
+ +
+
+ )} + }