[SQL Lab] fix table metadata loading spinner (#7121)

* [SQL Lab] fix table metadata loading spinner

The loading spinner used to be close to the new table name that was just
added, and recently flickers and disappears early.

This puts the spinner where it's expected to be.

* Use class

* Addressing comments

* adapt CSS

* add missing license
This commit is contained in:
Maxime Beauchemin 2019-04-09 20:51:35 -07:00 committed by GitHub
parent 1104aca5bd
commit 79dbb3f1fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View File

@ -190,7 +190,11 @@ class TableElement extends React.PureComponent {
</div>
<div className="pull-right">
{table.isMetadataLoading || table.isExtraMetadataLoading ?
<Loading size={50} />
<Loading
size={50}
position="normal"
className="margin-zero"
/>
:
this.renderControls()
}
@ -239,7 +243,6 @@ class TableElement extends React.PureComponent {
<Collapse
in={this.state.expanded}
timeout={this.props.timeout}
transitionAppear
onExited={this.removeFromStore.bind(this)}
>
<div className="TableElement table-schema m-b-10">

View File

@ -0,0 +1,21 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
img.loading.margin-zero {
margin: 0px;
}

View File

@ -19,13 +19,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import './Loading.css';
const propTypes = {
size: PropTypes.number,
position: PropTypes.oneOf(['floating', 'normal']),
className: PropTypes.string,
};
const defaultProps = {
size: 50,
position: 'floating',
className: '',
};
const FLOATING_STYLE = {
@ -37,7 +41,7 @@ const FLOATING_STYLE = {
transform: 'translate(-50%, -50%)',
};
export default function Loading({ size, position }) {
export default function Loading({ size, position, className }) {
const style = position === 'floating' ? FLOATING_STYLE : {};
const styleWithWidth = {
...style,
@ -45,7 +49,7 @@ export default function Loading({ size, position }) {
};
return (
<img
className="loading"
className={`loading ${className}`}
alt="Loading..."
src="/static/assets/images/loading.gif"
style={styleWithWidth}