-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update module resolution to bundler (#1387)
* chore: update module resolution to bundler * fix: linter issues * fix jest * fix: build * use import type * lint
- Loading branch information
1 parent
330e4a3
commit 727c616
Showing
25 changed files
with
89 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/extension-base/src/background/handlers/Extension.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/extension-ui/src/Popup/CreateAccount/CreateAccount.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/extension-ui/src/Popup/ImportSeed/ImportSeed.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/extension-ui/src/components/AccountNamePasswordCreation.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,62 @@ | ||
// Copyright 2019-2024 @polkadot/extension-ui authors & contributor | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import type { WithTranslation } from 'react-i18next'; | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import React from 'react'; | ||
import { withTranslation } from 'react-i18next'; | ||
import Header from '../partials/Header'; | ||
import Button from './Button'; | ||
import ButtonArea from './ButtonArea'; | ||
import VerticalSpace from './VerticalSpace'; | ||
|
||
import Header from '../partials/Header.js'; | ||
import Button from './Button.js'; | ||
import ButtonArea from './ButtonArea.js'; | ||
import VerticalSpace from './VerticalSpace.js'; | ||
|
||
interface Props extends WithTranslation { | ||
interface ErrorBoundaryProps { | ||
children: React.ReactNode; | ||
className?: string; | ||
error?: Error | null; | ||
trigger?: string; | ||
} | ||
|
||
interface State { | ||
error: Error | null; | ||
} | ||
|
||
const translate = withTranslation(); | ||
|
||
// NOTE: This is the only way to do an error boundary, via extend | ||
class ErrorBoundary extends React.Component<Props> { | ||
public override state: State = { error: null }; | ||
|
||
public static getDerivedStateFromError (error: Error): Partial<State> { | ||
return { error }; | ||
} | ||
const ErrorBoundary: React.FC<ErrorBoundaryProps> = ({ children, error: propError, trigger }) => { | ||
const { t } = useTranslation(); | ||
const [error, setError] = useState<Error | null>(null); | ||
|
||
public override componentDidUpdate (prevProps: Props) { | ||
const { error } = this.state; | ||
const { trigger } = this.props; | ||
useEffect(() => { | ||
if (error !== null && trigger) { | ||
setError(null); | ||
} | ||
}, [error, trigger]); | ||
|
||
if (error !== null && (prevProps.trigger !== trigger)) { | ||
this.setState({ error: null }); | ||
useEffect(() => { | ||
if (propError) { | ||
setError(propError); | ||
} | ||
} | ||
}, [propError]); | ||
|
||
#goHome = () => { | ||
this.setState({ error: null }); | ||
const goHome = useCallback(() => { | ||
setError(null); | ||
window.location.hash = '/'; | ||
}; | ||
|
||
public override render (): React.ReactNode { | ||
const { children, t } = this.props; | ||
const { error } = this.state; | ||
|
||
return error | ||
? ( | ||
<> | ||
<Header text={t<string, Record<string, string>, string>('An error occurred')} /> | ||
<div> | ||
{t('Something went wrong with the query and rendering of this component. {{message}}', { | ||
replace: { message: error.message } | ||
})} | ||
</div> | ||
<VerticalSpace /> | ||
<ButtonArea> | ||
<Button | ||
onClick={this.#goHome} | ||
> | ||
{t('Back to home')} | ||
</Button> | ||
</ButtonArea> | ||
</> | ||
) | ||
: children; | ||
}, [setError]); | ||
|
||
if (error) { | ||
return ( | ||
<> | ||
<Header text={t('An error occurred')} /> | ||
<div> | ||
{t('Something went wrong with the query and rendering of this component. {{message}}', { | ||
replace: { message: error.message } | ||
})} | ||
</div> | ||
<VerticalSpace /> | ||
<ButtonArea> | ||
<Button onClick={goHome}> | ||
{t('Back to home')} | ||
</Button> | ||
</ButtonArea> | ||
</> | ||
); | ||
} | ||
} | ||
|
||
export default translate(ErrorBoundary); | ||
return <>{children}</>; | ||
}; | ||
|
||
export default ErrorBoundary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.