Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
Signed-off-by: Qiaozp <[email protected]>
  • Loading branch information
chivalryq committed May 4, 2023
1 parent a7a2823 commit 0b55620
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 73 deletions.
2 changes: 1 addition & 1 deletion packages/velaux-data/src/api/addon.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ApplicationStatus, UIParam } from './application';
import type { NameAlias } from './env';
import { KeyValue } from "@velaux/data";
import { KeyValue } from "../types";

export interface Addon {
name: string;
Expand Down
124 changes: 61 additions & 63 deletions packages/velaux-ui/src/layout/AppRootPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ enum types {
}

function ConfigPage({ pluginId, dispatch, pluginList, loading }: Props) {

const [valid, setValid] = React.useState(false)
const [app, setApp] = React.useState<AppPagePlugin>();
const _meta = pluginList.filter(item => item.id === pluginId)[0]
Expand All @@ -58,18 +57,15 @@ function ConfigPage({ pluginId, dispatch, pluginList, loading }: Props) {
newJsonData[key] = value
meta.jsonSetting = newJsonData
setApp({ ...app, meta: meta } as AppPagePlugin)
console.log('handleJSONChange', meta)
}
const handleSecureJSONChange = (key: string, value: any) => {
const newSecureJsonData = { ...meta.secureJsonData }
newSecureJsonData[key] = value
meta.secureJsonData = newSecureJsonData
setApp({ ...app, meta: meta } as AppPagePlugin)
console.log('handleSecureJSONChange', meta)
}

const saveSetting = () => {
console.log('saveSetting', meta.jsonSetting, meta.secureJsonData)
dispatch({
type: 'plugins/setPlugin',
payload: {
Expand Down Expand Up @@ -168,78 +164,81 @@ function ConfigPage({ pluginId, dispatch, pluginList, loading }: Props) {
const AppConfigPage = app.configPages.body

return (
<>
<Box>
<Loading visible={loading.models.plugins ?? false} fullScreen={true} />
<Box className={'page-header'} direction={'row'} spacing={12}>
<Box className={'container'}>
<Box className={'page-header'} direction={'row'} spacing={12}>
<span className={'page-header-logo'}>
{renderIcon(meta.id, valid, meta.info?.logos.large)}
</span>
<Box direction={'column'}>
<h1 className={'page-header-title'}>{
<>
<a onClick={handleGotoPlugins}>Plugins</a> / {meta.name}
</>
}</h1>
<Row className={'basic-info font-size-16'}>
<Col>
<div className={'info-item-title'}>Version</div>
<div>{meta.info.version}</div>
</Col>
<Col>
<Divider direction="ver" style={{ height: '100%' }} />
</Col>
<Col>
<Box direction={'column'}>
<div className={'info-item-title'}>Author</div>
<div>{meta.info.author?.name ?? "Unknown"}</div>
</Box>
</Col>
<Col>
<Divider direction="ver" style={{ height: '100%' }} />
</Col>
<Col className={'info-item'}>
<div className={'info-item-title'}>Status</div>
<div>{
meta.enabled ? <Translation className={''}>Enabled</Translation> : <Translation>Disabled</Translation>
}</div>
</Col>
</Row>
<h4 className={'font-size-14'}>{meta.info.description ?? "No descriptions"}</h4>
</Box>
<Box style={{ marginLeft: 'auto' }} align={'flex-end'} direction={'row'} justify={'flex-end'}>
<Row gutter={8}>
{isInstalled && !isEnabled &&
<Box direction={'column'}>
<h1 className={'page-header-title'}>{
<>
<a onClick={handleGotoPlugins}>Plugins</a> / {meta.name}
</>
}</h1>

<h4 className={'font-size-14'}>{meta.info.description ?? "No descriptions"}</h4>
</Box>
<Box style={{ marginLeft: 'auto' }} align={'flex-end'} direction={'row'} justify={'flex-end'}>
<Box justify={"space-between"} style={{ height: '100%' }}>
<Row className={'basic-info font-size-16'} justify={'end'}>
<Col>
<Button type={'primary'} onClick={() => enablePlugin(pluginId)}>Enable</Button>
<div className={'info-item-title'}>Version</div>
<div>{meta.info.version}</div>
</Col>
}
{isEnabled &&
<Col>
<Button type={'primary'} onClick={saveSetting}>Save & Reload</Button>
<Divider direction="ver" style={{ height: '100%' }} />
</Col>
}
{
isEnabled &&
<Col>
<Button warning={true} onClick={() => disablePlugin(pluginId)}>Disable</Button>
<Box direction={'column'}>
<div className={'info-item-title'}>Author</div>
<div>{meta.info.author?.name ?? "Unknown"}</div>
</Box>
</Col>
}
{
!isEnabled && isInstalled &&
<Col>
<Button warning={true} onClick={() => uninstallPlugin(pluginId)}>Uninstall</Button>
<Divider direction="ver" style={{ height: '100%' }} />
</Col>
}
</Row>
<Col className={'info-item'}>
<div className={'info-item-title'}>Status</div>
<div>{
meta.enabled ? <Translation className={''}>Enabled</Translation> :
<Translation>Disabled</Translation>
}</div>
</Col>
</Row>
<Box direction={'row'} justify={"flex-end"} spacing={8}>
{isInstalled && !isEnabled &&
<Button type={'primary'} onClick={() => enablePlugin(pluginId)}>Enable</Button>
}
{isEnabled &&
<Button type={'primary'} onClick={saveSetting}>Save</Button>
}
{
isEnabled &&
<Button warning={true} onClick={() => disablePlugin(pluginId)}>Disable</Button>
}
{
!isEnabled && isInstalled &&
<Button warning={true} onClick={() => uninstallPlugin(pluginId)}>Uninstall</Button>
}
</Box>
</Box>
</Box>
</Box>
</Box>
<Tab>
<Tab.Item title={'Config'}>
<AppConfigPage plugin={app} query={{}} onJSONDataChange={handleJSONChange}
onSecureJSONDataChange={handleSecureJSONChange} />
</Tab.Item>
</Tab>
</>
<Box className={'container'}>
<Tab>
<Tab.Item title={'Config'}>
<Box style={{ backgroundColor: '#FFF',padding: '0 10px'}}>
<AppConfigPage plugin={app} query={{}} onJSONDataChange={handleJSONChange}
onSecureJSONDataChange={handleSecureJSONChange} />
</Box>
</Tab.Item>
</Tab>
</Box>

</Box>
)
}

Expand All @@ -252,7 +251,6 @@ async function loadAppPlugin(
if (app && 'type' in app) {
return importAppPagePlugin(app)
.then((pageApp) => {
console.log('pageApp', pageApp)
setApp(pageApp);
})
.catch((err) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/velaux-ui/src/services/MenuService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const defaultWorkspaceMenus: Menu[] = [
type: MenuTypes.Workspace,
to: '/addons',
icon: <BsPlugin></BsPlugin>,
label: 'Addons & Plugins',
label: 'Addons',
name: 'addon-list',
permission: { resource: 'addon:*', action: 'list' },
relatedRoute: ['/addons', '/plugins'],
Expand Down
14 changes: 6 additions & 8 deletions plugins/node-dashboard/src/components/AppConfig/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as React from 'react';
import { Button } from '@velaux/ui';
import { PluginConfigPageProps, AppPluginMeta, PluginMeta } from '@velaux/data';
import { enablePlugin } from "@velaux/ui";
import { PluginEnableRequest } from "@velaux/data";
import { Button ,enablePlugin } from '@velaux/ui';
import { PluginConfigPageProps, AppPluginMeta, PluginMeta ,PluginEnableRequest } from '@velaux/data';

export type AppPluginSettings = {};

export interface AppConfigProps extends PluginConfigPageProps<AppPluginMeta<AppPluginSettings>> {}

export const AppConfig = ({ plugin }: AppConfigProps) => {
const { enabled, jsonData } = plugin.meta;
const { enabled, jsonSetting } = plugin.meta;

return (
<div className="gf-form-group">
Expand All @@ -24,7 +22,7 @@ export const AppConfig = ({ plugin }: AppConfigProps) => {
onClick={() =>
updatePluginAndReload(plugin.meta.id, {
enabled: true,
jsonData,
jsonSetting
})
}
>
Expand All @@ -42,7 +40,7 @@ export const AppConfig = ({ plugin }: AppConfigProps) => {
onClick={() =>
updatePluginAndReload(plugin.meta.id, {
enabled: false,
jsonData,
jsonSetting
})
}
>
Expand All @@ -59,7 +57,7 @@ const updatePluginAndReload = async (pluginId: string, data: Partial<PluginMeta>
try {
const params: PluginEnableRequest = {
id: pluginId,
jsonData: data.jsonData? data.jsonData : {},
jsonData: data.jsonSetting? data.jsonSetting : {},
secureJsonData: data.secureJsonData? data.secureJsonData : {},
}
await enablePlugin(params).then((res) => {
Expand Down

0 comments on commit 0b55620

Please sign in to comment.