Skip to content

Commit

Permalink
allow toggling top logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vish9812 committed Nov 10, 2023
1 parent 9fca680 commit fd71184
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function Filters(props: FiltersProps) {
{
field: "msg",
flex: 2,
headerCheckboxSelection: true,
checkboxSelection: true,
filter: "agTextColumnFilter",
},
Expand Down
3 changes: 3 additions & 0 deletions src/components/filters/useViewModel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describe("useViewModel", () => {
const getGrid = () => ({
api: {
deselectAll: vi.fn(),
setFilterModel: vi.fn(),
},
});
const topLogsGridRef = getGrid();
Expand All @@ -124,7 +125,9 @@ describe("useViewModel", () => {
defaultFilters
);
expect(topLogsGridRef.api.deselectAll).toHaveBeenCalledOnce();
expect(topLogsGridRef.api.setFilterModel).toHaveBeenCalledOnce();
expect(addedLogsGridRef.api.deselectAll).toHaveBeenCalledOnce();
expect(addedLogsGridRef.api.setFilterModel).toHaveBeenCalledOnce();
dispose();
});
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/filters/useViewModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ function useViewModel(props: FiltersProps) {
) {
setFilters(defaultFilters());
handleErrorsOnlyChange(false);
topLogsGridRef.api.setFilterModel(null);
topLogsGridRef.api.deselectAll();
if (addedLogs().length > 0) {
addedLogsGridRef.api.setFilterModel(null);
addedLogsGridRef.api.deselectAll();
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/normalize/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function Normalize() {
handleFileUpload,
} = useViewModel();

const newFileText = () =>
logDatas().length === 1 ? "Compare With" : "New File";

return (
<Grid container spacing={2}>
<Grid item xs={12}>
Expand All @@ -59,7 +62,7 @@ function Normalize() {
variant="contained"
startIcon={<FileUploadIcon />}
>
open file
{newFileText()}
<HiddenInput
type="file"
multiple={false}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/normalize/useViewModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function useViewModel() {
};

const handleFileUpload = async (files: FileList, logData: LogData) => {
if (!files || !files.length) return;

setProcessingFile(true);
setAnalyzeDisabled(true);

Expand Down

0 comments on commit fd71184

Please sign in to comment.