Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sqllab): Change icon color for running sql #22050

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import createCache from '@emotion/cache';

export {
css,
keyframes,
jsx,
ThemeProvider,
CacheProvider as EmotionCacheProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryState } from '@superset-ui/core';
import React from 'react';
import sinon from 'sinon';
import { shallow } from 'enzyme';

import { render } from 'spec/helpers/testing-library';
import TabStatusIcon from 'src/SqlLab/components/TabStatusIcon';

function setup() {
const onClose = sinon.spy();
const wrapper = shallow(
<TabStatusIcon onClose={onClose} tabState="running" />,
);
return { wrapper, onClose };
return render(<TabStatusIcon tabState={'running' as QueryState} />);
}

describe('TabStatusIcon', () => {
it('renders a circle without an x when hovered', () => {
const { wrapper } = setup();
expect(wrapper.find('div.circle')).toExist();
expect(wrapper.text()).toBe('');
const { container } = setup();
expect(container.getElementsByClassName('circle')[0]).toBeInTheDocument();
expect(
container.getElementsByClassName('circle')[0]?.textContent ?? 'undefined',
).toBe('');
});
});
25 changes: 23 additions & 2 deletions superset-frontend/src/SqlLab/components/TabStatusIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,33 @@
* under the License.
*/
import React from 'react';
import { QueryState } from '@superset-ui/core';
import { QueryState, styled } from '@superset-ui/core';
import Icons, { IconType } from 'src/components/Icons';

const IconContainer = styled.span`
position: absolute;
top: -7px;
left: 0px;
`;

interface TabStatusIconProps {
tabState: QueryState;
}

const STATE_ICONS: Record<string, React.FC<IconType>> = {
success: Icons.Check,
failed: Icons.CancelX,
};

export default function TabStatusIcon({ tabState }: TabStatusIconProps) {
return <div className={`circle ${tabState}`} />;
const StatusIcon = STATE_ICONS[tabState];
return (
<div className={`circle ${tabState}`}>
{StatusIcon && (
<IconContainer>
<StatusIcon iconSize="xs" />
</IconContainer>
)}
</div>
);
}
5 changes: 3 additions & 2 deletions superset-frontend/src/SqlLab/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,12 @@ div.Workspace {
vertical-align: middle;
font-size: @font-size-m;
font-weight: @font-weight-bold;
color: @lightest;
position: relative;
}

.running {
background-color: fade(@success, @opacity-heavy);
color: @darkest;
background-color: @info;
}

.success {
Expand Down