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

Standardizing spinner placement and adding missing spinners, Fixes #689 #3226

Merged
merged 8 commits into from
May 2, 2024
4 changes: 4 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ h1 {
font-weight: bold;
}

.card > .card-body {
position: relative;
}

.sidebar-filters > .card-body {
padding: 15px 15px 0 15px;
}
Expand Down
24 changes: 12 additions & 12 deletions src/components/bucket/BucketAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ export default function BucketAttributes({
[bid, updateBucket]
);

if (busy) {
return <Spinner />;
}

return (
<div>
<h1>
Edit <b>{bid}</b> bucket attributes
</h1>
<BucketTabs bid={bid} capabilities={capabilities} selected="attributes">
<BucketForm
session={session}
bid={bid}
bucket={bucket}
formData={formData}
deleteBucket={handleDeleteBucket}
onSubmit={handleSubmit}
/>
{busy ? (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier, why do you like unnecessary parenthesis?

<Spinner />
) : (
<BucketForm
session={session}
bid={bid}
bucket={bucket}
formData={formData}
deleteBucket={handleDeleteBucket}
onSubmit={handleSubmit}
/>
)}
</BucketTabs>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/bucket/BucketCollections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default function BucketCollections({
collections={collections}
listBucketNextCollections={listBucketNextCollections}
capabilities={capabilities}
showSpinner={!collections.loaded}
/>
)}
{listActions}
Expand Down
9 changes: 7 additions & 2 deletions src/components/bucket/BucketGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ export default function BucketCollections({
</h1>
<BucketTabs bid={bid} selected="groups" capabilities={capabilities}>
{listActions}
{groups.length === 0 ? (
{!bucket.busy && groups.length === 0 ? (
<div className="alert alert-info">
<p>This bucket has no groups.</p>
</div>
) : (
<DataList bid={bid} groups={groups} capabilities={capabilities} />
<DataList
bid={bid}
groups={groups}
capabilities={capabilities}
showSpinner={bucket.busy}
/>
)}
{listActions}
</BucketTabs>
Expand Down
19 changes: 10 additions & 9 deletions src/components/bucket/BucketPermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export function BucketPermissions() {

const { busy, permissions } = bucket;
const acls = ["read", "write", "collection:create", "group:create"];
if (busy) {
return <Spinner />;
}
return (
<div>
<h1>
Expand All @@ -32,12 +29,16 @@ export function BucketPermissions() {
capabilities={session.serverInfo.capabilities}
selected="permissions"
>
<PermissionsForm
permissions={permissions}
acls={acls}
readonly={!canEditBucket(session, bucket.data.id)}
onSubmit={onSubmit}
/>
{busy ? (
<Spinner />
) : (
<PermissionsForm
permissions={permissions}
acls={acls}
readonly={!canEditBucket(session, bucket.data.id)}
onSubmit={onSubmit}
/>
)}
</BucketTabs>
</div>
);
Expand Down
16 changes: 15 additions & 1 deletion src/components/bucket/CollectionDataList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Spinner from "../Spinner";
import AdminLink from "@src/components/AdminLink";
import PaginatedTable from "@src/components/PaginatedTable";
import { canCreateCollection } from "@src/permission";
Expand Down Expand Up @@ -28,7 +29,13 @@ export function ListActions(props) {
}

export function DataList(props) {
const { bid, collections, capabilities, listBucketNextCollections } = props;
const {
bid,
collections,
capabilities,
listBucketNextCollections,
showSpinner,
} = props;
const { loaded, entries, hasNextPage } = collections;
const thead = (
<thead>
Expand All @@ -45,6 +52,13 @@ export function DataList(props) {

const tbody = (
<tbody className={!loaded ? "loading" : ""}>
{showSpinner && (
<tr>
<td colSpan={6}>
<Spinner />
</td>
</tr>
)}
{entries.map((collection, index) => {
const {
id: cid,
Expand Down
10 changes: 9 additions & 1 deletion src/components/bucket/GroupDataList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Spinner from "../Spinner";
import AdminLink from "@src/components/AdminLink";
import { canCreateGroup } from "@src/permission";
import { timeago } from "@src/utils";
Expand All @@ -6,7 +7,7 @@ import { Gear } from "react-bootstrap-icons";
import { ClockHistory } from "react-bootstrap-icons";

export function DataList(props) {
const { bid, groups, capabilities } = props;
const { bid, groups, capabilities, showSpinner } = props;
return (
<table className="table table-striped table-bordered record-list">
<thead>
Expand All @@ -18,6 +19,13 @@ export function DataList(props) {
</tr>
</thead>
<tbody>
{showSpinner && (
<tr>
<td colSpan={4}>
<Spinner />
</td>
</tr>
)}
{groups.map((group, index) => {
const { id: gid, members, last_modified } = group;
const date = new Date(last_modified);
Expand Down
28 changes: 14 additions & 14 deletions src/components/collection/CollectionAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ export default function CollectionAttributes({
} = match;
const { busy, data: formData } = collection;

if (busy) {
return <Spinner />;
}

return (
<div>
<h1>
Expand All @@ -82,16 +78,20 @@ export default function CollectionAttributes({
selected="attributes"
capabilities={capabilities}
>
<CollectionForm
bid={bid}
cid={cid}
session={session}
bucket={bucket}
collection={collection}
deleteCollection={handleDeleteCollection}
formData={formData}
onSubmit={onSubmit}
/>
{busy ? (
<Spinner />
) : (
<CollectionForm
bid={bid}
cid={cid}
session={session}
bucket={bucket}
collection={collection}
deleteCollection={handleDeleteCollection}
formData={formData}
onSubmit={onSubmit}
/>
)}
</CollectionTabs>
</div>
);
Expand Down
19 changes: 10 additions & 9 deletions src/components/collection/CollectionPermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ export function CollectionPermissions() {
);
};

if (busy) {
return <Spinner />;
}
return (
<div>
<h1>
Expand All @@ -46,12 +43,16 @@ export function CollectionPermissions() {
capabilities={session.serverInfo.capabilities}
selected="permissions"
>
<PermissionsForm
permissions={permissions}
acls={acls}
readonly={!canEditCollection(session, bucket.data.id, collection)}
onSubmit={onSubmit}
/>
{busy ? (
<Spinner />
) : (
<PermissionsForm
permissions={permissions}
acls={acls}
readonly={!canEditCollection(session, bucket.data.id, collection)}
onSubmit={onSubmit}
/>
)}
</CollectionTabs>
</div>
);
Expand Down
29 changes: 15 additions & 14 deletions src/components/group/GroupAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function GroupAttributes(props: Props) {
params: { bid, gid },
} = match;
const { busy, data: formData } = group;
console.log(group);

const onSubmit = useCallback(
(formData: GroupData) => {
Expand All @@ -60,10 +61,6 @@ export default function GroupAttributes(props: Props) {
[bid, deleteGroup]
);

if (busy || formData == null) {
return <Spinner />;
}

return (
<div>
<h1>
Expand All @@ -79,16 +76,20 @@ export default function GroupAttributes(props: Props) {
selected="attributes"
capabilities={capabilities}
>
<GroupForm
bid={bid}
gid={gid}
session={session}
bucket={bucket}
group={group}
deleteGroup={onDeleteGroup}
formData={formData}
onSubmit={onSubmit}
/>
{busy || formData == null ? ( // formData will be null until it is fetched, busy will be false until the fetch starts, need to wait for for both conditions before rendering
<Spinner />
) : (
<GroupForm
bid={bid}
gid={gid}
session={session}
bucket={bucket}
group={group}
deleteGroup={onDeleteGroup}
formData={formData}
onSubmit={onSubmit}
/>
)}
</GroupTabs>
</div>
);
Expand Down
19 changes: 10 additions & 9 deletions src/components/group/GroupPermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export function GroupPermissions() {
const onSubmit = ({ formData }: { formData: GroupPermissionsType }) => {
dispatch(BucketActions.updateGroup(bid, gid, { permissions: formData }));
};
if (busy) {
return <Spinner />;
}
return (
<div>
<h1>
Expand All @@ -40,12 +37,16 @@ export function GroupPermissions() {
capabilities={session.serverInfo.capabilities}
selected="permissions"
>
<PermissionsForm
permissions={permissions}
acls={["read", "write"]}
readonly={!canEditGroup(session, bucket.data.id, group)}
onSubmit={onSubmit}
/>
{busy ? (
<Spinner />
) : (
<PermissionsForm
permissions={permissions}
acls={["read", "write"]}
readonly={!canEditGroup(session, bucket.data.id, group)}
onSubmit={onSubmit}
/>
)}
</GroupTabs>
</div>
);
Expand Down
19 changes: 10 additions & 9 deletions src/components/record/RecordPermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export function RecordPermissions() {
};
const { busy, permissions } = record;
const acls = ["read", "write"];
if (busy) {
return <Spinner />;
}
return (
<div>
<h1>
Expand All @@ -45,12 +42,16 @@ export function RecordPermissions() {
capabilities={session.serverInfo.capabilities}
selected="permissions"
>
<PermissionsForm
permissions={permissions}
acls={acls}
readonly={!canEditRecord(session, bid, collection, record)}
onSubmit={onSubmit}
/>
{busy ? (
<Spinner />
) : (
<PermissionsForm
permissions={permissions}
acls={acls}
readonly={!canEditRecord(session, bid, collection, record)}
onSubmit={onSubmit}
/>
)}
</RecordTabs>
</div>
);
Expand Down
10 changes: 4 additions & 6 deletions src/components/signoff/SimpleReview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export default function SimpleReview({
console.error(ex);
}
}
} else {
setRecords({ oldRecords: [], newRecords: [], loading: false });
}
}
getRecords();
Expand All @@ -137,11 +139,7 @@ export default function SimpleReview({
Not authenticated
</div>
);
} else if (
session.authenticating ||
session.busy ||
(records.loading && signoffSource && signoffDest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall why we had this condition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we were just having one spinner for any of the conditions. In this case if we're waiting for auth, waiting for session info to load, waiting for the records to load, or waiting for the signoff info to load just show a spinner.

But now we've broken it up. If we have enough context to render the tabs (auth and session) we do so. And then we show a spinner under the tabs if we're waiting for the records or signoff info still.

) {
} else if (session.authenticating || session.busy) {
return <Spinner />;
}
const handleRollback = (text: string) => {
Expand Down Expand Up @@ -212,7 +210,7 @@ export default function SimpleReview({
capabilities={capabilities || {}}
totalRecords={collection?.totalRecords || 0}
>
<SignoffContent />
{records.loading ? <Spinner /> : <SignoffContent />}
</CollectionTabs>
</div>
);
Expand Down
Loading
Loading