2023-04-13 09:07:43 -05:00
|
|
|
import React from 'react';
|
|
|
|
import { connect, ConnectedProps } from 'react-redux';
|
|
|
|
|
|
|
|
import { Alert } from '@grafana/ui';
|
|
|
|
import { StoreState } from 'app/types';
|
|
|
|
|
|
|
|
import { resetError, resetWarning } from './state/reducers';
|
|
|
|
|
|
|
|
function mapStateToProps(state: StoreState) {
|
|
|
|
return {
|
|
|
|
error: state.authConfig.updateError,
|
|
|
|
warning: state.authConfig.warning,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
|
resetError,
|
|
|
|
resetWarning,
|
|
|
|
};
|
|
|
|
|
|
|
|
const connector = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
export type Props = ConnectedProps<typeof connector>;
|
|
|
|
|
|
|
|
export const ErrorContainerUnconnected = ({ error, warning, resetError, resetWarning }: Props): JSX.Element => {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
{error && (
|
|
|
|
<Alert title={error.message} onRemove={() => resetError()}>
|
2023-07-17 09:58:22 -05:00
|
|
|
{error.errors?.map((e, i) => <div key={i}>{e}</div>)}
|
2023-04-13 09:07:43 -05:00
|
|
|
</Alert>
|
|
|
|
)}
|
|
|
|
{warning && (
|
|
|
|
<Alert title={warning.message} onRemove={() => resetWarning()} severity="warning">
|
2023-07-17 09:58:22 -05:00
|
|
|
{warning.errors?.map((e, i) => <div key={i}>{e}</div>)}
|
2023-04-13 09:07:43 -05:00
|
|
|
</Alert>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connector(ErrorContainerUnconnected);
|