Skip to content

Commit 4fb1cdd

Browse files
Show an inline loader in the executions timeline while paginating
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
1 parent df937f4 commit 4fb1cdd

5 files changed

Lines changed: 39 additions & 14 deletions

File tree

src/components/modules/TransferModule/Executions/Executions.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type Props = {
8787
executions: Execution[];
8888
executionsTasks: ExecutionTasks[];
8989
loading: boolean;
90+
paginationLoading?: boolean;
9091
tasksLoading: boolean;
9192
instancesDetails: Instance[];
9293
hasOlderExecutions?: boolean;
@@ -322,6 +323,7 @@ class Executions extends React.Component<Props, State> {
322323
items={this.props.executions}
323324
selectedItem={this.state.selectedExecution}
324325
hasOlderItems={this.props.hasOlderExecutions}
326+
loading={this.props.paginationLoading}
325327
onPreviousClick={() => {
326328
this.handlePreviousExecutionClick();
327329
}}

src/components/modules/TransferModule/Timeline/Timeline.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ const Wrapper = styled.div<any>`
4040
opacity: 1;
4141
}
4242
`;
43+
const LoadingIcon = styled(StatusIcon)`
44+
position: absolute;
45+
top: 0;
46+
left: -19px;
47+
`;
4348
const MainLine = styled.div<any>`
4449
width: 100%;
4550
padding-top: 7px;
@@ -85,6 +90,7 @@ type Props = {
8590
items?: Execution[] | null;
8691
selectedItem?: Execution | null;
8792
hasOlderItems?: boolean;
93+
loading?: boolean;
8894
onPreviousClick?: () => void;
8995
onNextClick?: () => void;
9096
onItemClick?: (item: Execution) => void;
@@ -215,16 +221,20 @@ class Timeline extends React.Component<Props> {
215221
this.wrapperRef = w;
216222
}}
217223
>
218-
<ArrowStyled
219-
orientation="left"
220-
forceShow={
221-
!this.props.items ||
222-
!this.props.items.length ||
223-
this.props.hasOlderItems
224-
}
225-
primary={Boolean(this.props.items && this.props.items.length)}
226-
onClick={this.props.onPreviousClick}
227-
/>
224+
{this.props.loading ? (
225+
<LoadingIcon status="RUNNING" />
226+
) : (
227+
<ArrowStyled
228+
orientation="left"
229+
forceShow={
230+
!this.props.items ||
231+
!this.props.items.length ||
232+
this.props.hasOlderItems
233+
}
234+
primary={Boolean(this.props.items && this.props.items.length)}
235+
onClick={this.props.onPreviousClick}
236+
/>
237+
)}
228238
{this.renderMainLine()}
229239
{this.renderItems()}
230240
<ArrowStyled

src/components/modules/TransferModule/TransferDetailsContent/TransferDetailsContent.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type Props = {
8989
detailsLoading: boolean;
9090
executions: Execution[];
9191
executionsLoading: boolean;
92+
executionsPaginationLoading?: boolean;
9293
executionsTasksLoading: boolean;
9394
executionsTasks: ExecutionTasks[];
9495
minionPools: MinionPool[];
@@ -211,6 +212,7 @@ class TransferDetailsContent extends React.Component<Props, State> {
211212
onDeleteExecutionClick={this.props.onDeleteExecutionClick}
212213
onExecuteClick={this.props.onExecuteClick}
213214
loading={this.props.executionsLoading || this.props.detailsLoading}
215+
paginationLoading={this.props.executionsPaginationLoading}
214216
onChange={this.props.onExecutionChange}
215217
tasksLoading={this.props.executionsTasksLoading}
216218
instancesDetails={this.props.instancesDetails}

src/components/smart/TransferDetailsPage/TransferDetailsPage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,9 @@ class TransferDetailsPage extends React.Component<Props, State> {
866866
this.handleExecutionChange(id);
867867
}}
868868
executions={transferStore.executionsList}
869+
executionsPaginationLoading={
870+
transferStore.executionsPaginationLoading
871+
}
869872
hasOlderExecutions={transferStore.executionsHasOlderPage}
870873
onLoadOlderExecutions={() => {
871874
transferStore.loadOlderExecutions();

src/stores/TransferStore.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class TransferStore {
8888

8989
@observable executionsLoading = false;
9090

91+
@observable executionsPaginationLoading = false;
92+
9193
executionsPageSize = 10;
9294

9395
@action resetTransferPagination(): void {
@@ -100,6 +102,7 @@ class TransferStore {
100102
this.executionsList = [];
101103
this.executionsHasOlderPage = false;
102104
this.executionsLoading = false;
105+
this.executionsPaginationLoading = false;
103106
}
104107

105108
@action async getTransferExecutions(options?: {
@@ -136,7 +139,12 @@ class TransferStore {
136139

137140
@action async loadOlderExecutions(): Promise<void> {
138141
const transferId = this.transferDetails?.id;
139-
if (!transferId || !this.executionsHasOlderPage || this.executionsLoading) {
142+
if (
143+
!transferId ||
144+
!this.executionsHasOlderPage ||
145+
this.executionsLoading ||
146+
this.executionsPaginationLoading
147+
) {
140148
return;
141149
}
142150

@@ -145,7 +153,7 @@ class TransferStore {
145153
return;
146154
}
147155

148-
this.executionsLoading = true;
156+
this.executionsPaginationLoading = true;
149157

150158
try {
151159
const raw = await TransferSource.getExecutions(transferId, {
@@ -158,12 +166,12 @@ class TransferStore {
158166
runInAction(() => {
159167
this.executionsList = [...raw, ...this.executionsList];
160168
this.executionsHasOlderPage = hasOlderPage;
161-
this.executionsLoading = false;
169+
this.executionsPaginationLoading = false;
162170
});
163171
} catch (err) {
164172
runInAction(() => {
165173
this.executionsHasOlderPage = false;
166-
this.executionsLoading = false;
174+
this.executionsPaginationLoading = false;
167175
});
168176
console.error(err);
169177
}

0 commit comments

Comments
 (0)