Skip to content

Commit c29b876

Browse files
added circular progress (#2885)
Signed-off-by: msivasubramaniaan <[email protected]>
1 parent 3d346c4 commit c29b876

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

src/webview/common/loading.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,40 @@
22
* Copyright (c) Red Hat, Inc. All rights reserved.
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
5-
import { Box, Typography } from '@mui/material';
5+
import { Box, CircularProgress, Typography } from '@mui/material';
66
import LinearProgress from '@mui/material/LinearProgress';
77
import { makeStyles } from '@mui/styles';
88
import * as React from 'react';
99
import loaderStyle from './loading.style';
1010

1111
interface LoadProps extends React.AllHTMLAttributes<HTMLDivElement> {
12-
title: string
12+
title: string,
13+
type?: string
1314
}
1415

1516
const useLoadingStyle = makeStyles(loaderStyle);
1617

1718
export const LoadScreen: React.FC<LoadProps> = ({
18-
title
19+
title,
20+
type
1921
}: LoadProps) => {
2022
const loadingStyle = useLoadingStyle();
23+
const isCircular = type && type === 'circle';
2124
const isInstall = title.indexOf('Install') !== -1;
2225
return (
23-
<div className={isInstall ? '' : loadingStyle.loading}>
24-
<div style={{ width : isInstall ? 'auto' : '30rem' }}>
26+
<div className={isInstall ? '' : loadingStyle.loading} style={{ float: 'right', marginRight: '0.5rem' }}>
27+
<div style={{ width: isInstall ? 'auto' : '30rem', display: 'flex', flexDirection: isCircular ? 'row' : 'column' }}>
2528
<Box sx={{ color: '#EE0000' }}>
26-
<LinearProgress color='inherit' sx={{ height: isInstall ? '0.5rem' : '1rem' }} />
29+
{type && type === 'circle' ?
30+
<CircularProgress color='inherit' size={20} /> :
31+
<LinearProgress color='inherit' sx={{ height: isInstall ? '0.5rem' : '1rem' }} />
32+
}
2733
</Box>
2834
<Typography
2935
variant='caption'
3036
component='div'
3137
color='inherit'
32-
style={{ marginTop: '0.5rem', fontSize: '1.25em' }}
38+
style={{ marginTop: isCircular ? '3px' : '0.5rem', marginLeft: isCircular ? '5px' : '0', fontSize: '1em' }}
3339
>{title}</Typography>
3440
</div>
3541
</div>

src/webview/helm-chart/app/cardItem.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55
import { Autocomplete, Badge, Button, Card, InputLabel, Modal, TextField, ThemeProvider, Typography, darken, lighten, styled } from '@mui/material';
6+
import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
67
import React from 'react';
78
import clsx from 'clsx';
89
import { CardTheme } from '../../common/cardItem.style';
910
import '../app/cardItem.scss';
10-
import { LoadScreen } from '../../common/loading';
1111
import { Chart } from '../helmChartType';
1212
import { VSCodeMessage } from '../vsCodeMessage';
1313
import { DevFileProps } from './wrapperCardItem';
14+
import { LoadScreen } from '../../common/loading';
1415

1516
export class CardItem extends React.Component<DevFileProps, {
1617
displayName: string,
@@ -21,6 +22,7 @@ export class CardItem extends React.Component<DevFileProps, {
2122
loadScreen: boolean,
2223
error: boolean,
2324
errorMsg: string,
25+
installed?: boolean
2426
}
2527
}> {
2628

@@ -98,12 +100,11 @@ export class CardItem extends React.Component<DevFileProps, {
98100
installResponse: {
99101
loadScreen: message.data.show,
100102
error: message.data.isError,
101-
errorMsg: message.data.error || ''
103+
errorMsg: message.data.error || '',
104+
installed: message.data.isInstalled
102105
}
103106
});
104-
if (message.data.isError === false) {
105-
this.onCloseClick(undefined, 'backdropClick');
106-
} else if (message.data.isError) {
107+
if (message.data.isError) {
107108
this.props.helmEntry.isExpand = message.data.chartName === this.state.selectedVersion.name ? true : false;
108109
}
109110
}
@@ -318,28 +319,32 @@ export class CardItem extends React.Component<DevFileProps, {
318319
</Typography>
319320
</div>
320321
</div>
321-
<div style={{ width: '50%' }}>
322-
<Button
323-
disabled={this.handleDisable()}
324-
variant='outlined'
325-
className={this.props.cardItemStyle.helmInstallBtn}
326-
onClick={this.clickInstall}
327-
style={{ float: 'right', backgroundColor: this.handleDisable() ? 'var(--vscode-button-secondaryBackground)' : '#EE0000', textTransform: 'none', color: this.props.themeKind <= 1 ? 'black' : 'white' }}>
328-
<Typography variant='body2'>
329-
Install
330-
</Typography>
331-
</Button>
322+
<div style={{ width: '50%', display: 'flex', flexDirection: 'row' }}>
323+
<div style={{ width: '85%'}}>
324+
{
325+
installResponse.loadScreen && <LoadScreen title='Installation in Progress' type='circle' />
326+
}
327+
</div>
328+
<div style={{float: 'right'}}>
329+
<Button
330+
disabled={this.handleDisable() || installResponse.installed}
331+
variant='outlined'
332+
className={this.props.cardItemStyle.helmInstallBtn}
333+
onClick={this.clickInstall}
334+
style={{ float: 'right', backgroundColor: this.handleDisable() || installResponse.installed ? 'var(--vscode-button-secondaryBackground)' : '#EE0000', textTransform: 'none', color: this.props.themeKind <= 1 ? 'black' : 'white' }}
335+
startIcon={installResponse.installed ? <CheckCircleOutlineIcon /> : undefined}>
336+
<Typography variant='body2'>
337+
{!installResponse.installed ? 'Install' : 'Installed'}
338+
</Typography>
339+
</Button>
340+
</div>
332341
</div>
333342
</div>
334343
</div>
335344
</div>
336345
{
337346
versionCard
338347
}
339-
{
340-
installResponse.loadScreen ?
341-
<LoadScreen title='Installing the Chart' /> : undefined
342-
}
343348
</Card>
344349
</Modal>;
345350

src/webview/helm-chart/helmChartLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export class HelmCommand {
4141
panel.webview.postMessage({
4242
action: 'loadScreen',
4343
show: false,
44-
isError: false
44+
isError: false,
45+
isInstalled: true
4546
});
4647
} catch (e) {
4748
panel.webview.postMessage({

0 commit comments

Comments
 (0)