Skip to content

Commit

Permalink
lint and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranMn committed Jan 13, 2025
1 parent 005aac0 commit 1ec9287
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type {
TextCell,
} from "@glideapps/glide-data-grid";
import { GridCellKind } from "@glideapps/glide-data-grid";
import {
ArrowRightRegularIcon,
IconButton,
LoadingSpinner,
Select,
} from "@hashintel/design-system";
// import {
// ArrowRightRegularIcon,
// IconButton,
// LoadingSpinner,
// Select,
// } from "@hashintel/design-system";
import type { EntityId } from "@local/hash-graph-types/entity";
import { isBaseUrl } from "@local/hash-graph-types/ontology";
import { stringifyPropertyValue } from "@local/hash-isomorphic-utils/stringify-property-value";
Expand All @@ -38,7 +38,7 @@ import type { CustomIcon } from "../../../components/grid/utils/custom-grid-icon
import type { ColumnFilter } from "../../../components/grid/utils/filtering";
import { tableContentSx } from "../../../shared/table-content";
import type { FilterState } from "../../../shared/table-header";
import { MenuItem } from "../../../shared/ui/menu-item";
// import { MenuItem } from "../../../shared/ui/menu-item";
import { isAiMachineActor } from "../../../shared/use-actors";
import type { ChipCellProps } from "../chip-cell";
import { createRenderChipCell } from "../chip-cell";
Expand Down Expand Up @@ -95,15 +95,15 @@ export const EntitiesTable: FunctionComponent<
hasSomeLinks: boolean;
hidePropertiesColumns?: boolean;
hideColumns?: (keyof EntitiesTableRow)[];
limit: number;
// limit: number;
loading: boolean;
loadingComponent: ReactElement;
isViewingOnlyPages: boolean;
maxHeight: string | number;
goToNextPage?: () => void;
// goToNextPage?: () => void;
readonly?: boolean;
selectedRows: EntitiesTableRow[];
setLimit: (limit: number) => void;
// setLimit: (limit: number) => void;
setSelectedRows: (rows: EntitiesTableRow[]) => void;
setSelectedEntityType: (params: { entityTypeId: VersionedUrl }) => void;
setShowSearch: (showSearch: boolean) => void;
Expand All @@ -124,15 +124,15 @@ export const EntitiesTable: FunctionComponent<
handleEntityClick,
hideColumns,
hidePropertiesColumns = false,
limit,
// limit,
loading: entityDataLoading,
loadingComponent,
isViewingOnlyPages,
maxHeight,
goToNextPage,
// goToNextPage,
propertyTypes,
readonly,
setLimit,
// setLimit,
selectedRows,
setSelectedRows,
showSearch,
Expand Down Expand Up @@ -633,6 +633,15 @@ export const EntitiesTable: FunctionComponent<
);
}

console.log(

Check failure on line 636 in apps/hash-frontend/src/pages/shared/entities-visualizer/entities-table.tsx

View workflow job for this annotation

GitHub Actions / Package (@apps/hash-frontend)

Unexpected console statement
JSON.stringify({
rows: rows.length,
tableData: !!tableData,
entityDataLoading,
tableDataCalculating,
}),
);

return (
<Stack gap={1}>
<Grid
Expand All @@ -645,7 +654,7 @@ export const EntitiesTable: FunctionComponent<
createRenderUrlCell({ firstColumnLeftPadding }),
createRenderChipCell({ firstColumnLeftPadding }),
]}
dataLoading={entityDataLoading}
dataLoading={entityDataLoading || tableDataCalculating}
enableCheckboxSelection={!readonly}
firstColumnLeftPadding={firstColumnLeftPadding}
freezeColumns={1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ export const useEntitiesTable = (
if (isGenerateEntitiesTableDataResultMessage(data)) {
const { done, requestId, result } = data;

setWaitingTableData(false);

if (accumulatedDataRef.current.requestId !== requestId) {
accumulatedDataRef.current = { requestId, rows: result.rows };
} else {
Expand All @@ -313,6 +311,8 @@ export const useEntitiesTable = (
},
rows: accumulatedDataRef.current.rows,
});
setWaitingTableData(false);

accumulatedDataRef.current.rows = [];
}
}
Expand All @@ -327,6 +327,9 @@ export const useEntitiesTable = (
throw new Error("No worker available");
}

setTableData(null);
setWaitingTableData(true);

worker.postMessage({
type: "generateEntitiesTableData",
params: {
Expand Down Expand Up @@ -366,6 +369,6 @@ export const useEntitiesTable = (

return {
tableData,
loading: waitingTableData,
loading: waitingTableData || actorsLoading,
};
};
4 changes: 2 additions & 2 deletions apps/hash-frontend/src/shared/table-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const TableHeader = <R extends GridRow>({

if (typeof value === "string") {
return value;
} else if (key === "lastEditedBy") {
} else if (key === "lastEditedBy" || key === "createdBy") {
const user = value as MinimalUser | undefined;

return user?.displayName ?? "";
Expand Down Expand Up @@ -379,7 +379,7 @@ export const TableHeader = <R extends GridRow>({
/**
* @todo H-3909 full text search via API
*/
<Tooltip title="Search for text in visible rows">
<Tooltip title="Search for text in visible rows" placement="top">
<IconButton onClick={toggleSearch}>
<MagnifyingGlassRegularIcon />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tooltip } from "@mui/material";
import { unparse } from "papaparse";
import type { FunctionComponent } from "react";
import { useCallback } from "react";
Expand Down Expand Up @@ -44,6 +45,8 @@ export const ExportToCsvButton: FunctionComponent<{
}, [generateCsvFile]);

return (
<TableHeaderButton onClick={handleExportToCsv}>Export</TableHeaderButton>
<Tooltip title="Export the visible rows to CSV" placement="top">
<TableHeaderButton onClick={handleExportToCsv}>Export</TableHeaderButton>
</Tooltip>
);
};

0 comments on commit 1ec9287

Please sign in to comment.