Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu Install Plugin button fix #131

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function Menu(props: {
props.setOpen(false);
}}
>
<PluginUploadInfo />
<PluginUploadInfo onPluginInstalled={() => props.setOpen(false)} />
<span>Install Plugin</span>
</MenuRow>
<MenuRow
Expand Down
10 changes: 9 additions & 1 deletion src/components/PluginInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@
import classNames from 'classnames';
import DefaultPluginIcon from '../../assets/img/default-plugin-icon.png';

export default function PluginUploadInfo(): ReactElement {
export default function PluginUploadInfo({
onPluginInstalled,
}: {
onPluginInstalled?: () => void;
}): ReactElement {
const [error, showError] = useState('');
const [pluginBuffer, setPluginBuffer] = useState<ArrayBuffer | any>(null);

Check warning on line 35 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const [pluginContent, setPluginContent] = useState<PluginConfig | null>(null);

const onAddPlugin = useCallback(
async (evt: React.MouseEvent<HTMLButtonElement>) => {

Check warning on line 39 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

'evt' is defined but never used
try {
await addPlugin(Buffer.from(pluginBuffer).toString('hex'));
setPluginContent(null);
onPluginInstalled?.();
} catch (e: any) {

Check warning on line 44 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
showError(e?.message || 'Invalid Plugin');
}
},
Expand All @@ -52,7 +57,7 @@
const plugin = await makePlugin(arrayBuffer);
setPluginContent(await getPluginConfig(plugin));
setPluginBuffer(arrayBuffer);
} catch (e: any) {

Check warning on line 60 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
showError(e?.message || 'Invalid Plugin');
} finally {
evt.target.value = '';
Expand All @@ -72,6 +77,9 @@
className="opacity-0 absolute top-0 right-0 h-full w-full cursor-pointer"
type="file"
onChange={onPluginInfo}
onClick={(e) => {
e.stopPropagation();
}}
/>
{error && <ErrorModal onClose={() => showError('')} message={error} />}
{pluginContent && (
Expand Down Expand Up @@ -108,11 +116,11 @@
const { pluginContent, onClose, onAddPlugin, children } = props;

const header = Children.toArray(children).filter(
(c: any) => c.type.name === 'PluginInfoModalHeader',

Check warning on line 119 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
)[0];

const content = Children.toArray(children).filter(
(c: any) => c.type.name === 'PluginInfoModalContent',

Check warning on line 123 in src/components/PluginInfo/index.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
)[0];

return (
Expand Down
Loading