Skip to content

Commit

Permalink
feat(logs): add view button and wrap text in user request log
Browse files Browse the repository at this point in the history
  • Loading branch information
use-tusk[bot] authored Jun 13, 2024
1 parent 156782d commit d67471d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 3 additions & 1 deletion web/components/shared/themed/table/requestRowView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const RequestRowView = (props: RequestRowViewProps) => {

{selectedRow ? (
<div className="flex flex-col space-y-2 w-full h-full overflow-auto">
{selectedRow.render()}
<div className="whitespace-pre-wrap break-words">
{selectedRow.render()}
</div>
</div>
) : (
<div className="flex flex-col space-y-4 justify-center items-center h-full w-full bg-white border border-gray-300 dark:bg-black dark:border-gray-700 rounded-lg">
Expand Down
9 changes: 5 additions & 4 deletions web/components/shared/themed/table/themedTableV5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import { UIFilterRow } from "../themedAdvancedFilters";
import ThemedTableHeader from "./themedTableHeader";
import DraggableColumnHeader from "./draggableColumnHeader";
import { TimeFilter } from "../../../templates/dashboard/dashboardPage";
import { useLocalStorage } from "../../../../services/hooks/localStorage";
import RequestRowView from "./requestRowView";
import { NormalizedRequest } from "../../../templates/requestsV2/builder/abstractRequestBuilder";
import { OrganizationFilter } from "../../../../services/lib/organization_layout/organization_layout";
import { RequestViews } from "./viewButton";

interface ThemedTableV5Props<T> {
defaultData: T[];
Expand Down Expand Up @@ -68,6 +68,7 @@ interface ThemedTableV5Props<T> {
onSaveFilterCallback?: () => void;
layoutPage: "dashboard" | "requests";
};
view: RequestViews;
}

export type RequestViews = "table" | "card" | "row";
Expand All @@ -89,13 +90,13 @@ export default function ThemedTableV5<T>(props: ThemedTableV5Props<T>) {
noDataCTA,
onDataSet: onDataSet,
savedFilters,
view,
} = props;

const [visibleColumns, setVisibleColumns] = useState<VisibilityState>({});
const [columnOrder, setColumnOrder] = useState<ColumnOrderState>(
defaultColumns.map((column) => column.id as string) // must start out with populated columnOrder so we can splice
defaultColumns.map((column) => column.id as string)
);
const [view, setView] = useLocalStorage<RequestViews>("view", "table");

const onVisibilityHandler: OnChangeFn<VisibilityState> = (newState) => {
setVisibleColumns(newState);
Expand Down Expand Up @@ -167,7 +168,7 @@ export default function ThemedTableV5<T>(props: ThemedTableV5Props<T>) {
makeCard
? {
currentView: view,
onViewChange: setView,
onViewChange: () => {},
}
: undefined
}
Expand Down
4 changes: 4 additions & 0 deletions web/components/templates/requestsV2/requestsPageV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
getModelFromPath,
mapGeminiProJawn,
} from "./builder/mappers/geminiMapper";
import { RequestViews } from "../../shared/themed/table/themedTableV5";

interface RequestsPageV2Props {
currentPage: number;
Expand All @@ -54,6 +55,7 @@ interface RequestsPageV2Props {
currentFilter: OrganizationFilter | null;
organizationLayout: OrganizationLayout | null;
organizationLayoutAvailable: boolean;
view: RequestViews;
}

function getSortLeaf(
Expand Down Expand Up @@ -101,6 +103,7 @@ const RequestsPageV2 = (props: RequestsPageV2Props) => {
currentFilter,
organizationLayout,
organizationLayoutAvailable,
view,
} = props;
const [isLive, setIsLive] = useLocalStorage("isLive", false);
const jawn = useJawnClient();
Expand Down Expand Up @@ -593,6 +596,7 @@ const RequestsPageV2 = (props: RequestsPageV2Props) => {
properties: properties,
}
}
view={view}
/>
<TableFooter
currentPage={currentPage}
Expand Down
11 changes: 11 additions & 0 deletions web/components/templates/users/id/userIdPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
} from "@heroicons/react/24/outline";
import { useRouter } from "next/router";
import HcBreadcrumb from "../../../ui/hcBreadcrumb";
import { useState } from "react";
import ViewButton from "../../../shared/themed/table/viewButton";

interface UserIdPageProps {
userId: string;
Expand Down Expand Up @@ -46,6 +48,7 @@ const UserIdPage = (props: UserIdPageProps) => {

const { user, isLoading, costOverTime, requestOverTime } = useUserId(userId);
const router = useRouter();
const [selectedView, setSelectedView] = useState<RequestViews>("row");

return (
<>
Expand Down Expand Up @@ -200,6 +203,14 @@ const UserIdPage = (props: UserIdPageProps) => {
</TabPanel>
<TabPanel>
<div className="py-2">
<div className="flex justify-end mb-4">
<ViewButton
currentView={selectedView}
onViewChange={(view) => {
setSelectedView(view);
}}
/>
</div>
<RequestsPageV2
currentPage={1}
pageSize={25}
Expand Down

0 comments on commit d67471d

Please sign in to comment.