mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
alerts: use shorthand return
This commit is contained in:
committed by
David Lechner
parent
95199e44c1
commit
9fe62467d5
@@ -76,11 +76,12 @@ const UnexpectedErrorAlert: React.VoidFunctionComponent<UnexpectedErrorAlertProp
|
||||
);
|
||||
};
|
||||
|
||||
export const unexpectedError: CreateToast<{ error: Error }> = (onAction, { error }) => {
|
||||
return {
|
||||
message: <UnexpectedErrorAlert error={error} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const unexpectedError: CreateToast<{ error: Error }> = (
|
||||
onAction,
|
||||
{ error },
|
||||
) => ({
|
||||
message: <UnexpectedErrorAlert error={error} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -11,11 +11,9 @@ const UpdateServerFailure: React.VoidFunctionComponent = () => {
|
||||
return <p>{i18n.translate('updateServerFailure.message')}</p>;
|
||||
};
|
||||
|
||||
export const updateServerFailure: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <UpdateServerFailure />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const updateServerFailure: CreateToast = (onAction) => ({
|
||||
message: <UpdateServerFailure />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -17,11 +17,9 @@ const BluetoothNotAvailable: React.VoidFunctionComponent = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const bluetoothNotAvailable: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <BluetoothNotAvailable />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const bluetoothNotAvailable: CreateToast = (onAction) => ({
|
||||
message: <BluetoothNotAvailable />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -25,11 +25,9 @@ const MissingService: React.VoidFunctionComponent<MissingServiceProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
export const missingService: CreateToast<MissingServiceProps> = (onAction, props) => {
|
||||
return {
|
||||
message: <MissingService {...props} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const missingService: CreateToast<MissingServiceProps> = (onAction, props) => ({
|
||||
message: <MissingService {...props} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -11,11 +11,9 @@ const NoGatt: React.VoidFunctionComponent = () => {
|
||||
return <p>{i18n.translate('noGatt.message')}</p>;
|
||||
};
|
||||
|
||||
export const noGatt: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <NoGatt />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const noGatt: CreateToast = (onAction) => ({
|
||||
message: <NoGatt />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -45,12 +45,10 @@ const NoHub: React.VoidFunctionComponent<NoHubProps> = ({ onFlashFirmware }) =>
|
||||
);
|
||||
};
|
||||
|
||||
export const noHub: CreateToast<never, 'dismiss' | 'flashFirmware'> = (onAction) => {
|
||||
return {
|
||||
message: <NoHub onFlashFirmware={() => onAction('flashFirmware')} />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
timeout: 15000,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const noHub: CreateToast<never, 'dismiss' | 'flashFirmware'> = (onAction) => ({
|
||||
message: <NoHub onFlashFirmware={() => onAction('flashFirmware')} />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
timeout: 15000,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -39,11 +39,9 @@ const NoWebBluetooth: React.VoidFunctionComponent = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const noWebBluetooth: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <NoWebBluetooth />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const noWebBluetooth: CreateToast = (onAction) => ({
|
||||
message: <NoWebBluetooth />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -30,11 +30,9 @@ const OldFirmware: React.VoidFunctionComponent<OldFirmwareProps> = ({
|
||||
|
||||
export const oldFirmware: CreateToast<never, 'dismiss' | 'flashFirmware'> = (
|
||||
onAction,
|
||||
) => {
|
||||
return {
|
||||
message: <OldFirmware onFlashFirmware={() => onAction('flashFirmware')} />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
) => ({
|
||||
message: <OldFirmware onFlashFirmware={() => onAction('flashFirmware')} />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -20,11 +20,9 @@ const FileInUseAlert: React.VoidFunctionComponent<FileInUseAlertProps> = ({
|
||||
export const fileInUse: CreateToast<{ fileName: string }> = (
|
||||
onAction,
|
||||
{ fileName },
|
||||
) => {
|
||||
return {
|
||||
message: <FileInUseAlert fileName={fileName} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
) => ({
|
||||
message: <FileInUseAlert fileName={fileName} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -17,11 +17,9 @@ const NoFilesToBackup: React.VoidFunctionComponent = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const noFilesToBackup: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <NoFilesToBackup />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const noFilesToBackup: CreateToast = (onAction) => ({
|
||||
message: <NoFilesToBackup />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -23,11 +23,9 @@ const DfuError: React.VoidFunctionComponent<DfuErrorProps> = ({ onTryAgain }) =>
|
||||
);
|
||||
};
|
||||
|
||||
export const dfuError: CreateToast<never, 'dismiss' | 'tryAgain'> = (onAction) => {
|
||||
return {
|
||||
message: <DfuError onTryAgain={() => onAction('tryAgain')} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const dfuError: CreateToast<never, 'dismiss' | 'tryAgain'> = (onAction) => ({
|
||||
message: <DfuError onTryAgain={() => onAction('tryAgain')} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -40,13 +40,11 @@ const FlashProgress: React.VoidFunctionComponent<FlashProgressProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
export const flashProgress: CreateToast<FlashProgressProps> = (onAction, props) => {
|
||||
return {
|
||||
message: <FlashProgress {...props} />,
|
||||
icon: 'download',
|
||||
intent: Intent.PRIMARY,
|
||||
// close one second after progress is complete
|
||||
timeout: (props.progress ?? 0) < 1 ? 0 : 1000,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const flashProgress: CreateToast<FlashProgressProps> = (onAction, props) => ({
|
||||
message: <FlashProgress {...props} />,
|
||||
icon: 'download',
|
||||
intent: Intent.PRIMARY,
|
||||
// close one second after progress is complete
|
||||
timeout: (props.progress ?? 0) < 1 ? 0 : 1000,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -33,11 +33,9 @@ const NoDfuHub: React.VoidFunctionComponent = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const noDfuHub: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <NoDfuHub />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const noDfuHub: CreateToast = (onAction) => ({
|
||||
message: <NoDfuHub />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -11,11 +11,9 @@ const NoDfuInterface: React.VoidFunctionComponent = () => {
|
||||
return <p>{i18n.translate('noDfuInterface.message')}</p>;
|
||||
};
|
||||
|
||||
export const noDfuInterface: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <NoDfuInterface />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const noDfuInterface: CreateToast = (onAction) => ({
|
||||
message: <NoDfuInterface />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -16,11 +16,9 @@ const NoWebUsb: React.VoidFunctionComponent = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const noWebUsb: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <NoWebUsb />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const noWebUsb: CreateToast = (onAction) => ({
|
||||
message: <NoWebUsb />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -11,11 +11,9 @@ const ReleaseButton: React.VoidFunctionComponent = () => {
|
||||
return <p>{i18n.translate('releaseButton.message')}</p>;
|
||||
};
|
||||
|
||||
export const releaseButton: CreateToast = (onAction) => {
|
||||
return {
|
||||
message: <ReleaseButton />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
export const releaseButton: CreateToast = (onAction) => ({
|
||||
message: <ReleaseButton />,
|
||||
icon: 'info-sign',
|
||||
intent: Intent.PRIMARY,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
@@ -47,12 +47,10 @@ const CompilerError: React.VoidFunctionComponent<CompilerErrorProps> = ({ error
|
||||
export const compilerError: CreateToast<CompilerErrorProps, 'dismiss' | 'gotoError'> = (
|
||||
onAction,
|
||||
props,
|
||||
) => {
|
||||
return {
|
||||
message: <CompilerError {...props} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
timeout: 0,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
};
|
||||
};
|
||||
) => ({
|
||||
message: <CompilerError {...props} />,
|
||||
icon: 'error',
|
||||
intent: Intent.DANGER,
|
||||
timeout: 0,
|
||||
onDismiss: () => onAction('dismiss'),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user