-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add asset events to dashboard #44961
base: main
Are you sure you want to change the base?
Changes from all commits
3dfcf21
94f827a
27a3f73
b26670c
f69cf68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 { Box, Text, HStack } from "@chakra-ui/react"; | ||
import { FiDatabase } from "react-icons/fi"; | ||
import { MdOutlineAccountTree } from "react-icons/md"; | ||
import { Link } from "react-router-dom"; | ||
|
||
import type { AssetEventResponse } from "openapi/requests/types.gen"; | ||
import Time from "src/components/Time"; | ||
|
||
export const AssetEvent = ({ | ||
event, | ||
}: { | ||
readonly event: AssetEventResponse; | ||
}) => { | ||
const hasDagRuns = event.created_dagruns.length > 0; | ||
const source = event.extra?.from_rest_api === true ? "API" : ""; | ||
|
||
return ( | ||
<Box fontSize={13} mt={1} w="full"> | ||
<Text fontWeight="bold"> | ||
<Time datetime={event.timestamp} /> | ||
</Text> | ||
<HStack> | ||
<FiDatabase /> <Text> {event.uri ?? ""} </Text> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likely better to use the name here, maybe we some rich UI that reveals more asset information on user interaction. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we pass name and group we can put more useful information here. And could have a tooltip to show more. |
||
</HStack> | ||
<HStack> | ||
<MdOutlineAccountTree /> <Text> Source: </Text> | ||
{source === "" ? ( | ||
<Link | ||
to={`/dags/${event.source_dag_id}/runs/${event.source_run_id}/tasks/${event.source_task_id}?map_index=${event.source_map_index}`} | ||
> | ||
<Text color="fg.info"> {event.source_dag_id} </Text> | ||
</Link> | ||
) : ( | ||
source | ||
)} | ||
</HStack> | ||
<HStack> | ||
<Text> Triggered Dag Runs: </Text> | ||
{hasDagRuns ? ( | ||
<Link | ||
to={`/dags/${event.created_dagruns[0]?.dag_id}/runs/${event.created_dagruns[0]?.run_id}`} | ||
> | ||
<Text color="fg.info"> {event.created_dagruns[0]?.dag_id} </Text> | ||
</Link> | ||
) : ( | ||
"~" | ||
)} | ||
</HStack> | ||
</Box> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/*! | ||
* 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 { | ||
Box, | ||
Heading, | ||
Flex, | ||
HStack, | ||
VStack, | ||
StackSeparator, | ||
Skeleton, | ||
} from "@chakra-ui/react"; | ||
import { createListCollection } from "@chakra-ui/react/collection"; | ||
|
||
import { useAssetServiceGetAssetEvents } from "openapi/queries"; | ||
import { MetricsBadge } from "src/components/MetricsBadge"; | ||
import { Select } from "src/components/ui"; | ||
|
||
import { AssetEvent } from "./AssetEvent"; | ||
|
||
type AssetEventProps = { | ||
readonly assetSortBy: string; | ||
readonly endDate: string; | ||
readonly setAssetSortBy: React.Dispatch<React.SetStateAction<string>>; | ||
readonly startDate: string; | ||
}; | ||
|
||
export const AssetEvents = ({ | ||
assetSortBy, | ||
endDate, | ||
setAssetSortBy, | ||
startDate, | ||
}: AssetEventProps) => { | ||
const { data, isLoading } = useAssetServiceGetAssetEvents({ | ||
limit: 6, | ||
orderBy: assetSortBy, | ||
timestampGte: startDate, | ||
timestampLte: endDate, | ||
}); | ||
|
||
const assetSortOptions = createListCollection({ | ||
items: [ | ||
{ label: "Newest first", value: "-timestamp" }, | ||
{ label: "Oldest first", value: "timestamp" }, | ||
], | ||
}); | ||
|
||
return ( | ||
<Box borderRadius={5} borderWidth={1} ml={2} pb={2}> | ||
<Flex justify="space-between" mr={1} mt={0} pl={3} pt={1}> | ||
<HStack> | ||
<MetricsBadge | ||
backgroundColor="blue.solid" | ||
runs={isLoading ? 0 : data?.total_entries} | ||
/> | ||
<Heading marginEnd="auto" size="md"> | ||
Asset Events | ||
</Heading> | ||
</HStack> | ||
<Select.Root | ||
collection={assetSortOptions} | ||
data-testid="asset-sort-duration" | ||
defaultValue={["-timestamp"]} | ||
onValueChange={(option) => setAssetSortBy(option.value[0] as string)} | ||
variant="outline" // Flushed seems to be right option to remove border but is not valid as per typescript | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this comment mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the UI design the select component has no border in asset events widget. "flushed" is a variant that achieves this effect on select but the type for select only has outline | subtle as valid values though flushed works. This can be kept outline too and would just deviate from the design. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think "flushed" is a valid or at least not a publically-supported variant. So we can remove the comment. And we can add a |
||
width={130} | ||
> | ||
<Select.Trigger> | ||
<Select.ValueText placeholder="Sort by" /> | ||
</Select.Trigger> | ||
|
||
<Select.Content> | ||
{assetSortOptions.items.map((option) => ( | ||
<Select.Item item={option} key={option.value[0]}> | ||
{option.label} | ||
</Select.Item> | ||
))} | ||
</Select.Content> | ||
</Select.Root> | ||
</Flex> | ||
{isLoading ? ( | ||
<VStack px={3} separator={<StackSeparator />}> | ||
{Array.from({ length: 5 }, (_, index) => index).map((index) => ( | ||
<Skeleton height={100} key={index} width="full" /> | ||
))} | ||
</VStack> | ||
) : ( | ||
<VStack px={3} separator={<StackSeparator />}> | ||
{data?.asset_events.map((event) => ( | ||
<AssetEvent event={event} key={event.id} /> | ||
))} | ||
</VStack> | ||
)} | ||
</Box> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're to add
uri
here, we'll probably need to addname
(and maybegroup
?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure we should add
uri
here. If we need it in the UI, it’d be better to include the entire asset object instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is as per the initial UI design for dashboard. I am okay with changing this as per consensus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The designs were quite preliminary so I am happy with adding everything suggested