-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create dag graph with nested groups and join_ids (#44199)
* Create dag graph with nested groups and join_ids * Add edge labels, setup/teardown tasks, and mapped tasks * move all graph formatting utils inside of useGraphLayout hook * move opengroup logic to a local context provider * Add vite plugin to fix graph css * Remove commented out code
- Loading branch information
Showing
21 changed files
with
1,823 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/*! | ||
* 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 { | ||
createContext, | ||
useCallback, | ||
useMemo, | ||
type PropsWithChildren, | ||
} from "react"; | ||
import { useLocalStorage } from "usehooks-ts"; | ||
|
||
export type OpenGroupsContextType = { | ||
openGroupIds: Array<string>; | ||
setOpenGroupIds: (groupIds: Array<string>) => void; | ||
toggleGroupId: (groupId: string) => void; | ||
}; | ||
|
||
export const OpenGroupsContext = createContext< | ||
OpenGroupsContextType | undefined | ||
>(undefined); | ||
|
||
type Props = { | ||
readonly dagId: string; | ||
} & PropsWithChildren; | ||
|
||
export const OpenGroupsProvider = ({ children, dagId }: Props) => { | ||
const openGroupsKey = `${dagId}/open-groups`; | ||
const [openGroupIds, setOpenGroupIds] = useLocalStorage<Array<string>>( | ||
openGroupsKey, | ||
[], | ||
); | ||
|
||
const toggleGroupId = useCallback( | ||
(groupId: string) => { | ||
if (openGroupIds.includes(groupId)) { | ||
setOpenGroupIds(openGroupIds.filter((id) => id !== groupId)); | ||
} else { | ||
setOpenGroupIds([...openGroupIds, groupId]); | ||
} | ||
}, | ||
[openGroupIds, setOpenGroupIds], | ||
); | ||
|
||
const value = useMemo<OpenGroupsContextType>( | ||
() => ({ openGroupIds, setOpenGroupIds, toggleGroupId }), | ||
[openGroupIds, setOpenGroupIds, toggleGroupId], | ||
); | ||
|
||
return ( | ||
<OpenGroupsContext.Provider value={value}> | ||
{children} | ||
</OpenGroupsContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*! | ||
* 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 * from "./OpenGroupsProvider"; | ||
export * from "./useOpenGroups"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*! | ||
* 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 { useContext } from "react"; | ||
|
||
import { | ||
OpenGroupsContext, | ||
type OpenGroupsContextType, | ||
} from "./OpenGroupsProvider"; | ||
|
||
export const useOpenGroups = (): OpenGroupsContextType => { | ||
const context = useContext(OpenGroupsContext); | ||
|
||
if (context === undefined) { | ||
throw new Error("useOpenGroup must be used within a OpenGroupsProvider"); | ||
} | ||
|
||
return context; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*! | ||
* 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 { Heading } from "@chakra-ui/react"; | ||
|
||
import type { DAGResponse } from "openapi/requests/types.gen"; | ||
import { Dialog } from "src/components/ui"; | ||
|
||
import { Graph } from "./Graph"; | ||
|
||
type TriggerDAGModalProps = { | ||
dagDisplayName: DAGResponse["dag_display_name"]; | ||
onClose: () => void; | ||
open: boolean; | ||
}; | ||
|
||
export const DagVizModal: React.FC<TriggerDAGModalProps> = ({ | ||
dagDisplayName, | ||
onClose, | ||
open, | ||
}) => ( | ||
<Dialog.Root onOpenChange={onClose} open={open} size="full"> | ||
<Dialog.Content backdrop> | ||
<Dialog.Header bg="blue.muted"> | ||
<Heading size="xl">{dagDisplayName}</Heading> | ||
<Dialog.CloseTrigger closeButtonProps={{ size: "xl" }} /> | ||
</Dialog.Header> | ||
<Dialog.Body display="flex"> | ||
<Graph /> | ||
</Dialog.Body> | ||
</Dialog.Content> | ||
</Dialog.Root> | ||
); |
Oops, something went wrong.