This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 096fae77f4 feat: Locations Formats the layout if it does not exist
(#11535)
096fae77f4 is described below
commit 096fae77f4a2dd436f515e5b51f170591d7b6f24
Author: labbomb <[email protected]>
AuthorDate: Wed Aug 24 18:59:14 2022 +0800
feat: Locations Formats the layout if it does not exist (#11535)
---
.../src/views/projects/workflow/components/dag/index.tsx | 1 +
.../projects/workflow/components/dag/use-graph-auto-layout.ts | 2 +-
.../src/views/projects/workflow/definition/detail/index.tsx | 10 ++++++++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git
a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx
b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx
index 9d419f2657..b573ed3f38 100644
--- a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx
+++ b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx
@@ -89,6 +89,7 @@ export default defineComponent({
const graph = ref<Graph>()
provide('graph', graph)
+ context.expose(graph)
// Auto layout modal
const {
diff --git
a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts
b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts
index de3301829c..853e7adc63 100644
---
a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts
+++
b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts
@@ -80,7 +80,7 @@ export function useGraphAutoLayout(options: Options) {
* @returns
*/
function format(layoutConfig: LayoutConfig) {
- if (!layoutConfig) {
+ if (Object.keys(layoutConfig).length === 0) {
layoutConfig = DEFAULT_LAYOUT_CONFIG
}
const graph = graphRef?.value
diff --git
a/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx
b/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx
index 1da1c34774..8a090f5b09 100644
---
a/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx
+++
b/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx
@@ -33,6 +33,7 @@ import {
Location
} from '../../components/dag/types'
import Styles from './index.module.scss'
+import { useGraphAutoLayout } from '../../components/dag/use-graph-auto-layout'
interface SaveData {
saveForm: SaveForm
@@ -55,6 +56,7 @@ export default defineComponent({
const definition = ref<WorkflowDefinition>()
const readonly = ref(false)
const isLoading = ref(true)
+ const dagRef = ref()
const refresh = () => {
isLoading.value = true
@@ -62,6 +64,13 @@ export default defineComponent({
readonly.value = res.processDefinition.releaseState === 'ONLINE'
definition.value = res
isLoading.value = false
+ if (!res.processDefinition.locations) {
+ setTimeout(() => {
+ const graph = dagRef.value
+ const { submit } = useGraphAutoLayout({ graph })
+ submit()
+ }, 1000)
+ }
})
}
@@ -115,6 +124,7 @@ export default defineComponent({
>
{!isLoading.value && (
<Dag
+ ref={dagRef}
definition={definition.value}
onRefresh={refresh}
projectCode={projectCode}