Skip to content

Commit d376cf8

Browse files
authored
More defensive 'of many' logic (#461)
1 parent ebe0e34 commit d376cf8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

ui/src/app/shared/header/header.component.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('HeaderComponent', () => {
3939

4040
const initJobs: JobListView = {
4141
results: [testJob1, testJob2, testJob3],
42-
totalSize: null,
42+
totalSize: undefined,
4343
exhaustive: false,
4444
stale: false
4545
};
@@ -139,7 +139,7 @@ describe('HeaderComponent', () => {
139139
testComponent.chips.delete('statuses');
140140
testComponent.jobs.next({
141141
results: [testJob1, testJob2],
142-
totalSize: null,
142+
totalSize: undefined,
143143
exhaustive: true,
144144
stale: false
145145
});
@@ -156,7 +156,7 @@ describe('HeaderComponent', () => {
156156
testComponent.chips.delete('statuses');
157157
testComponent.jobs.next({
158158
results: [testJob1, testJob2],
159-
totalSize: null,
159+
totalSize: undefined,
160160
exhaustive: false,
161161
stale: false
162162
});
@@ -172,7 +172,7 @@ describe('HeaderComponent', () => {
172172
it('should not show length of inexhaustive job streams of unknown length', async(() => {
173173
testComponent.jobs.next({
174174
results: [testJob1],
175-
totalSize: null,
175+
totalSize: undefined,
176176
exhaustive: false,
177177
stale: false
178178
});
@@ -184,7 +184,7 @@ describe('HeaderComponent', () => {
184184
// Transition to exhaustive, "of X" should now display length (even though totalSize is still null).
185185
testComponent.jobs.next({
186186
results: [testJob1, testJob2],
187-
totalSize: null,
187+
totalSize: undefined,
188188
exhaustive: true,
189189
stale: false
190190
});

ui/src/app/shared/header/header.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ export class JobsPaginatorIntl extends MatPaginatorIntl {
281281
getRangeLabel = (page: number, pageSize: number, length: number) => {
282282

283283
let knownLength = null;
284-
285-
if (this.backendJobs.value.totalSize !== null) {
284+
if (this.backendJobs.value.totalSize ||
285+
this.backendJobs.value.totalSize === 0) {
286286
knownLength = this.backendJobs.value.totalSize;
287287
} else if (this.backendJobs.value.exhaustive) {
288288
knownLength = length;

ui/src/app/shared/job-stream.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class JobStream extends BehaviorSubject<JobListView> {
1919
private request: QueryJobsRequest) {
2020
super({
2121
results: [],
22-
totalSize: 0,
22+
totalSize: undefined,
2323
exhaustive: false,
2424
stale: false
2525
});
@@ -72,7 +72,7 @@ export class JobStream extends BehaviorSubject<JobListView> {
7272
// by the exhaustive flag.
7373
export type JobListView = {
7474
results: QueryJobsResult[];
75-
totalSize: number|null;
75+
totalSize: number|undefined;
7676
exhaustive: boolean;
7777
stale: boolean;
7878
}

0 commit comments

Comments
 (0)