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

refactor: update LoadingIndicator component #2433

Closed
Closed
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 @@ -159,7 +159,7 @@ export class UnconnectedDetailsPanel extends React.PureComponent<TProps, TState>
)}
{this.state.detailsLoading && (
<div className="Ddg--DetailsPanel--LoadingWrapper">
<LoadingIndicator className="Ddg--DetailsPanel--LoadingIndicator" />
<LoadingIndicator centered={false} className="Ddg--DetailsPanel--LoadingIndicator" small={false} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false values are defaults, why do we need to set them explicitly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False values are indeed default. However, it seems there was a mismatch between the tests snapshot and the actual rendered component.
The snapshots explicitly included the false values even though it could be ignored, so I wrote the components to match them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather update the snapshots

</div>
)}
{this.state.details && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class OperationTableDetails extends React.PureComponent<TProps, TState> {
const { loading, error } = this.props;

if (loading) {
return <LoadingIndicator centered />;
return <LoadingIndicator centered small={false}/>;
}

if (error.opsCalls && error.opsErrors && error.opsLatencies) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class ServiceGraphImpl extends React.PureComponent<TProps> {
yAxisTickFormat,
xDomain,
} = this.props;
let GraphComponent = this.generatePlaceholder(<LoadingIndicator centered />);
let GraphComponent = this.generatePlaceholder(<LoadingIndicator centered small={false} />);
const noDataComponent = this.generatePlaceholder('No Data');
const apiErrorComponent = this.generatePlaceholder('Couldn’t fetch data');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class UnconnectedQualityMetrics extends React.PureComponent<TProps, TStat
</div>
</>
)}
{loading && <LoadingIndicator centered />}
{loading && <LoadingIndicator centered small={false}/>}
{error && <div className="QualityMetrics--Error">{error.message}</div>}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ type LoadingIndicatorProps = {
style?: React.CSSProperties;
};

export default function LoadingIndicator(props: LoadingIndicatorProps) {
const { centered, vcentered, className, small, ...rest } = props;
function LoadingIndicator({ centered, vcentered, className, small, ...rest }: LoadingIndicatorProps){
const cls = `
LoadingIndicator
${centered ? 'is-centered' : ''}
Expand All @@ -37,8 +36,4 @@ export default function LoadingIndicator(props: LoadingIndicatorProps) {
return <LuLoader2 className={cls} {...rest} />;
}

LoadingIndicator.defaultProps = {
centered: false,
className: undefined,
small: false,
};
export default LoadingIndicator