diff --git a/dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/index.tsx b/dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/index.tsx index 687f4a37f1..bf65326979 100644 --- a/dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/index.tsx +++ b/dinky-web/src/pages/DataStudio/CenterTabContent/SqlTask/index.tsx @@ -17,13 +17,13 @@ * */ -import { CenterTab, DataStudioState } from '@/pages/DataStudio/model'; -import { Button, Col, Divider, Flex, Row, Skeleton, TabsProps } from 'antd'; +import {CenterTab, DataStudioState} from '@/pages/DataStudio/model'; +import {Button, Col, Divider, Flex, Row, Skeleton, TabsProps} from 'antd'; import '../index.less'; -import React, { memo, useCallback, useEffect, useRef, useState } from 'react'; -import { registerEditorKeyBindingAndAction } from '@/utils/function'; -import { Monaco } from '@monaco-editor/react'; -import { Panel, PanelGroup } from 'react-resizable-panels'; +import React, {memo, useCallback, useEffect, useRef, useState} from 'react'; +import {registerEditorKeyBindingAndAction} from '@/utils/function'; +import {Monaco} from '@monaco-editor/react'; +import {Panel, PanelGroup} from 'react-resizable-panels'; import { ApartmentOutlined, BugOutlined, @@ -42,7 +42,7 @@ import { XFilled } from '@ant-design/icons'; import RunToolBarButton from '@/pages/DataStudio/components/RunToolBarButton'; -import { connect, useModel } from '@umijs/max'; +import {connect, useModel} from '@umijs/max'; import CusPanelResizeHandle from '@/pages/DataStudio/components/CusPanelResizeHandle'; import { ProForm, @@ -53,20 +53,20 @@ import { ProFormTextArea, ProFormTreeSelect } from '@ant-design/pro-components'; -import { useAsyncEffect, useFullscreen } from 'ahooks'; -import { SelectFlinkEnv } from '@/pages/DataStudio/CenterTabContent/RunToolbar/SelectFlinkEnv'; -import { SelectFlinkRunMode } from '@/pages/DataStudio/CenterTabContent/RunToolbar/SelectFlinkRunMode'; -import { mapDispatchToProps } from '@/pages/DataStudio/DvaFunction'; -import { TaskInfo } from '@/pages/DataStudio/CenterTabContent/SqlTask/TaskInfo'; -import { HistoryVersion } from '@/pages/DataStudio/CenterTabContent/SqlTask/HistoryVersion'; +import {useAsyncEffect, useFullscreen} from 'ahooks'; +import {SelectFlinkEnv} from '@/pages/DataStudio/CenterTabContent/RunToolbar/SelectFlinkEnv'; +import {SelectFlinkRunMode} from '@/pages/DataStudio/CenterTabContent/RunToolbar/SelectFlinkRunMode'; +import {mapDispatchToProps} from '@/pages/DataStudio/DvaFunction'; +import {TaskInfo} from '@/pages/DataStudio/CenterTabContent/SqlTask/TaskInfo'; +import {HistoryVersion} from '@/pages/DataStudio/CenterTabContent/SqlTask/HistoryVersion'; import { FlinkTaskRunType, SqlConvertForm, StudioLineageParams, TaskState } from '@/pages/DataStudio/type'; -import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants'; -import { debounce } from 'lodash'; +import {JOB_LIFE_CYCLE} from '@/pages/DevOps/constants'; +import {debounce} from 'lodash'; import { cancelTask, changeTaskLife, @@ -78,25 +78,25 @@ import { getJobPlan, getTaskDetails } from '@/pages/DataStudio/service'; -import { l } from '@/utils/intl'; -import { editor } from 'monaco-editor'; -import { DataStudioActionType } from '@/pages/DataStudio/data.d'; -import { getDataByParams, handlePutDataJson, queryDataByParams } from '@/services/BusinessCrud'; -import { API_CONSTANTS } from '@/services/endpoints'; -import { Jobs, LineageDetailInfo } from '@/types/DevOps/data'; -import { lockTask, matchLanguage } from '@/pages/DataStudio/function'; -import { PushpinIcon } from '@/components/Icons/CustomIcons'; -import { assert, isSql } from '@/pages/DataStudio/utils'; -import { DIALECT } from '@/services/constants'; -import { SysConfigStateType } from '@/pages/SettingCenter/GlobalSetting/model'; +import {l} from '@/utils/intl'; +import {editor} from 'monaco-editor'; +import {DataStudioActionType} from '@/pages/DataStudio/data.d'; +import {getDataByParams, handlePutDataJson, queryDataByParams} from '@/services/BusinessCrud'; +import {API_CONSTANTS} from '@/services/endpoints'; +import {Jobs, LineageDetailInfo} from '@/types/DevOps/data'; +import {lockTask, matchLanguage} from '@/pages/DataStudio/function'; +import {PushpinIcon} from '@/components/Icons/CustomIcons'; +import {assert, isSql} from '@/pages/DataStudio/utils'; +import {DIALECT} from '@/services/constants'; +import {SysConfigStateType} from '@/pages/SettingCenter/GlobalSetting/model'; import CodeEdit from '@/components/CustomEditor/CodeEdit'; import DiffModal from '@/pages/DataStudio/CenterTabContent/SqlTask/DiffModal'; import TaskConfig from '@/pages/DataStudio/CenterTabContent/SqlTask/TaskConfig'; import SelectDb from '@/pages/DataStudio/CenterTabContent/RunToolbar/SelectDb'; -import { SseData, Topic } from '@/models/UseWebSocketModel'; -import { ResourceInfo } from '@/types/RegCenter/data'; -import { buildResourceTreeDataAtTreeForm } from '@/pages/RegCenter/Resource/components/FileTree/function'; -import { ProFormDependency } from '@ant-design/pro-form'; +import {SseData, Topic} from '@/models/UseWebSocketModel'; +import {ResourceInfo} from '@/types/RegCenter/data'; +import {buildResourceTreeDataAtTreeForm} from '@/pages/RegCenter/Resource/components/FileTree/function'; +import {ProFormDependency} from '@ant-design/pro-form'; export type FlinkSqlProps = { showDesc: boolean; @@ -127,7 +127,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { users, tabs } = props; - const { params, title, id } = props.tabData as CenterTab; + const {params, title, id} = props.tabData as CenterTab; const containerRef = useRef(null); const editorInstance = useRef(null); const [codeEditorWidth, setCodeEditorWidth] = useState(0); @@ -175,10 +175,10 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { const [isSubmitting, setIsSubmitting] = useState(false); const formRef = useRef(); - const [isFullscreen, { enterFullscreen, exitFullscreen }] = useFullscreen(containerRef); + const [isFullscreen, {enterFullscreen, exitFullscreen}] = useFullscreen(containerRef); - const { initialState } = useModel('@@initialState'); - const { subscribeTopic } = useModel('UseWebSocketModel', (model: any) => ({ + const {initialState} = useModel('@@initialState'); + const {subscribeTopic} = useModel('UseWebSocketModel', (model: any) => ({ subscribeTopic: model.subscribeTopic })); const [isRunning, setIsRunning] = useState(false); @@ -187,10 +187,10 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { const taskDetail = await getTaskDetails(params.taskId); if (taskDetail) { const statement = params.statement ?? taskDetail.statement; - const newParams = { ...taskDetail, taskId: params.taskId, statement, mockSinkFunction: true }; + const newParams = {...taskDetail, taskId: params.taskId, statement, mockSinkFunction: true}; if (taskDetail.dialect.toLowerCase() === DIALECT.FLINKJAR) { const sqlConvertForm = await flinkJarSqlConvertForm(taskDetail.statement); - setSqlForm({ enable: true, ...sqlConvertForm }); + setSqlForm({enable: true, ...sqlConvertForm}); setCurrentState({ ...newParams, statement: sqlConvertForm?.initSqlStatement ?? '' @@ -198,27 +198,27 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { setOriginStatementValue(sqlConvertForm?.initSqlStatement ?? ''); if (params?.statement && params?.statement !== sqlConvertForm?.initSqlStatement) { setDiff([ - { key: 'statement', server: sqlConvertForm?.initSqlStatement, cache: params.statement } + {key: 'statement', server: sqlConvertForm?.initSqlStatement, cache: params.statement} ]); setOpenDiffModal(true); updateCenterTab({ ...props.tabData, isUpdate: true, - params: { ...newParams } + params: {...newParams} }); } } else { setOriginStatementValue(statement); // @ts-ignore setCurrentState(newParams); - updateCenterTab({ ...props.tabData, params: newParams }); + updateCenterTab({...props.tabData, params: newParams}); if (params?.statement && params?.statement !== taskDetail.statement) { - setDiff([{ key: 'statement', server: taskDetail.statement, cache: params.statement }]); + setDiff([{key: 'statement', server: taskDetail.statement, cache: params.statement}]); setOpenDiffModal(true); updateCenterTab({ ...props.tabData, isUpdate: true, - params: { ...newParams } + params: {...newParams} }); } } @@ -226,6 +226,15 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { setLoading(false); }, []); + useEffect(() => { + setCurrentState(prevState => ({ + ...prevState, + name: params.name, + note: params.note, + secondLevelOwners: params.secondLevelOwners, + firstLevelOwner: params.firstLevelOwner + })) + }, [params]); useEffect(() => { return subscribeTopic(Topic.TASK_RUN_INSTANCE, null, (data: SseData) => { if (data?.data?.RunningTaskId) { @@ -237,7 +246,8 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { // 数据初始化 useEffect(() => { if (!containerRef.current) { - return () => {}; + return () => { + }; } // 监控布局宽度高度变化,重新计算树的高度 const element = containerRef.current!!; @@ -279,10 +289,10 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { updateCenterTab({ ...props.tabData, isUpdate: false, - params: { ...currentState, statement } + params: {...currentState, statement} }); } - setCurrentState((prevState) => ({ ...prevState, statement })); + setCurrentState((prevState) => ({...prevState, statement})); setOriginStatementValue(statement); setOpenDiffModal(false); @@ -305,9 +315,9 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { updateCenterTab({ ...props.tabData, isUpdate: originStatementValue !== value, - params: { ...currentState, statement: value ?? '' } + params: {...currentState, statement: value ?? ''} }); - setCurrentState((prevState) => ({ ...prevState, statement: value ?? '' })); + setCurrentState((prevState) => ({...prevState, statement: value ?? ''})); }; const onValuesChange = (changedValues: any, allValues: TaskState) => { @@ -330,10 +340,10 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { } allValues.type = mode; } - setCurrentState({ ...currentState, ...allValues }); - updateCenterTab({ ...props.tabData, params: { ...currentState, ...allValues } }); + setCurrentState({...currentState, ...allValues}); + updateCenterTab({...props.tabData, params: {...currentState, ...allValues}}); }; - const hotKeyConfig = { enable: activeTab === id }; + const hotKeyConfig = {enable: activeTab === id}; const getActiveTab = () => { return tabs.find((item: CenterTab) => { @@ -386,7 +396,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { rightToolbarItem.push({ label: l('global.info'), key: 'info', - children: + children: }); const handleSave = useCallback(async () => { @@ -394,8 +404,8 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { currentState.dialect.toLowerCase() === DIALECT.FLINKJAR ? (await flinkJarFormConvertSql(sqlForm))!! : currentState.statement; - await handlePutDataJson(API_CONSTANTS.TASK, { ...currentState, statement }); - updateCenterTab({ ...props.tabData, isUpdate: false }); + await handlePutDataJson(API_CONSTANTS.TASK, {...currentState, statement}); + updateCenterTab({...props.tabData, isUpdate: false}); }, [currentState, updateCenterTab, props.tabData, sqlForm]); const handleCheck = useCallback(async () => { @@ -404,8 +414,8 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { ? (await flinkJarFormConvertSql(sqlForm))!! : currentState.statement; const res = await explainSql( - l('pages.datastudio.editor.checking', '', { jobName: currentState?.name }), - { ...currentState, statement } + l('pages.datastudio.editor.checking', '', {jobName: currentState?.name}), + {...currentState, statement} ); updateAction({ actionType: DataStudioActionType.TASK_RUN_CHECK, @@ -434,7 +444,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { }, [currentState, updateAction]); const handleLineage = useCallback(async () => { - const { type, dialect, databaseId, statement, envId, fragment, taskId } = currentState; + const {type, dialect, databaseId, statement, envId, fragment, taskId} = currentState; const params: StudioLineageParams = { type: 1, // todo: 暂时写死 ,后续优化 dialect: dialect, @@ -473,7 +483,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { } }); const result = await executeSql( - l('pages.datastudio.editor.submitting', '', { jobName: title }), + l('pages.datastudio.editor.submitting', '', {jobName: title}), currentState.taskId ); if (result.success) { @@ -513,8 +523,8 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { setIsSubmitting(true); try { const res = await debugTask( - l('pages.datastudio.editor.debugging', '', { jobName: currentState.name }), - { ...currentState } + l('pages.datastudio.editor.debugging', '', {jobName: currentState.name}), + {...currentState} ); if (res?.success && res?.data?.result?.success) { updateAction({ @@ -560,7 +570,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { const handleGotoDevOps = useCallback(async () => { const dataByParams = await queryDataByParams( API_CONSTANTS.GET_JOB_INSTANCE_BY_TASK_ID, - { taskId: currentState.taskId } + {taskId: currentState.taskId} ); if (dataByParams) { window.open(`/#/devops/job-detail?id=${dataByParams?.id}`); @@ -597,7 +607,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { ); currentState.step = JOB_LIFE_CYCLE.PUBLISH; } - setCurrentState((prevState) => ({ ...prevState, step: currentState.step })); + setCurrentState((prevState) => ({...prevState, step: currentState.step})); }, [handleSave, currentState.step, currentState.taskId]); return ( @@ -617,7 +627,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { fileName={currentState.name} onUse={updateTask} /> - + { } + icon={} onClick={handleSave} disabled={currentState?.step === JOB_LIFE_CYCLE.PUBLISH || isLockTask} hotKey={{ @@ -651,7 +661,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { isShow={!isFullscreen} showDesc={showDesc} desc={l('global.fullScreen')} - icon={} + icon={} onClick={async () => { enterFullscreen(); }} @@ -660,7 +670,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { isShow={isFullscreen} showDesc={showDesc} desc={l('global.fullScreen.exit')} - icon={} + icon={} onClick={async () => { exitFullscreen(); }} @@ -668,7 +678,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { } + icon={} onClick={handleCheck} disabled={isLockTask} isShow={ @@ -696,14 +706,14 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { true, 'includes' )} - icon={} + icon={} onClick={handleDAG} /> } + icon={} onClick={handleLineage} isShow={assert(currentState.dialect, [DIALECT.FLINK_SQL], true, 'includes')} /> @@ -715,15 +725,15 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { 'includes' ) && ( <> - - - + + + )} {isSql(currentState.dialect) && ( <> - - + + )} @@ -732,7 +742,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { [DIALECT.JAVA, DIALECT.SCALA, DIALECT.PYTHON_LONG, DIALECT.FLINKSQLENV], true, 'notIncludes' - ) && } + ) && } { disabled={isLockTask || isSubmitting} color={'green'} desc={l('pages.datastudio.editor.exec')} - icon={} + icon={} onClick={handleSubmit} hotKey={{ ...hotKeyConfig, @@ -764,7 +774,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { disabled={isLockTask || isSubmitting} color={'red'} desc={l('pages.datastudio.editor.debug')} - icon={} + icon={} onClick={handleDebug} hotKey={{ ...hotKeyConfig, @@ -779,7 +789,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { showDesc={showDesc} color={'red'} desc={l('pages.datastudio.editor.stop')} - icon={} + icon={} onClick={handleStop} hotKey={{ ...hotKeyConfig, @@ -801,34 +811,34 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { disabled={isLockTask} showDesc={showDesc} desc={l('pages.datastudio.to.jobDetail')} - icon={} + icon={} onClick={handleGotoDevOps} /> - + } + icon={} onClick={handleFormat} /> } + icon={} onClick={handleLocation} /> - + } + icon={} onClick={handleChangeJobLife} /> { showDesc={showDesc} disabled={isLockTask} desc={l('button.offline')} - icon={} + icon={} onClick={handleChangeJobLife} /> } + icon={} isShow={ enabledDs && JOB_LIFE_CYCLE.PUBLISH === currentState.step && @@ -862,9 +872,9 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { /> - - - + + + { {sqlForm.enable && ( <> - + @@ -900,7 +910,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { {/**/} { setSqlForm((prevState) => ({ ...prevState, @@ -914,7 +924,7 @@ export const SqlTask = memo((props: FlinkSqlProps & any) => { /> - {({ manualInput }) => { + {({manualInput}) => { return manualInput?.length > 0 ? ( { )} {selectRightToolbar && ( <> - +