Merge branch '17229-integrate-webshell' into main. Closes #17229
authorStephen Smith <stephen@curii.com>
Thu, 23 Sep 2021 17:47:01 +0000 (13:47 -0400)
committerStephen Smith <stephen@curii.com>
Thu, 23 Sep 2021 17:47:01 +0000 (13:47 -0400)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/common/formatters.test.ts [new file with mode: 0644]
src/common/formatters.ts
src/components/data-explorer/data-explorer.tsx
src/store/data-explorer/data-explorer-reducer.ts

diff --git a/src/common/formatters.test.ts b/src/common/formatters.test.ts
new file mode 100644 (file)
index 0000000..83177e2
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { formatUploadSpeed } from "./formatters";
+
+describe('formatUploadSpeed', () => {
+    it('should show speed less than 1MB/s', () => {
+        // given
+        const speed = 900;
+
+        // when
+        const result = formatUploadSpeed(0, speed, 0, 1);
+
+        // then
+        expect(result).toBe('0.90 MB/s');
+    });
+
+    it('should show 5MB/s', () => {
+        // given
+        const speed = 5230;
+
+        // when
+        const result = formatUploadSpeed(0, speed, 0, 1);
+
+        // then
+        expect(result).toBe('5.23 MB/s');
+    }); 
+});
\ No newline at end of file
index 779809f1569494da93c599706fd1d977201df46a..6d0a7e491e4e508384ccbad42f66cc2eb3f8c195 100644 (file)
@@ -61,7 +61,8 @@ export function formatUploadSpeed(prevLoaded: number, loaded: number, prevTime:
     const speed = loaded > prevLoaded && currentTime > prevTime
         ? (loaded - prevLoaded) / (currentTime - prevTime)
         : 0;
-    return `${(speed / 1000).toFixed(2)} KB/s`;
+
+    return `${(speed / 1000).toFixed(2)} MB/s`;
 }
 
 const FILE_SIZES = [
index a38d0ed65ae3c03eb9affdd76a67cf423b2fbd60..d272e870bf0caaa46c7918624fe091265fb5c762 100644 (file)
@@ -134,6 +134,8 @@ export const DataExplorer = withStyles(styles)(
                             page={this.props.page}
                             onChangePage={this.changePage}
                             onChangeRowsPerPage={this.changeRowsPerPage}
+                            // Disable next button on empty lists since that's not default behavior
+                            nextIconButtonProps={(itemsAvailable > 0) ? {} : {disabled: true}}
                             component="div" /> : <Button
                                 variant="text"
                                 size="medium"
index c6aa7116b8de9d79341b0c56cdbc2f3d5a526b89..f67cccdcd48dc9eaea220c835149549d6dc871f6 100644 (file)
@@ -57,7 +57,7 @@ export const dataExplorerReducer = (state: DataExplorerState = {}, action: DataE
             update(state, id, mapColumns(setFilters(columnName, filters))),
 
         SET_ITEMS: ({ id, items, itemsAvailable, page, rowsPerPage }) =>
-            update(state, id, explorer => ({ ...explorer, items, itemsAvailable, page, rowsPerPage })),
+            update(state, id, explorer => ({ ...explorer, items, itemsAvailable, page: page || 0, rowsPerPage })),
 
         APPEND_ITEMS: ({ id, items, itemsAvailable, page, rowsPerPage }) =>
             update(state, id, explorer => ({