Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit ee784c5

Browse files
authored
batches: show total count in workspaces preview header (#37191)
1 parent 215f190 commit ee784c5

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

client/web/src/enterprise/batches/batch-spec/edit/workspaces-preview/WorkspacesPreview.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@
6464
overflow-x: auto;
6565
overflow-y: hidden;
6666
}
67+
68+
.total-count {
69+
font-weight: normal;
70+
margin-left: auto;
71+
}

client/web/src/enterprise/batches/batch-spec/edit/workspaces-preview/WorkspacesPreview.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,30 @@ const MemoizedWorkspacesPreview: React.FunctionComponent<
193193
</>
194194
)
195195

196+
const totalCount = useMemo(() => {
197+
if (shouldShowConnection) {
198+
if (cachedWorkspacesPreview && (showCached || !connection?.nodes.length)) {
199+
return (
200+
<span className={styles.totalCount}>
201+
Displaying {cachedWorkspacesPreview.nodes.length} of {cachedWorkspacesPreview.totalCount}
202+
</span>
203+
)
204+
}
205+
if (connection) {
206+
return (
207+
<span className={styles.totalCount}>
208+
Displaying {connection.nodes.length} of {connection?.totalCount}
209+
</span>
210+
)
211+
}
212+
}
213+
return null
214+
}, [shouldShowConnection, showCached, cachedWorkspacesPreview, connection])
215+
196216
return (
197217
<div className="d-flex flex-column align-items-center w-100 h-100">
198218
<WorkspacesListHeader>
199-
Workspaces {isReadOnly ? '' : 'preview '}
219+
<span>Workspaces {isReadOnly ? '' : 'preview '}</span>
200220
{(isServerStale || resolutionState === 'CANCELED' || !hasPreviewed) &&
201221
shouldShowConnection &&
202222
!isWorkspacesPreviewInProgress &&
@@ -208,6 +228,7 @@ const MemoizedWorkspacesPreview: React.FunctionComponent<
208228
aria-label="The workspaces previewed below may not be up-to-date."
209229
/>
210230
)}
231+
{totalCount}
211232
</WorkspacesListHeader>
212233
{/* We wrap this section in its own div to prevent margin collapsing within the flex column */}
213234
{!isReadOnly && (

client/web/src/enterprise/batches/workspaces-list/Header.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
flex-shrink: 0;
55
display: flex;
66
align-items: center;
7-
justify-content: flex-start;
7+
justify-content: space-between;
88
width: 100%;
99
padding-bottom: 0.5rem;
1010
margin-bottom: 0.5rem;

0 commit comments

Comments
 (0)