Unverified Commit 54cc7812 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor] Refactor Create root Folder (#2207)

* Refactor Create root Folder
parent 6e737036
......@@ -98,7 +98,7 @@ public class CatalogueController {
* @param catalogue
* @return Result<Void>
*/
@PutMapping
@PutMapping("saveOrUpdateCatalogue")
@Log(title = "Insert Or Update Catalogue", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Insert Or Update Catalogue")
public Result<Void> saveOrUpdateCatalogue(@RequestBody Catalogue catalogue) {
......
......@@ -88,7 +88,6 @@ export default {
'right.menu.paste': 'Paste',
'right.menu.delete': 'Delete',
'right.menu.createCatalogue': 'Create Directory',
'right.menu.createRootCatalogue': 'Create Root Directory',
'right.menu.uploadZipToCreate': 'Upload Zip To Create',
'right.menu.createTask': 'Create Task',
'right.menu.closeAll': 'Close All',
......
......@@ -1024,4 +1024,9 @@ export default {
'datastudio.middle.qg.gitprojects': 'Git Projects',
'datastudio.middle.qg.udf': 'UDF',
'datastudio.middle.qg.resource': 'Resource',
// project
'datastudio.project.create.rootFolder': 'Create Root Folder',
'datastudio.project.create.folder.name': 'Folder Name',
'datastudio.project.create.folder.name.placeholder': 'Please enter the folder name',
};
......@@ -79,7 +79,6 @@ export default {
'right.menu.open': '打开',
'right.menu.submit': '异步提交',
'right.menu.addSub': '添加子项',
'right.menu.addRoot': '添加根菜单',
'right.menu.exportJson': '导出 JSON',
'right.menu.importJson': '导入 JSON',
'right.menu.rename': '重命名',
......
......@@ -1036,5 +1036,10 @@ export default {
'datastudio.middle.qg.gitprojects': 'Git 项目',
'datastudio.middle.qg.udf': 'UDF',
'datastudio.middle.qg.resource': '资源',
// project
'datastudio.project.create.rootFolder': '创建根目录',
'datastudio.project.create.folder.name': '目录名称',
'datastudio.project.create.folder.name.placeholder': '请输入目录名称',
};
......@@ -119,14 +119,15 @@ const MenuForm: React.FC<MenuFormProps> = (props) => {
return (
<>
<ProFormTreeSelect
initialValue={selectedKeys}
shouldUpdate
name={'parentId'}
label={l('menu.parentId')}
rules={[{ required: true, message: l('menu.parentIdPlaceholder') }]}
placeholder={l('menu.parentIdPlaceholder')}
fieldProps={{
labelInValue: false,
treeData: [{ label: '根菜单', value: '-1' }].concat(
labelInValue: false,
treeData: [{ label: <>Root <span style={{color: 'grey'}}>&nbsp;&nbsp;&nbsp;Root Folder</span></>, value: '-1' }].concat(
buildMenuFormTree(treeData, searchValue, true),
),
onSearch: (value) => setSearchValue(value),
......
......@@ -17,7 +17,7 @@
*
*/
import {DeleteTwoTone, PlusCircleTwoTone} from '@ant-design/icons';
import Icon, {DeleteTwoTone, PlusCircleTwoTone} from '@ant-design/icons';
import {l} from "@/utils/intl";
import React from "react";
import {BackIcon} from "@/components/Icons/CustomIcons";
......@@ -26,14 +26,10 @@ import {DefaultOptionType} from "antd/es/select";
import {Space} from "antd";
import {TagAlignLeft} from "@/components/StyledComponents";
import * as Icons from '@ant-design/icons';
import {IconRender} from "@/pages/AuthCenter/Menu/function";
const IconRender = ({icon}:{icon: string}) => {
// @ts-ignore
const IconComponent = Icons[icon];
return <IconComponent style={{marginRight: 8}}/>;
}
/**
* menu icon options
......
......@@ -88,8 +88,8 @@ const MenuList: React.FC = () => {
const handleAddOrUpdateSubmit = async (value: Partial<SysMenu>) => {
await executeAndCallbackRefresh(async () => {
await handleAddOrUpdate('/api/menu/addOrUpdate', {...value});
handleModalVisible(false);
});
handleModalVisible(false);
};
......@@ -245,7 +245,6 @@ const MenuList: React.FC = () => {
</>
}
console.log(treeData,buildMenuFormTree(treeData,'',true))
/**
* render
*/
......@@ -272,7 +271,7 @@ console.log(treeData,buildMenuFormTree(treeData,'',true))
<RightContextMenu
contextMenuPosition={contextMenuPosition} open={contextMenuVisible}
openChange={() => setContextMenuVisible(false)} items={RIGHT_CONTEXT_MENU(rightClickedNode?.isLeaf)}
openChange={() => setContextMenuVisible(false)} items={RIGHT_CONTEXT_MENU(rightClickedNode?.type === 'F')}
onClick={handleMenuClick}
/>
</>
......
......@@ -18,20 +18,15 @@
*/
import {SysMenu} from "@/types/RegCenter/data";
import {searchTreeNode} from "@/utils/function";
import {renderIcon, searchTreeNode} from "@/utils/function";
import * as Icons from '@ant-design/icons';
import * as React from "react";
import {Space} from "antd";
import {l} from "@/utils/intl";
/**
* render icon
* @param {string} iconName
* @returns {JSX.Element}
*/
const renderIcon = (iconName: string) => {
export const IconRender = ({icon}:{icon: string}) => {
// @ts-ignore
return iconName ? React.createElement(Icons[iconName]) : null;
return icon ? React.createElement(Icons[icon]) : null;
}
const renderMenuType = (menuYype: string) => {
......@@ -69,10 +64,11 @@ export const buildMenuTree = (data: SysMenu[], searchValue: string = ''): any =>
name: item.name,
parentId: item.parentId,
label: searchTreeNode(item.name, searchValue),
icon: renderIcon(item.icon),//
icon: <IconRender icon={item.icon}/>,
content: item.note,
path: item.path,
value: item.id,
type: item.type,
title: <>{searchTreeNode(item.name, searchValue)}{renderTitle(item)}</>,
fullInfo: item,
key: item.id,
......@@ -96,7 +92,7 @@ export const buildMenuFormTree = (data: SysMenu[], searchValue: string = '', fil
name: item.name,
parentId: item.parentId,
label: searchTreeNode(item.name, searchValue),
icon: renderIcon(item.icon),//
icon: <IconRender icon={item.icon}/>,
content: item.note,
path: item.path,
value: item.id,
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React from "react";
import {ProForm, ProFormText} from "@ant-design/pro-components";
import {l} from "@/utils/intl";
const JobForm = () => {
return <>
<ProFormText
name="name"
width={'md'}
label={l('datastudio.project.create.folder.name')}
placeholder={l('datastudio.project.create.folder.name.placeholder')}
rules={[ {required: true, message: l('datastudio.project.create.folder.name.placeholder')} ]}
/>
</>
};
export default JobForm;
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { ModalForm } from "@ant-design/pro-components";
import {Form} from "antd";
import React from "react";
import JobForm from "@/pages/DataStudio/LeftContainer/Project/JobModal/JobForm";
import {Catalogue} from "@/types/Studio/data";
import {l} from "@/utils/intl";
type JobModalProps = {
onCancel: () => void
onSubmit: (values: Catalogue) => void
modalVisible: boolean
}
const JobModal:React.FC<JobModalProps> = ( props ) => {
const {onCancel, onSubmit, modalVisible} = props;
const [form] = Form.useForm<Catalogue>();
return <>
<ModalForm<Catalogue>
title={l('datastudio.project.create.rootFolder')}
form={form}
width={'30%'}
open={modalVisible}
layout={'inline'}
style={{display: 'flex', flexDirection: 'column', alignItems: 'center',}}
autoFocusFirstInput
modalProps={{destroyOnClose: true, maskClosable: false, onCancel: onCancel}}
onFinish={async (values) => onSubmit(values)}
>
<JobForm />
</ModalForm>
</>
};
export default JobModal;
\ No newline at end of file
......@@ -25,7 +25,6 @@ import {StateType} from "@/pages/DataStudio/model";
import {Key} from "@ant-design/pro-components";
import {BtnRoute} from "@/pages/DataStudio/route";
import Search from "antd/es/input/Search";
import {never} from "@umijs/utils/compiled/zod";
const {DirectoryTree} = Tree;
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import React, {useState} from "react";
import {Space} from "antd";
import Title from "@/components/Front/Title";
import {l} from "@/utils/intl";
import JobModal from "@/pages/DataStudio/LeftContainer/Project/JobModal";
import {connect} from "@umijs/max";
import {StateType} from "@/pages/DataStudio/model";
import {Catalogue} from "@/types/Studio/data";
import {handleAddOrUpdate} from "@/services/BusinessCrud";
import {PlusOutlined} from "@ant-design/icons";
import {CircleBtn} from "@/components/CallBackButton/CircleBtn";
const ProjectTitle: React.FC<StateType & connect> = (props) => {
const {
leftContainer: {selectKey},
dispatch,
} = props;
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
const handleCancelCreate = async () => {
handleModalVisible(false);
}
const handleCreateClick = async () => {
handleModalVisible(true);
}
/**
* 创建根目录, 并刷新目录树
* @param {Catalogue} values
* @returns {Promise<void>}
*/
const handleSubmit = async (values: Catalogue) => {
await handleAddOrUpdate('/api/catalogue/saveOrUpdateCatalogue', {
...values,
isLeaf: false,
parentId: 0,
}, ()=>{
handleCancelCreate();
dispatch({type: 'Studio/queryProject'});
});
}
/**
* 渲染侧边栏标题
* @returns {JSX.Element}
*/
const renderTitle = () => {
if (selectKey && selectKey === "menu.datastudio.project") {
return <Space>
<Title>{l(selectKey)}</Title>
<CircleBtn title={l("datastudio.project.create.rootFolder")} icon={<PlusOutlined/>}
onClick={() => handleCreateClick()}/>
<JobModal modalVisible={createModalVisible} onCancel={handleCancelCreate} onSubmit={handleSubmit}/>
</Space>
} else {
return <Title>{l(selectKey)}</Title>
}
}
return <>
{renderTitle()}
</>
}
export default connect(({Studio}: { Studio: StateType }) => ({
leftContainer: Studio.leftContainer,
}))(ProjectTitle);
\ No newline at end of file
......@@ -28,32 +28,36 @@ import {getTaskDetails} from "@/pages/DataStudio/LeftContainer/Project/service";
const Project: React.FC = (props: connect) => {
const {dispatch}=props
const onNodeClick = (info: any) => {
// 选中的key
const {node: {isLeaf, name,type,parentId,path,key,taskId}} = info;
if (isLeaf) {
// const queryParams = {id: selectDatabaseId , schemaName, tableName};
getTaskDetails(taskId).then(res=>{
path.pop()
res['useResult']=true
res['maxRowNum']=100
dispatch({
type: "Studio/addTab",
payload: {
icon: type,
id: parentId + name,
breadcrumbLabel: path.join("/"),
label: name ,
params:{taskId:taskId,taskData:res},
type: "project",
subType: type.toLowerCase()
}
})
})
}
}
return (
<div style={{paddingInline: 5}}>
<JobTree onNodeClick={(info:any) => {
// 选中的key
const {node: {isLeaf, name, fullInfo,type,parentId,path,key,taskId}} = info;
if (isLeaf) {
// const queryParams = {id: selectDatabaseId , schemaName, tableName};
getTaskDetails(taskId).then(res=>{
path.pop()
res['useResult']=true
res['maxRowNum']=100
dispatch({
type: "Studio/addTab",
payload: {
icon: type,
id: parentId+name,
breadcrumbLabel: path.join("/"),
label: name ,
params:{taskId:taskId,taskData:res},
type: "project",
subType: type.toLowerCase()
}
})
})
}
}} treeData={props.data}/>
<JobTree onNodeClick={(info:any) => onNodeClick(info)} treeData={props.data}/>
</div>
)
};
......
import {Space, Tabs} from "antd";
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {Tabs} from "antd";
import MovableSidebar, {MovableSidebarProps} from "@/components/Sidebar/MovableSidebar";
import React, {useState} from "react";
import {connect} from "@@/exports";
import {StateType, VIEW} from "@/pages/DataStudio/model";
import {BtnRoute, LeftSide} from "@/pages/DataStudio/route";
import {l} from "@/utils/intl";
import Title from "@/components/Front/Title";
import useThemeValue from "@/hooks/useThemeValue";
import {PlusOutlined} from "@ant-design/icons";
import {CircleBtn, CircleButtonProps} from "@/components/CallBackButton/CircleBtn";
import ProjectTitle from "@/pages/DataStudio/LeftContainer/Project/ProjectTitle";
export type LeftContainerProps = {
size: number
......@@ -44,34 +61,29 @@ const LeftContainer: React.FC<LeftContainerProps> = (props: any) => {
*/
const handleMaxsize = () => {
handleReSizeChange(MAX_WIDTH)
}
};
const content = (
<Tabs activeKey={leftContainer.selectKey} items={LeftSide} tabBarStyle={{display: "none"}}/>
)
/**
* 侧边栏属性
* @type {{onResize: (event: any, direction: any, elementRef: {offsetWidth: any}) => void, visible: boolean, defaultSize: {width: any, height: any}, enable: {right: boolean}, minWidth: number, title: string, handlerMinimize: () => void, contentHeight: any, maxWidth: number}}
*/
const restMovableSidebarProps: MovableSidebarProps = {
contentHeight: toolContentHeight,
onResize: (event: any, direction: any, elementRef: {
offsetWidth: any;
}) => handleReSizeChange(elementRef.offsetWidth),
title: <Title>{l(leftContainer.selectKey)}</Title>,
onResize: (event: any, direction: any, elementRef: {offsetWidth: any; }) => handleReSizeChange(elementRef.offsetWidth),
title: <ProjectTitle/>,
handlerMinimize: () => handleMinimize(),
handlerMaxsize: handleMaxsize,
visible: leftContainer.selectKey !== "",
defaultSize: {width: leftContainer.width, height: leftContainer.height},
minWidth: 260,
maxWidth: MAX_WIDTH, //
maxWidth: MAX_WIDTH,
enable: {right: true},
btnGroup: BtnRoute[leftContainer.selectKey] ? BtnRoute[leftContainer.selectKey].map((item: CircleButtonProps) => {
return <CircleBtn title={item.title} icon={item.icon} onClick={item.onClick} key={item.title}/>
}) : [],
btnGroup: BtnRoute[leftContainer.selectKey] ? BtnRoute[leftContainer.selectKey].map((item: CircleButtonProps) => (<CircleBtn title={item.title} icon={item.icon} onClick={item.onClick} key={item.title}/>)) : [],
style: {borderInlineEnd: "1px solid " + themeValue.borderColor}
}
const content = <Tabs activeKey={leftContainer.selectKey} items={LeftSide} tabBarStyle={{display: "none"}}/>
return (
<MovableSidebar {...restMovableSidebarProps}>
......
......@@ -193,17 +193,13 @@ const DataStudio = (props: any) => {
<Menu
mode="inline"
selectedKeys={[leftContainer.selectKey]}
items={LeftSide.map(x => {
return {key: x.key, label: x.label, icon: x.icon}
})}
items={LeftSide.map(x => ({key: x.key, label: x.label, icon: x.icon}))}
style={{
height: '50%',
borderBlockStart: "1px solid " + themeValue.borderColor,
borderInlineEnd: "1px solid " + themeValue.borderColor
}}
onClick={(item) => {
updateSelectLeftKey(item.key === leftContainer.selectKey ? '' : item.key)
}}
onClick={(item) => updateSelectLeftKey(item.key === leftContainer.selectKey ? '' : item.key)}
/>
......@@ -211,9 +207,7 @@ const DataStudio = (props: any) => {
<Menu
mode="inline"
selectedKeys={[bottomContainer.selectKey]}
items={LeftBottomSide.map(x => {
return {key: x.key, label: x.label, icon: x.icon}
})}
items={LeftBottomSide.map(x => ({key: x.key, label: x.label, icon: x.icon}))}
style={{
display: 'flex',
height: '50%',
......@@ -279,9 +273,7 @@ const DataStudio = (props: any) => {
}).map(x => {
return {key: x.key, label: x.label, icon: x.icon}
})}
onClick={(item) => {
updateSelectRightKey(item.key === rightContainer.selectKey ? '' : item.key)
}}
onClick={(item) => updateSelectRightKey(item.key === rightContainer.selectKey ? '' : item.key)}
/>
</Sider>
</Layout>
......
import {Reducer} from "@@/plugin-dva/types";
import {Effect, Reducer} from "@@/plugin-dva/types";
import React from "react";
import {Cluster, DataSources} from "@/types/RegCenter/data";
import {QueryParams} from "@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data";
import {l} from "@/utils/intl";
import {getFooterValue} from "@/pages/DataStudio/function";
import {getTaskData} from "@/pages/DataStudio/LeftContainer/Project/service";
/**
* 初始化布局宽高度
......@@ -234,7 +235,9 @@ export type StateType = {
export type ModelType = {
namespace: string;
state: StateType;
effects: {};
effects: {
queryProject: Effect;
};
reducers: {
updateToolContentHeight: Reducer<StateType>;
updateCenterContentHeight: Reducer<StateType>;
......@@ -326,7 +329,15 @@ const Model: ModelType = {
},
}
},
effects: {},
effects: {
*queryProject({payload}, {call, put}) {
const response : [] = yield call(getTaskData, payload);
yield put({
type: 'saveProject',
payload: response,
});
},
},
reducers: {
/**
* 更新工具栏高度
......
......@@ -90,14 +90,16 @@ export function chooseTenantSubmit(params: { tenantId: number }) {
* add or update data
* @param url
* @param params
* @param afterCallBack
*/
export const handleAddOrUpdate = async (url: string, params: any) => {
export const handleAddOrUpdate = async (url: string, params: any, afterCallBack? : ()=> void) => {
const tipsTitle = params.id ? l('app.request.update') : l('app.request.add');
await LoadingMessageAsync(l('app.request.running') + tipsTitle);
try {
const {code, msg} = await addOrUpdateData(url, {...params});
if (code === RESPONSE_CODE.SUCCESS) {
await SuccessMessage(msg);
afterCallBack && afterCallBack();
} else {
await WarningMessage(msg);
}
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export type Catalogue = {
id: number;
name: string;
tenantId: number;
taskId: number;
type: string;
parentId: number;
isLeaf: boolean;
createTime: Date;
updateTime: Date;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment