Skip to content

Commit

Permalink
fix: styling and hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren committed Oct 13, 2024
1 parent 775da6d commit cd95ea0
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 29 deletions.
4 changes: 4 additions & 0 deletions keep-ui/app/incidents/[id]/incident-activity.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
outline: unset !important;
}

li[class^="VerticalItemWrapper-"] {
margin: unset !important;
}

[class^="TimelineTitleWrapper-"] {
display: none !important;
}
Expand Down
2 changes: 1 addition & 1 deletion keep-ui/app/incidents/[id]/incident-activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default function IncidentActivity({
: alerts?.items.find(
(a) => a.fingerprint === auditEvent.fingerprint
),
text: auditEvent.description,
text: _type === "comment" ? auditEvent.description : "",
timestamp: auditEvent.timestamp,
} as IncidentActivity;
}) || [];
Expand Down
23 changes: 16 additions & 7 deletions keep-ui/app/topology/model/useTopology.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TopologyService } from "@/app/topology/model/models";
import { useSession } from "next-auth/react";
import useSWR from "swr";
import useSWR, { SWRConfiguration } from "swr";
import { getApiURL } from "@/utils/apiUrl";
import { fetcher } from "@/utils/fetcher";
import { useEffect } from "react";
Expand All @@ -14,15 +14,23 @@ type UseTopologyOptions = {
services?: string[];
environment?: string;
initialData?: TopologyService[];
options?: SWRConfiguration;
};

// TODO: ensure that hook is memoized so could be used multiple times in the tree without rerenders
export const useTopology = ({
providerIds,
services,
environment,
initialData: fallbackData,
}: UseTopologyOptions = {}) => {
export const useTopology = (
{
providerIds,
services,
environment,
initialData: fallbackData,
options,
}: UseTopologyOptions = {
options: {
revalidateOnFocus: false,
},
}
) => {
const { data: session } = useSession();
const pollTopology = useTopologyPollingContext();

Expand All @@ -35,6 +43,7 @@ export const useTopology = ({
(url: string) => fetcher(url, session!.accessToken),
{
fallbackData,
...options,
}
);

Expand Down
14 changes: 10 additions & 4 deletions keep-ui/app/topology/model/useTopologyApplications.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TopologyApplication } from "./models";
import { getApiURL } from "@/utils/apiUrl";
import useSWR from "swr";
import useSWR, { SWRConfiguration } from "swr";
import { fetcher } from "@/utils/fetcher";
import { useSession } from "next-auth/react";
import { useCallback, useMemo } from "react";
Expand All @@ -9,11 +9,16 @@ import { useRevalidateMultiple } from "@/utils/state";

type UseTopologyApplicationsOptions = {
initialData?: TopologyApplication[];
options?: SWRConfiguration;
};

export function useTopologyApplications({
initialData,
}: UseTopologyApplicationsOptions = {}) {
export function useTopologyApplications(
{ initialData, options }: UseTopologyApplicationsOptions = {
options: {
revalidateOnFocus: false,
},
}
) {
const apiUrl = getApiURL();
const { data: session } = useSession();
const revalidateMultiple = useRevalidateMultiple();
Expand All @@ -24,6 +29,7 @@ export function useTopologyApplications({
(url: string) => fetcher(url, session!.accessToken),
{
fallbackData: initialData,
...options,
}
);

Expand Down
9 changes: 7 additions & 2 deletions keep-ui/utils/hooks/useAlerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export const useAlerts = () => {

const useMultipleFingerprintsAlertAudit = (
fingerprints: string[] | undefined,
options: SWRConfiguration = { revalidateOnFocus: true }
options: SWRConfiguration = {
revalidateOnFocus: true,
revalidateOnMount: false,
}
) => {
return useSWR<AuditEvent[]>(
() =>
Expand All @@ -112,7 +115,9 @@ export const useAlerts = () => {

const useAlertAudit = (
fingerprint: string,
options: SWRConfiguration = { revalidateOnFocus: false }
options: SWRConfiguration = {
revalidateOnFocus: false,
}
) => {
return useSWR<AuditEvent[]>(
() =>
Expand Down
5 changes: 4 additions & 1 deletion keep-ui/utils/hooks/useDashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export const useDashboards = () => {

const { data, error, mutate } = useSWR<Dashboard[]>(
session ? `${apiUrl}/dashboard` : null,
(url: string) => fetcher(url, session!.accessToken)
(url: string) => fetcher(url, session!.accessToken),
{
revalidateOnFocus: false,
}
);

return {
Expand Down
24 changes: 11 additions & 13 deletions keep-ui/utils/hooks/useIncidents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
IncidentDto,
IncidentsMetaDto,
PaginatedIncidentAlertsDto,
PaginatedIncidentsDto
PaginatedIncidentsDto,
} from "../../app/incidents/models";
import { PaginatedWorkflowExecutionDto } from "app/workflows/builder/types";
import { useSession } from "next-auth/react";
Expand All @@ -17,11 +17,11 @@ interface IncidentUpdatePayload {
}

interface Filters {
status: string[],
severity: string[],
assignees: string[]
sources: string[],
affected_services: string[],
status: string[];
severity: string[];
assignees: string[];
sources: string[];
affected_services: string[];
}

export const useIncidents = (
Expand All @@ -32,7 +32,7 @@ export const useIncidents = (
filters: Filters | {} = {},
options: SWRConfiguration = {
revalidateOnFocus: false,
},
}
) => {
const apiUrl = getApiURL();
const { data: session } = useSession();
Expand All @@ -44,13 +44,11 @@ export const useIncidents = (
filtersParams.delete(key as string);
} else {
value.forEach((s: string) => {
filtersParams.append(key, s)
filtersParams.append(key, s);
});
}
});

console.log(filters);

return useSWR<PaginatedIncidentsDto>(
() =>
session
Expand Down Expand Up @@ -93,7 +91,8 @@ export const useIncidentFutureIncidents = (
const { data: session } = useSession();

return useSWR<PaginatedIncidentsDto>(
() => (session ? `${apiUrl}/incidents/${incidentId}/future_incidents` : null),
() =>
session ? `${apiUrl}/incidents/${incidentId}/future_incidents` : null,
(url) => fetcher(url, session?.accessToken),
options
);
Expand Down Expand Up @@ -169,7 +168,6 @@ export const usePollIncidents = (mutateIncidents: any) => {
}, [bind, unbind, handleIncoming]);
};


export const useIncidentsMeta = (
options: SWRConfiguration = {
revalidateOnFocus: false,
Expand All @@ -183,4 +181,4 @@ export const useIncidentsMeta = (
(url) => fetcher(url, session?.accessToken),
options
);
};
};
6 changes: 5 additions & 1 deletion keep-ui/utils/hooks/useWorkflowExecutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import useSWR, { SWRConfiguration } from "swr";
import { getApiURL } from "utils/apiUrl";
import { fetcher } from "utils/fetcher";

export const useWorkflowExecutions = (options?: SWRConfiguration) => {
export const useWorkflowExecutions = (
options: SWRConfiguration = {
revalidateOnFocus: false,
}
) => {
const apiUrl = getApiURL();
const { data: session } = useSession();

Expand Down

0 comments on commit cd95ea0

Please sign in to comment.