Skip to content

Commit

Permalink
Spotless Apply
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu-mingye authored and github-actions[bot] committed Nov 3, 2023
1 parent d8f8cd7 commit 3f62f0a
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 77 deletions.
2 changes: 1 addition & 1 deletion dinky-web/src/components/TableTransfer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*
*/

import { UserBaseInfo } from '@/types/AuthCenter/data.d';
import { ProColumns, ProTable } from '@ant-design/pro-components';
import { Transfer } from 'antd';
import { TableRowSelection } from 'antd/es/table/interface';
import { TransferProps } from 'antd/es/transfer';
import { difference } from 'lodash';
import {UserBaseInfo} from "@/types/AuthCenter/data.d";

/**
* Customize Table Transfer Props
Expand Down
15 changes: 9 additions & 6 deletions dinky-web/src/components/Transfer/TreeTransfer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*
*/

import { Transfer,Tree } from 'antd';
import type { TransferDirection,TransferItem } from 'antd/es/transfer';
import { Transfer, Tree } from 'antd';
import type { TransferDirection, TransferItem } from 'antd/es/transfer';
import type { DataNode } from 'antd/es/tree';
import React,{ Key } from 'react';
import React, { Key } from 'react';

const {DirectoryTree} = Tree;
const { DirectoryTree } = Tree;
interface TreeTransferProps {
dataSource: DataNode[];
targetKeys: Key[];
Expand All @@ -37,10 +37,13 @@ const generateTree = (treeNodes: DataNode[] = [], checkedKeys: Key[] = []): Data
disabled: checkedKeys.includes(props.key as string),
children: generateTree(children, checkedKeys)
}));
export const TreeTransfer: React.FC<TreeTransferProps> = ({dataSource, targetKeys, ...restProps}) => {
export const TreeTransfer: React.FC<TreeTransferProps> = ({
dataSource,
targetKeys,
...restProps
}) => {
const transferDataSource: TransferItem[] = [];


function flatten(list: DataNode[] = []) {
list.forEach((item) => {
transferDataSource.push(item as TransferItem);
Expand Down
1 change: 0 additions & 1 deletion dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ export default {
'rc.udf.register.deleteConfirm': '确定删除该 UDF 吗?',
'rc.udf.register': '注册 UDF',


/**
*
* role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
*
*/

import { TagAlignCenter } from '@/components/StyledComponents';
import { ResourceInfo } from '@/types/RegCenter/data';
import { parseByteStr,renderIcon } from '@/utils/function';
import { parseByteStr, renderIcon } from '@/utils/function';
import { l } from '@/utils/intl';
import {TagAlignCenter} from "@/components/StyledComponents";

const buildTitleLabel = (item: ResourceInfo) => {
return (
Expand All @@ -36,7 +36,6 @@ const buildTitleLabel = (item: ResourceInfo) => {
);
};


/**
* 判断目录是否为空
* @param directory
Expand All @@ -57,7 +56,11 @@ function isDirectoryEmpty(directory: ResourceInfo): boolean {
return true;
}

function filterEmpty(isFilterEmptyChildren: boolean, item: ResourceInfo, filterSuffixList: string[]) {
function filterEmpty(
isFilterEmptyChildren: boolean,
item: ResourceInfo,
filterSuffixList: string[]
) {
if (isFilterEmptyChildren) {
if (item.isDirectory) {
// 如果是目录,则递归遍历看最深处是否是空目录,是的话过滤掉
Expand All @@ -75,19 +78,25 @@ function filterEmpty(isFilterEmptyChildren: boolean, item: ResourceInfo, filterS
return true;
}

export const buildResourceTreeData = (data: ResourceInfo[], isFilterEmptyChildren = false, filterSuffixList : string[] = []): any =>
data.filter((item: ResourceInfo) => filterEmpty(isFilterEmptyChildren, item, filterSuffixList)).map((item: ResourceInfo) => {
return {
isLeaf: !item.isDirectory,
name: item.fileName,
parentId: item.pid,
label: item.fullName + '/' + item.fileName,
icon: <TagAlignCenter>{renderIcon(item.fileName, '.', item.isDirectory)}</TagAlignCenter>,
path: item.fullName,
title: buildTitleLabel(item),
fullInfo: item,
key: item.id,
id: item.id,
children: item.children && buildResourceTreeData(item.children, isFilterEmptyChildren)
};
});
export const buildResourceTreeData = (
data: ResourceInfo[],
isFilterEmptyChildren = false,
filterSuffixList: string[] = []
): any =>
data
.filter((item: ResourceInfo) => filterEmpty(isFilterEmptyChildren, item, filterSuffixList))
.map((item: ResourceInfo) => {
return {
isLeaf: !item.isDirectory,
name: item.fileName,
parentId: item.pid,
label: item.fullName + '/' + item.fileName,
icon: <TagAlignCenter>{renderIcon(item.fileName, '.', item.isDirectory)}</TagAlignCenter>,
path: item.fullName,
title: buildTitleLabel(item),
fullInfo: item,
key: item.id,
id: item.id,
children: item.children && buildResourceTreeData(item.children, isFilterEmptyChildren)
};
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {TreeTransfer} from "@/components/Transfer/TreeTransfer";
import {buildResourceTreeData} from "@/pages/RegCenter/Resource/components/FileTree/function";
import {Modal} from "antd";
import React, {Key, memo} from "react";
import {TransferDirection} from "antd/es/transfer";
import {l} from "@/utils/intl";

import { TreeTransfer } from '@/components/Transfer/TreeTransfer';
import { buildResourceTreeData } from '@/pages/RegCenter/Resource/components/FileTree/function';
import { l } from '@/utils/intl';
import { Modal } from 'antd';
import { TransferDirection } from 'antd/es/transfer';
import React, { Key, memo } from 'react';

type UDFRegisterModalProps = {
showEdit: boolean;
Expand All @@ -13,32 +12,32 @@ type UDFRegisterModalProps = {
targetKeys: Key[];
targetKeyChange: (targetKeys: Key[], direction: TransferDirection, moveKeys: string[]) => void;
treeData: any[];

}
};

const UDFRegisterModal: React.FC<UDFRegisterModalProps> = (props) => {
const { showEdit, openChange, treeData, targetKeys, targetKeyChange, onOk } = props;

const {showEdit, openChange,treeData,targetKeys,targetKeyChange,onOk} = props;

return <>
<Modal
width={'70%'}
bodyStyle={{height: 600, overflow: 'auto'}}
open={showEdit}
title={l('rc.udf.register')}
destroyOnClose
closable
maskClosable={false}
onCancel={() => openChange(false)}
onOk={() => onOk()}
>
<TreeTransfer
dataSource={buildResourceTreeData(treeData, true,['jar','zip'])}
targetKeys={targetKeys}
onChange={targetKeyChange}
/>
</Modal>
</>
}
return (
<>
<Modal
width={'70%'}
bodyStyle={{ height: 600, overflow: 'auto' }}
open={showEdit}
title={l('rc.udf.register')}
destroyOnClose
closable
maskClosable={false}
onCancel={() => openChange(false)}
onOk={() => onOk()}
>
<TreeTransfer
dataSource={buildResourceTreeData(treeData, true, ['jar', 'zip'])}
targetKeys={targetKeys}
onChange={targetKeyChange}
/>
</Modal>
</>
);
};

export default memo(UDFRegisterModal);
22 changes: 10 additions & 12 deletions dinky-web/src/pages/RegCenter/UDF/components/UDFRegister/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,21 @@ import { EditBtn } from '@/components/CallBackButton/EditBtn';
import { PopconfirmDeleteBtn } from '@/components/CallBackButton/PopconfirmDeleteBtn';
import UDFRegisterModal from '@/pages/RegCenter/UDF/components/UDFRegister/UDFRegisterModal';
import { API_CONSTANTS } from '@/services/endpoints';
import { UDFRegisterInfo,UDFRegisterInfoParent } from '@/types/RegCenter/data';
import { UDFRegisterInfo, UDFRegisterInfoParent } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { useRequest } from '@@/plugin-request';
import { ProColumns } from '@ant-design/pro-components';
import ProTable,{ ActionType } from '@ant-design/pro-table';
import React, { Key,useEffect,useRef,useState } from 'react';
import { add,update } from './service';
import {l} from "@/utils/intl";
import ProTable, { ActionType } from '@ant-design/pro-table';
import React, { Key, useEffect, useRef, useState } from 'react';
import { add, update } from './service';

type UDFRegisterProps = {
showEdit: boolean;
showEditChange: (showEdit: boolean) => void;
}
};

const UDFRegister: React.FC<UDFRegisterProps> = (props) => {

const { showEdit,showEditChange } = props;
const { showEdit, showEditChange } = props;

const udfRegisterInfoRequest = useRequest<{
data: UDFRegisterInfo[];
Expand Down Expand Up @@ -100,7 +99,7 @@ const UDFRegister: React.FC<UDFRegisterProps> = (props) => {
},
{
title: l('rc.udf.register.source'),
width: "25%",
width: '25%',
dataIndex: 'source',
valueEnum: {
resources: { text: 'resources' },
Expand All @@ -122,7 +121,7 @@ const UDFRegister: React.FC<UDFRegisterProps> = (props) => {
{
title: l('rc.udf.register.name'),
dataIndex: 'name',
width: '10%',
width: '10%'
},
{
title: l('rc.udf.register.className'),
Expand Down Expand Up @@ -168,7 +167,7 @@ const UDFRegister: React.FC<UDFRegisterProps> = (props) => {
await update(row.id, row.name);
await udfRegisterInfoRequest.refresh();
actionRef.current?.reload();
}
};

return (
<ProTable
Expand All @@ -192,7 +191,6 @@ const UDFRegister: React.FC<UDFRegisterProps> = (props) => {
);
};


/**
* submit register udf
*/
Expand Down
8 changes: 4 additions & 4 deletions dinky-web/src/pages/RegCenter/UDF/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/

import SlowlyAppear from '@/components/Animation/SlowlyAppear';
import { CreateBtn } from "@/components/CallBackButton/CreateBtn";
import UDFRegister from "@/pages/RegCenter/UDF/components/UDFRegister";
import { CreateBtn } from '@/components/CallBackButton/CreateBtn';
import UDFRegister from '@/pages/RegCenter/UDF/components/UDFRegister';
import TemplateTable from '@/pages/RegCenter/UDF/components/UDFTemplate/TemplateTable';
import { l } from '@/utils/intl';
import { PageContainer } from '@ant-design/pro-components';
import * as React from "react";
import {l} from "@/utils/intl";
import * as React from 'react';

export default () => {
const [showEdit, setShowEdit] = React.useState<boolean>(false);
Expand Down
6 changes: 4 additions & 2 deletions dinky-web/src/utils/function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ import {
ConfigSvg,
FileIcon,
FlinkSQLSvg,
FolderSvgExpand, JarSvg,
FolderSvgExpand,
JarSvg,
JavaSvg,
LogSvg,
MarkDownSvg,
PythonSvg,
ScalaSvg,
ShellSvg,
XMLSvg,
YAMLSvg, ZipSvg
YAMLSvg,
ZipSvg
} from '@/components/Icons/CodeLanguageIcon';
import {
DATETIME_FORMAT,
Expand Down

0 comments on commit 3f62f0a

Please sign in to comment.