Skip to content
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
1 change: 1 addition & 0 deletions src/components/GlobalHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class GlobalHeader extends PureComponent {
"/config/dict",
"/config/namespace",
"/config/pluginhandle",
"/config/plugin",
"/system/resource",
"/system/role",
"/system/manage",
Expand Down
5 changes: 1 addition & 4 deletions src/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ body,
.optionParts {
display: flex;
justify-content: center;

div:first-child {
margin-right: 16px;
}
gap: 16px;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"SHENYU.BUTTON.SYSTEM.ENABLE": "Enable",
"SHENYU.BUTTON.SYSTEM.EDITRESOURCEDETAILS": "EditDetails",
"SHENYU.BUTTON.SYSTEM.RESOURCE": "Resource",
"SHENYU.BUTTON.SYSTEM.GENERATE": "Generate",
"SHENYU.BUTTON.DATA.PERMISSION.CONFIG": "ConfigureDataPermission",
"SHENYU.MESSAGE.SESSION.INVALID": "Session is invalid",
"SHENYU.MESSAGE.SESSION.RELOGIN": "Please login in again",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"SHENYU.BUTTON.SYSTEM.ENABLE": "启用",
"SHENYU.BUTTON.SYSTEM.EDITRESOURCEDETAILS": "编辑详情",
"SHENYU.BUTTON.SYSTEM.RESOURCE": "资源",
"SHENYU.BUTTON.SYSTEM.GENERATE": "生成",
"SHENYU.BUTTON.DATA.PERMISSION.CONFIG": "配置数据权限",
"SHENYU.MESSAGE.SESSION.INVALID": "会话超时",
"SHENYU.MESSAGE.SESSION.RELOGIN": "会话超时,请重新登录",
Expand Down
12 changes: 12 additions & 0 deletions src/models/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
updatePlugin,
deletePlugin,
addPlugin,
generatePlugin,
updatepluginEnabled,
fetchPluginHandleByPluginId,
addPluginResource,
Expand Down Expand Up @@ -74,6 +75,17 @@ export default {
message.warn(json.message);
}
},
*generate(params, { call, put }) {
const { payload, callback, fetchValue } = params;
const json = yield call(generatePlugin, payload);
if (json.code === 200) {
message.success(getIntlContent("SHENYU.COMMON.RESPONSE.ADD.SUCCESS"));
callback?.();
yield put({ type: "reload", fetchValue });
} else {
message.warn(json.message);
}
},
*changeStatus({ payload }, { call, put }) {
const json = yield call(updatePlugin, payload);
if (json.code === 200) {
Expand Down
41 changes: 40 additions & 1 deletion src/routes/System/Plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
Tag,
Typography,
Switch,
Dropdown,
Menu,
} from "antd";
import { connect } from "dva";
import { Link } from "dva/router";
Expand All @@ -46,6 +48,7 @@ const { Option } = Select;
authMenu: resource.authMenu,
language: global.language,
loading: loading.effects["plugin/fetch"],
namespaces: global.namespaces,
}))
export default class Plugin extends Component {
components = resizableComponents;
Expand Down Expand Up @@ -151,6 +154,35 @@ export default class Plugin extends Component {
});
};

getNamespaceMenus = (record) => {
const { namespaces } = this.props;
return (
<Menu>
{namespaces.map((namespace) => (
<Menu.Item key={namespace.id}>
<a onClick={() => this.generateClick(record, namespace)}>
{namespace.name}
</a>
</Menu.Item>
))}
</Menu>
);
};

generateClick = (record, namespace) => {
const { dispatch } = this.props;
dispatch({
type: "plugin/generate",
payload: {
pluginId: record.id,
namespaceId: namespace.namespaceId,
},
fetchValue: this.currentQueryPayload({
pageSize: 12,
}),
});
};

resourceClick = (record) => {
// code here...
const { dispatch } = this.props;
Expand Down Expand Up @@ -418,7 +450,7 @@ export default class Plugin extends Component {
dataIndex: "time",
key: "time",
ellipsis: true,
width: 160,
width: 200,
fixed: "right",
render: (text, record) => {
return (
Expand All @@ -443,6 +475,13 @@ export default class Plugin extends Component {
{getIntlContent("SHENYU.BUTTON.SYSTEM.RESOURCE")}
</div>
</AuthButton>
<AuthButton perms="system:plugin:add">
<Dropdown overlay={this.getNamespaceMenus(record)}>
<div className="edit">
{getIntlContent("SHENYU.BUTTON.SYSTEM.GENERATE")}
</div>
</Dropdown>
</AuthButton>
</div>
);
},
Expand Down
7 changes: 7 additions & 0 deletions src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ export async function addPlugin(params) {
});
}

/* generatePlugin */
export async function generatePlugin({ pluginId, namespaceId }) {
return request(`${baseUrl}/namespacePlugin/${namespaceId}/${pluginId}`, {
method: `PUT`,
});
}

function readFileAsBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
Expand Down
Loading