Skip to content
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

Standardize the column names on Events tabs #4055

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 45 additions & 40 deletions ui/components/EventsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { CircularProgress } from "@material-ui/core";
import * as React from "react";
import styled from "styled-components";
import { useListEvents } from "../hooks/events";
import { Event, ObjectRef } from "../lib/api/core/types.pb";
import Alert from "./Alert";
import DataTable from "./DataTable";
import Flex from "./Flex";
import Spacer from "./Spacer";
import Icon, { IconType } from "./Icon";
import RequestStateHandler from "./RequestStateHandler";
import Text from "./Text";
import Timestamp from "./Timestamp";

Expand All @@ -19,43 +17,44 @@ type Props = {
function EventsTable({ className, involvedObject }: Props) {
const { data, isLoading, error } = useListEvents(involvedObject);

if (isLoading) {
return (
<Flex wide center align>
<CircularProgress />
</Flex>
);
}

if (error) {
return (
<Spacer padding="small">
<Alert title="Error" message={error.message} severity="error" />
</Spacer>
);
}

return (
<DataTable
className={className}
fields={[
{
value: (e: Event) => <Text capitalize>{e.reason}</Text>,
label: "Reason",
sortValue: (e: Event) => e.reason,
},
{ value: "message", label: "Message", maxWidth: 600 },
{ value: "component", label: "Component" },
{
label: "Timestamp",
value: (e: Event) => <Timestamp time={e.timestamp} />,
sortValue: (e: Event) => -Date.parse(e.timestamp),
defaultSort: true,
secondarySort: true,
},
]}
rows={data.events}
/>
<RequestStateHandler loading={isLoading} error={error}>
<DataTable
className={className}
fields={[
{
label: "Reason",
labelRenderer: () => {
return (
<h2
className="reason"
title="This refers to what triggered the event, and can vary by component."
>
Reason
<Icon
size="base"
type={IconType.InfoIcon}
color="neutral30"
/>
</h2>
);
},
value: (e: Event) => <Text capitalize>{e.reason}</Text>,
sortValue: (e: Event) => e.reason,
},
{ label: "Message", value: "message", maxWidth: 600 },
{ label: "From", value: "component" },
{
label: "Last Updated",
value: (e: Event) => <Timestamp time={e.timestamp} />,
sortValue: (e: Event) => -Date.parse(e.timestamp),
defaultSort: true,
secondarySort: true,
},
]}
rows={data?.events}
/>
</RequestStateHandler>
);
}

Expand All @@ -69,4 +68,10 @@ export default styled(EventsTable).attrs({ className: EventsTable.name })`
word-wrap: break-word;
}
}
.reason {
display: flex;
align-items: center;
gap: 8px;
padding: 16px !important;
}
`;
Loading