Skip to content

Commit

Permalink
Add refetch button to audit log, format extra (apache#38276)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbovenzi authored Mar 19, 2024
1 parent 99e0d43 commit 6934b46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion airflow/www/static/js/components/NewTable/NewCells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ export const TimeCell = ({ getValue }: any) => {

export const CodeCell = ({ getValue }: any) => {
const value = getValue();
return value ? <Code>{JSON.stringify(value)}</Code> : null;
const code = typeof value === "string" ? JSON.parse(value) : value;
return code ? <Code>{JSON.stringify(code)}</Code> : null;
};
15 changes: 13 additions & 2 deletions airflow/www/static/js/dag/details/AuditLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
FormLabel,
Input,
HStack,
Button,
} from "@chakra-ui/react";
import { createColumnHelper } from "@tanstack/react-table";
import { snakeCase } from "lodash";
Expand All @@ -40,6 +41,7 @@ import type { EventLog } from "src/types/api-generated";
import { NewTable } from "src/components/NewTable/NewTable";
import { useTableURLState } from "src/components/NewTable/useTableUrlState";
import { CodeCell, TimeCell } from "src/components/NewTable/NewCells";
import { MdRefresh } from "react-icons/md";

interface Props {
taskId?: string;
Expand All @@ -60,7 +62,7 @@ const AuditLog = ({ taskId, run }: Props) => {
const sort = tableURLState.sorting[0];
const orderBy = sort ? `${sort.desc ? "-" : ""}${snakeCase(sort.id)}` : "";

const { data, isLoading, isFetching } = useEventLogs({
const { data, isLoading, isFetching, refetch } = useEventLogs({
dagId,
taskId,
runId: run?.runId || undefined,
Expand Down Expand Up @@ -121,7 +123,16 @@ const AuditLog = ({ taskId, run }: Props) => {
ref={logRef}
overflowY="auto"
>
<Flex justifyContent="right">
<Flex justifyContent="right" mb={2}>
<Button
leftIcon={<MdRefresh />}
onClick={() => refetch()}
variant="outline"
colorScheme="blue"
mr={2}
>
Refresh
</Button>
<LinkButton href={getMetaValue("audit_log_url")}>
View full cluster Audit Log
</LinkButton>
Expand Down

0 comments on commit 6934b46

Please sign in to comment.