From ff4bc3e5d2aaa03be60e55aa227f83bb03443787 Mon Sep 17 00:00:00 2001 From: amazon-meaisiah Date: Mon, 23 Mar 2020 22:21:20 -0700 Subject: [PATCH] Add a couple loading spinners --- dev-portal/src/pages/Admin/ApiManagement.jsx | 21 ++++++++++++--- dev-portal/src/pages/Dashboard.jsx | 27 ++++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/dev-portal/src/pages/Admin/ApiManagement.jsx b/dev-portal/src/pages/Admin/ApiManagement.jsx index a52532a9c..f0e1c76b8 100644 --- a/dev-portal/src/pages/Admin/ApiManagement.jsx +++ b/dev-portal/src/pages/Admin/ApiManagement.jsx @@ -1,6 +1,6 @@ import React from 'react' -import { Button, Table, Modal, Form, Message, Popup, Icon } from 'semantic-ui-react' +import { Button, Loader, Table, Modal, Form, Message, Popup, Icon } from 'semantic-ui-react' import { apiGatewayClient } from 'services/api' import { getApi } from 'services/api-catalog' @@ -34,7 +34,8 @@ export const ApiManagement = observer(class ApiManagement extends React.Componen super(props) this.state = { modalOpen: false, - errors: [] + errors: [], + apisUpdating: [] } this.fileInput = React.createRef() @@ -232,9 +233,23 @@ export const ApiManagement = observer(class ApiManagement extends React.Componen }) } + isUpdatingApiGatewayApi (api) { + return this.state.apisUpdating.includes(`${api.id}_${api.stage}`) + } + updateApiGatewayApi (api) { + // Simpler than implementing a multiset, and probably also faster. + this.setState(({ apisUpdating }) => ({ + apisUpdating: [...apisUpdating, `${api.id}_${api.stage}`] + })) apiGatewayClient() .then(app => app.post('/admin/catalog/visibility', {}, { apiKey: `${api.id}_${api.stage}`, subscribable: `${api.subscribable}` }, {})) + .then(() => this.setState(({ apisUpdating }) => { + const index = apisUpdating.indexOf(`${api.id}_${api.stage}`) + const newApisUpdating = apisUpdating.slice() + newApisUpdating.splice(index, 1) + return { apisUpdating: newApisUpdating } + })) } isSdkGenerationConfigurable (api) { @@ -395,7 +410,7 @@ export const ApiManagement = observer(class ApiManagement extends React.Componen style={{ width: '100%' }} onClick={() => this.updateApiGatewayApi(api)} > - Update + {this.isUpdatingApiGatewayApi(api) ? : 'Update'} diff --git a/dev-portal/src/pages/Dashboard.jsx b/dev-portal/src/pages/Dashboard.jsx index 4b4d402d3..4fcfec3ef 100644 --- a/dev-portal/src/pages/Dashboard.jsx +++ b/dev-portal/src/pages/Dashboard.jsx @@ -92,16 +92,23 @@ export default observer(() => {
API Key
- - {store.apiKey} - + { + store.apiKey + ? ( + + {store.apiKey} + + ) + // Note: this should be the same size as the text + : + }