mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
Instead of rendering the toaster separate from the main index, add it there so we can inherit all of the context providers. This requires passing the ref object instead of the toaster instance itself, so sagas have to be updated.
36 lines
987 B
TypeScript
36 lines
987 B
TypeScript
// SPDX-License-Identifier: MIT
|
|
// Copyright (c) 2022 The Pybricks Authors
|
|
|
|
import { Intent } from '@blueprintjs/core';
|
|
import React from 'react';
|
|
import type { CreateToast } from '../../toasterTypes';
|
|
import { useI18n } from './i18n';
|
|
|
|
type MissingServiceProps = {
|
|
serviceName: string;
|
|
hubName: string;
|
|
};
|
|
|
|
const MissingService: React.VoidFunctionComponent<MissingServiceProps> = ({
|
|
serviceName,
|
|
hubName,
|
|
}) => {
|
|
const i18n = useI18n();
|
|
return (
|
|
<>
|
|
<p>{i18n.translate('missingService.message', { serviceName })}</p>
|
|
<p>{i18n.translate('missingService.suggestion1')}</p>
|
|
<p>{i18n.translate('missingService.suggestion2', { hubName })}</p>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export const missingService: CreateToast<MissingServiceProps> = (onAction, props) => {
|
|
return {
|
|
message: <MissingService {...props} />,
|
|
icon: 'error',
|
|
intent: Intent.DANGER,
|
|
onDismiss: () => onAction('dismiss'),
|
|
};
|
|
};
|