Skip to content

Commit fbd6820

Browse files
committed
fix query key
tidy up audit log searches page
1 parent ff507f8 commit fbd6820

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

src/hooks/use-guid-resolver.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ const findGuids = (obj, guidsSet = new Set(), partnerGuidsMap = new Map()) => {
9898
return { guidsSet, partnerGuidsMap };
9999
};
100100

101-
export const useGuidResolver = () => {
101+
export const useGuidResolver = (manualTenant = null) => {
102102
const tenantFilter = useSettings().currentTenant;
103+
const activeTenant = manualTenant || tenantFilter;
103104

104105
// GUID resolution state
105106
const [guidMapping, setGuidMapping] = useState({});
@@ -195,7 +196,7 @@ export const useGuidResolver = () => {
195196
directoryObjectsMutation.mutate({
196197
url: "/api/ListDirectoryObjects",
197198
data: {
198-
tenantFilter: tenantFilter,
199+
tenantFilter: activeTenant,
199200
ids: guidsToSend,
200201
$select: "id,displayName,userPrincipalName,mail",
201202
},
@@ -249,7 +250,7 @@ export const useGuidResolver = () => {
249250
setIsLoadingGuids(false);
250251
}
251252
},
252-
[guidMapping, tenantFilter] // Only depend on guidMapping and tenantFilter
253+
[guidMapping, activeTenant] // Only depend on guidMapping and activeTenant
253254
);
254255

255256
return {

src/pages/tenant/administration/audit-logs/search-results.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { useRouter } from "next/router";
22
import { useState, useEffect } from "react";
33
import { Layout as DashboardLayout } from "/src/layouts/index.js";
4-
import { TabbedLayout } from "/src/layouts/TabbedLayout";
54
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx";
6-
import { EyeIcon } from "@heroicons/react/24/outline";
5+
import { EyeIcon, ArrowLeftIcon } from "@heroicons/react/24/outline";
76
import CippAuditLogDetails from "/src/components/CippComponents/CippAuditLogDetails.jsx";
8-
import tabOptions from "./tabOptions.json";
7+
import { Button, SvgIcon } from "@mui/material";
98

109
const searchResultsColumns = [
1110
"createdDateTime",
@@ -41,6 +40,10 @@ const Page = () => {
4140

4241
const pageTitle = searchName ? `${searchName}` : `Search Results - ${searchId}`;
4342

43+
const handleBackClick = () => {
44+
router.push("/tenant/administration/audit-logs/searches");
45+
};
46+
4447
// Define offcanvas configuration with larger size for audit log details
4548
const offcanvas = {
4649
title: "Audit Log Details",
@@ -51,6 +54,20 @@ const Page = () => {
5154
return (
5255
<CippTablePage
5356
title={pageTitle}
57+
cardButton={
58+
<Button
59+
variant="outlined"
60+
color="primary"
61+
onClick={handleBackClick}
62+
startIcon={
63+
<SvgIcon fontSize="small">
64+
<ArrowLeftIcon />
65+
</SvgIcon>
66+
}
67+
>
68+
Back to Searches
69+
</Button>
70+
}
5471
apiUrl="/api/ListAuditLogSearches"
5572
apiDataKey="Results"
5673
simpleColumns={searchResultsColumns}
@@ -65,10 +82,6 @@ const Page = () => {
6582
);
6683
};
6784

68-
Page.getLayout = (page) => (
69-
<DashboardLayout>
70-
<TabbedLayout tabOptions={tabOptions}>{page}</TabbedLayout>
71-
</DashboardLayout>
72-
);
85+
Page.getLayout = (page) => <DashboardLayout>{page}</DashboardLayout>;
7386

7487
export default Page;

src/pages/tenant/administration/audit-logs/searches.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Grid } from "@mui/system";
1212
import { Add } from "@mui/icons-material";
1313
import { useDialog } from "/src/hooks/use-dialog";
1414
import tabOptions from "./tabOptions.json";
15+
import { useSettings } from "/src/hooks/use-settings";
1516

1617
const simpleColumns = ["displayName", "status", "filterStartDateTime", "filterEndDateTime"];
1718

@@ -41,6 +42,7 @@ const actions = [
4142

4243
const Page = () => {
4344
const createSearchDialog = useDialog();
45+
const currentTenant = useSettings().currentTenant;
4446

4547
const filterControl = useForm({
4648
mode: "onChange",
@@ -460,7 +462,9 @@ const Page = () => {
460462
apiUrl={apiUrlWithFilters}
461463
apiDataKey="Results"
462464
simpleColumns={simpleColumns}
463-
queryKey="AuditLogSearches"
465+
queryKey={`AuditLogSearches-${filterControl.getValues().StatusFilter?.value || "All"}-${
466+
filterControl.getValues().DateFilter?.value || "AllTime"
467+
}-${currentTenant}`}
464468
actions={actions}
465469
cardButton={
466470
<Button

0 commit comments

Comments
 (0)