feat(org): Ported components to mjs and named exports
This commit is contained in:
parent
37f7833983
commit
595417a23b
118 changed files with 836 additions and 852 deletions
|
@ -1,7 +1,7 @@
|
|||
import React from 'react'
|
||||
import ResetButtons from './reset-buttons'
|
||||
import { ResetButtons } from './reset-buttons'
|
||||
import { LogGroup } from 'shared/components/workbench/logs'
|
||||
import DefaultErrorView from './view'
|
||||
import { ErrorView as DefaultErrorView } from './view'
|
||||
|
||||
const ErrorView = (props) => {
|
||||
if (props.children) return props.children
|
||||
|
@ -22,7 +22,7 @@ const ErrorView = (props) => {
|
|||
)
|
||||
}
|
||||
|
||||
class ErrorBoundary extends React.Component {
|
||||
export class ErrorBoundary extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = { hasError: false }
|
||||
|
@ -65,5 +65,3 @@ class ErrorBoundary extends React.Component {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorBoundary
|
|
@ -1,10 +0,0 @@
|
|||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
export default function ({resetGist, undoGist}) {
|
||||
const {t} = useTranslation(['app'])
|
||||
|
||||
return (<div className="flex flex-row gap-4 my-4">
|
||||
<button className="btn btn-primary" onClick={undoGist}>{t('undo')}</button>
|
||||
<button className="btn btn-primary" onClick={resetGist}>{t('reset_all')}</button>
|
||||
</div>
|
||||
)}
|
18
sites/shared/components/error/reset-buttons.mjs
Normal file
18
sites/shared/components/error/reset-buttons.mjs
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { useTranslation } from 'next-i18next'
|
||||
|
||||
// FIXME: I feel this should be kept closer to where it's used
|
||||
|
||||
export const ResetButtons = ({ resetGist, undoGist }) => {
|
||||
const { t } = useTranslation(['app'])
|
||||
|
||||
return (
|
||||
<div className="flex flex-row gap-4 my-4">
|
||||
<button className="btn btn-primary" onClick={undoGist}>
|
||||
{t('undo')}
|
||||
</button>
|
||||
<button className="btn btn-primary" onClick={resetGist}>
|
||||
{t('reset_all')}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
import Robot from 'shared/components/robot/index.js'
|
||||
import Popout from 'shared/components/popout.js'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { useState } from 'react'
|
||||
|
||||
const Error = ({ children, inspectChildren}) => {
|
||||
|
||||
const { t } = useTranslation(['errors'])
|
||||
const [share, setShare] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl m-auto">
|
||||
<Popout warning>
|
||||
<div className="flex flex-row justify-between">
|
||||
<div>
|
||||
<h3>{t('errors:something')}</h3>
|
||||
{children}
|
||||
</div>
|
||||
<Robot pose='fail' />
|
||||
</div>
|
||||
</Popout>
|
||||
<Popout tip>
|
||||
<h3>Would you like to report this problem?</h3>
|
||||
<p>
|
||||
You can help us <strong>make FreeSewing better by reporting this problem</strong>.
|
||||
</p>
|
||||
<p>If you choose to report this:</p>
|
||||
<ul className="list-disc list-inside ml-4 text-xl">
|
||||
<li>
|
||||
We will compile a <strong>crash report</strong> that contains everything needed <strong>to recreate this problem</strong>
|
||||
</li>
|
||||
<li>
|
||||
We will include <strong>personal data</strong> such as your <strong>username</strong>, <strong>
|
||||
email address</strong> and <strong>measurements</strong>
|
||||
</li>
|
||||
<li>
|
||||
We will share this report and the data in it with <a className="text-primary font-bold"
|
||||
href="https://github.com/orgs/freesewing/teams/bughunters">FreeSewing's bughunters team</a> who will investigate the problem on your behalf
|
||||
</li>
|
||||
<li>Your personal data will <strong>not be shared publicly</strong></li>
|
||||
</ul>
|
||||
<div className="form-control">
|
||||
<label className="cursor-pointer flex flex-row gap-4 my-4">
|
||||
<input type="checkbox" checked={share} className="checkbox checkbox-primary" onChange={() => setShare(!share)}/>
|
||||
<span className="label-text text-xl">I agree to the use of my personal data for the purposes outlined above</span>
|
||||
</label>
|
||||
</div>
|
||||
<p>
|
||||
<button disabled={!share} className="btn btn-primary">Report this</button>
|
||||
</p>
|
||||
<p>
|
||||
If you prefer not to share any info, or want to investigate the problem yourself, you can do so:
|
||||
</p>
|
||||
{inspectChildren}
|
||||
</Popout>
|
||||
</div>)
|
||||
}
|
||||
|
||||
export default Error
|
76
sites/shared/components/error/view.mjs
Normal file
76
sites/shared/components/error/view.mjs
Normal file
|
@ -0,0 +1,76 @@
|
|||
import { useTranslation } from 'next-i18next'
|
||||
import { useState } from 'react'
|
||||
import { Robot } from 'shared/components/robot/index.mjs'
|
||||
import { Popout } from 'shared/components/popout.mjs'
|
||||
|
||||
export const ErrorView = ({ children, inspectChildren }) => {
|
||||
const { t } = useTranslation(['errors'])
|
||||
const [share, setShare] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl m-auto">
|
||||
<Popout warning>
|
||||
<div className="flex flex-row justify-between">
|
||||
<div>
|
||||
<h3>{t('errors:something')}</h3>
|
||||
{children}
|
||||
</div>
|
||||
<Robot pose="fail" />
|
||||
</div>
|
||||
</Popout>
|
||||
<Popout tip>
|
||||
<h3>Would you like to report this problem?</h3>
|
||||
<p>
|
||||
You can help us <strong>make FreeSewing better by reporting this problem</strong>.
|
||||
</p>
|
||||
<p>If you choose to report this:</p>
|
||||
<ul className="list-disc list-inside ml-4 text-xl">
|
||||
<li>
|
||||
We will compile a <strong>crash report</strong> that contains everything needed{' '}
|
||||
<strong>to recreate this problem</strong>
|
||||
</li>
|
||||
<li>
|
||||
We will include <strong>personal data</strong> such as your <strong>username</strong>,{' '}
|
||||
<strong>email address</strong> and <strong>measurements</strong>
|
||||
</li>
|
||||
<li>
|
||||
We will share this report and the data in it with{' '}
|
||||
<a
|
||||
className="text-primary font-bold"
|
||||
href="https://github.com/orgs/freesewing/teams/bughunters"
|
||||
>
|
||||
FreeSewing's bughunters team
|
||||
</a>{' '}
|
||||
who will investigate the problem on your behalf
|
||||
</li>
|
||||
<li>
|
||||
Your personal data will <strong>not be shared publicly</strong>
|
||||
</li>
|
||||
</ul>
|
||||
<div className="form-control">
|
||||
<label className="cursor-pointer flex flex-row gap-4 my-4">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={share}
|
||||
className="checkbox checkbox-primary"
|
||||
onChange={() => setShare(!share)}
|
||||
/>
|
||||
<span className="label-text text-xl">
|
||||
I agree to the use of my personal data for the purposes outlined above
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<p>
|
||||
<button disabled={!share} className="btn btn-primary">
|
||||
Report this
|
||||
</button>
|
||||
</p>
|
||||
<p>
|
||||
If you prefer not to share any info, or want to investigate the problem yourself, you can
|
||||
do so:
|
||||
</p>
|
||||
{inspectChildren}
|
||||
</Popout>
|
||||
</div>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue