Skip to content

Commit

Permalink
feat: Plugin Information & InstallModal components
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Sep 23, 2021
1 parent 0ed4f36 commit 6228597
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 8 deletions.
13 changes: 13 additions & 0 deletions src/components/organisms/PluginManagerPane/PluginInformation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import {MonoklePlugin} from '@models/plugin';

function PluginInformation(props: {plugin: MonoklePlugin}) {
const {plugin} = props;
return (
<div>
<p>{plugin.name}</p>
</div>
);
}

export default PluginInformation;
16 changes: 16 additions & 0 deletions src/components/organisms/PluginManagerPane/PluginInstallModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, {useState} from 'react';
import {Input, Modal} from 'antd';

function PluginInstallModal(props: {isVisible: boolean; onClose: () => void}) {
const {isVisible, onClose} = props;
const [pluginUrl, setPluginUrl] = useState<string>();

return (
<Modal visible={isVisible} onCancel={onClose}>
<p>Plugin URL:</p>
<Input value={pluginUrl} onChange={e => setPluginUrl(e.target.value)} />
</Modal>
);
}

export default PluginInstallModal;
52 changes: 44 additions & 8 deletions src/components/organisms/PluginManagerPane/PluginManagerPane.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,55 @@
import React, {useState} from 'react';
import {Input} from 'antd';
import React, {useMemo, useState} from 'react';
import {TitleBar} from '@components/molecules';
import {useAppSelector} from '@redux/hooks';
import {PlusOutlined} from '@ant-design/icons';
import {Button} from 'antd';
import PluginInformation from './PluginInformation';
import PluginInstallModal from './PluginInstallModal';
import * as S from './styled';

function PluginManagerPane() {
const [pluginUrl, setPluginUrl] = useState<string>();
const plugins = useAppSelector(state => state.main.plugins);

const activePlugins = useMemo(() => plugins.filter(p => p.isActive), [plugins]);
const inactivePlugins = useMemo(() => plugins.filter(p => !p.isActive), [plugins]);

const [isInstallModalVisible, setInstallModalVisible] = useState<boolean>(false);
const onClickInstallPlugin = () => {
setInstallModalVisible(true);
};
const onCloseInstallPlugin = () => {
setInstallModalVisible(false);
};

return (
<div>
<TitleBar title="Plugin Manager" />
<PluginInstallModal isVisible={isInstallModalVisible} onClose={onCloseInstallPlugin} />
<TitleBar title="Plugin Manager">
<Button onClick={onClickInstallPlugin} type="link" size="small" icon={<PlusOutlined />} />
</TitleBar>
<S.Container>
<p>Enter plugin URL:</p>
<Input onChange={e => setPluginUrl(e.target.value)} />
<h2>Active plugins</h2>
<h2>Inactive plugins</h2>
{plugins.length === 0 ? (
<p>No plugins installed yet.</p>
) : (
<>
{activePlugins.length > 0 && (
<>
<h2>Active plugins</h2>
{activePlugins.map(activePlugin => (
<PluginInformation plugin={activePlugin} />
))}
</>
)}
{inactivePlugins.length > 0 && (
<>
<h2>Inactive plugins</h2>
{inactivePlugins.map(inactivePlugin => (
<PluginInformation plugin={inactivePlugin} />
))}
</>
)}
</>
)}
</S.Container>
</div>
);
Expand Down

0 comments on commit 6228597

Please sign in to comment.