Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ export const actions = addPrefix(ACTION_PREFIX, {
OPEN_DASHBOARD: "OPEN_DASHBOARD",
OPEN_INSTALLATION_WIZARD: "OPEN_INSTALLATION_WIZARD",
SET_SCOPE: "SET_SCOPE",
CHANGE_SCOPE: "CHANGE_SCOPE",
SET_STATE: "SET_STATE"
});
11 changes: 8 additions & 3 deletions src/components/Assets/AssetsFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const AssetsFilter = (props: AssetsFilterProps) => {
const [selectedInsights, setSelectedInsights] = useState<InsightType[]>([]);
const config = useContext(ConfigContext);
const previousEnvironment = usePrevious(config.environment);
const previousScope = usePrevious(config.scope);

const getData = (
services: string[],
Expand Down Expand Up @@ -135,8 +136,10 @@ export const AssetsFilter = (props: AssetsFilterProps) => {

useEffect(() => {
if (
isEnvironment(previousEnvironment) &&
previousEnvironment.originalName !== config.environment?.originalName
(isEnvironment(previousEnvironment) &&
previousEnvironment.originalName !==
config.environment?.originalName) ||
(previousScope && previousScope !== config.scope)
) {
const defaultFilters = {
services: [],
Expand All @@ -151,7 +154,9 @@ export const AssetsFilter = (props: AssetsFilterProps) => {
previousEnvironment,
config.environment,
setPersistedFilters,
props.onApply
props.onApply,
previousScope,
config.scope
]);

useEffect(() => {
Expand Down
24 changes: 10 additions & 14 deletions src/components/Assets/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ChangeEvent,
useContext,
useEffect,
useLayoutEffect,
Expand All @@ -16,7 +15,7 @@ import { usePrevious } from "../../hooks/usePrevious";
import { FeatureFlag } from "../../types";
import { ConfigContext } from "../common/App/ConfigContext";
import { EmptyState } from "../common/EmptyState";
import { MagnifierIcon } from "../common/icons/MagnifierIcon";
import { SearchInput } from "../common/SearchInput";
import { AssetList } from "./AssetList";
import { AssetTypeList } from "./AssetTypeList";
import { AssetsFilter } from "./AssetsFilter";
Expand Down Expand Up @@ -79,17 +78,19 @@ export const Assets = () => {
}, [config.scope]);

useEffect(() => {
if (previousScope !== config.scope?.span) {
if (!previousScope || previousScope !== config.scope?.span) {
setSelectedAssetTypeId(null);
setSearchInputValue("");
setSelectedServices([]);
}
}, [config.scope, previousScope]);

const handleBackButtonClick = () => {
setSelectedAssetTypeId(null);
};

const handleSearchInputChange = (e: ChangeEvent<HTMLInputElement>) => {
setSearchInputValue(e.target.value);
const handleSearchInputChange = (val: string | null) => {
setSearchInputValue(val || "");
};

const handleAssetTypeSelect = (assetTypeId: string) => {
Expand Down Expand Up @@ -155,15 +156,10 @@ export const Assets = () => {
<s.HeaderItem>
Assets
{window.assetsSearch === true && (
<s.SearchInputContainer>
<s.SearchInputIconContainer>
<MagnifierIcon color={"currentColor"} size={14} />
</s.SearchInputIconContainer>
<s.SearchInput
placeholder={"Search"}
onChange={handleSearchInputChange}
/>
</s.SearchInputContainer>
<SearchInput
onChange={handleSearchInputChange}
value={searchInputValue}
/>
)}
{isComplexFilterEnabled ? (
<AssetsFilter
Expand Down
2 changes: 1 addition & 1 deletion src/components/Insights/BottleneckInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const BottleneckInsight = (props: BottleneckInsightProps) => {

return (
<InsightCard
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
data={props.insight}
content={
<>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Insights/DurationBreakdownInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const DurationBreakdownInsight = (
return (
<InsightCard
data={props.insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
content={
<s.EntryList>
{pageItems.map((entry) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Insights/DurationInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export const DurationInsight = (props: DurationInsightProps) => {
return (
<InsightCard
data={props.insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
isRecent={isLastCallRecent}
content={
<s.Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const DurationSlowdownSourceInsight = (
return (
<InsightCard
data={props.insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
content={
<s.Container>
<Description>Found spans slowing the endpoint</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Insights/EndpointNPlusOneInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const EndpointNPlusOneInsight = (
return (
<InsightCard
data={props.insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
content={
<s.ContentContainer>
<Description>Check the following locations:</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const EndpointQueryOptimizationInsight = (
return (
<InsightCard
data={props.insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
content={
<s.ContentContainer>
<Description>Check the following locations:</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Insights/ExcessiveAPICallsInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ExcessiveAPICallsInsight = (
return (
<InsightCard
data={props.insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
content={
<s.ContentContainer>
<Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const HighNumberOfQueriesInsight = (
return (
<InsightCard
data={insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
content={
<s.ContentContainer>
<Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
title: "asdasdasd",
data: {
firstDetected: "2023-12-05T17:25:47.010Z",
lastDetected: "2024-01-05T13:14:47.010Z",
Expand Down
20 changes: 18 additions & 2 deletions src/components/Insights/InsightCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useContext, useState } from "react";
import { useTheme } from "styled-components";
import { actions } from "../../../actions";
import { PERCENTILES } from "../../../constants";
import { isString } from "../../../typeGuards/isString";
import { formatTimeDistance } from "../../../utils/formatTimeDistance";
Expand Down Expand Up @@ -123,16 +124,31 @@ export const InsightCard = (props: InsightCardProps) => {
IS_NEW_TIME_LIMIT
: false;

const handleLinkClick = (spanCodeObjectId?: string) => {
if (spanCodeObjectId) {
window.sendMessageToDigma({
action: actions.CHANGE_SCOPE,
payload: {
span: spanCodeObjectId
}
});
}
};

return (
<>
<Card
showTitle={!!(props.title && !scope?.span)}
showTitle={!!(props.spanInfo?.displayName && !scope?.span)}
title={
<s.Title>
<s.TitleIcon>
<OpenTelemetryLogoSmallIcon color="#6063F6" size={16} />
</s.TitleIcon>
<s.TitleText>{props.title}</s.TitleText>
<s.Link
onClick={() => handleLinkClick(props.spanInfo?.spanCodeObjectId)}
>
{props.spanInfo?.displayName}
</s.Link>
</s.Title>
}
header={
Expand Down
12 changes: 7 additions & 5 deletions src/components/Insights/InsightCard/styles.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import styled from "styled-components";
import { Link } from "../styles";

export const TitleIcon = styled.div`
display: flex;
`;

export const TitleText = styled.div`
fill: #a1b5ff;
export const Link = styled.a`
color: #7891d0;
text-decoration: none;
font-weight: 500;
font-size: 14px;
cursor: pointer;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: block;
overflow: hidden;
`;

export const Title = styled.div`
Expand Down
4 changes: 2 additions & 2 deletions src/components/Insights/InsightCard/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactNode } from "react";
import { InsightType } from "../../../types";
import { InsightType, SpanInfo } from "../../../types";
import { GenericCodeObjectInsight } from "../types";

export interface InsightCardProps {
Expand All @@ -9,7 +9,6 @@ export interface InsightCardProps {
menuItems?: string[];
stats?: string;
buttons?: ReactNode[];
title?: string;
onRecalculate: (
prefixedCodeObjectId: string,
insightType: InsightType
Expand All @@ -18,6 +17,7 @@ export interface InsightCardProps {
isRecent?: boolean;
onRefresh: (insightType: InsightType) => void;
isAsync?: boolean;
spanInfo?: SpanInfo | null;
}

export interface PercentileViewModeOptionProps {
Expand Down
24 changes: 16 additions & 8 deletions src/components/Insights/InsightsCatalog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { usePrevious } from "../../../hooks/usePrevious";

import { useDebounce } from "../../../hooks/useDebounce";
import { isNumber } from "../../../typeGuards/isNumber";
import { Pagination } from "../../common/Pagination";
import { SearchInput } from "../../common/SearchInput";
Expand All @@ -15,44 +16,51 @@ export const InsightsCatalog = (props: InsightsCatalogProps) => {
const { insights, onJiraTicketCreate, defaultQuery, totalCount } = props;
const [page, setPage] = useState(0);
const previousPage = usePrevious(page);
const [searchInputValue, setSearchInputValue] = useState<string | null>(
const [searchInputValue, setSearchInputValue] = useState(
defaultQuery.searchQuery
);
const debouncedSearchInputValue = useDebounce(searchInputValue, 1000);
const [sorting, setSorting] = useState<Sorting>(defaultQuery.sorting);
const previousSorting = usePrevious(sorting);
const previousSearchQuery = usePrevious(searchInputValue);
const previousSearchQuery = usePrevious(debouncedSearchInputValue);
const pageStartItemNumber = page * PAGE_SIZE + 1;
const pageEndItemNumber = Math.min(
pageStartItemNumber + PAGE_SIZE - 1,
totalCount
);

useEffect(() => {
if (previousPage !== page) {
window.scrollTo(0, 0);
}
}, [previousPage, page]);

useEffect(() => {
props.onQueryChange({
page,
sorting,
searchQuery: searchInputValue
searchQuery: debouncedSearchInputValue
});
}, []);

useEffect(() => {
if (
(isNumber(previousPage) && previousPage !== page) ||
(previousSorting && previousSorting !== sorting) ||
previousSearchQuery !== searchInputValue
previousSearchQuery !== debouncedSearchInputValue
) {
props.onQueryChange({
page,
sorting,
searchQuery: searchInputValue
searchQuery: debouncedSearchInputValue
});
}
}, [
previousSorting,
sorting,
previousPage,
page,
searchInputValue,
debouncedSearchInputValue,
previousSearchQuery
]);

Expand All @@ -63,7 +71,7 @@ export const InsightsCatalog = (props: InsightsCatalogProps) => {
onChange={(val: string | null) => {
setSearchInputValue(val);
}}
default={defaultQuery.searchQuery}
value={searchInputValue}
/>
<SortingSelector
onChange={(val: Sorting) => {
Expand All @@ -86,7 +94,7 @@ export const InsightsCatalog = (props: InsightsCatalogProps) => {
</s.Toolbar>
<InsightsPage
insights={insights}
isFilteringEnabled={searchInputValue !== null}
isFilteringEnabled={debouncedSearchInputValue !== null}
onJiraTicketCreate={onJiraTicketCreate}
onRefresh={props.onRefresh}
/>
Expand Down
8 changes: 0 additions & 8 deletions src/components/Insights/InsightsPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect } from "react";
import { v4 as uuidv4 } from "uuid";
import { usePersistence } from "../../../hooks/usePersistence";
import { usePrevious } from "../../../hooks/usePrevious";
import { trackingEvents as globalTrackingEvents } from "../../../trackingEvents";
import { isUndefined } from "../../../typeGuards/isUndefined";
import { InsightType } from "../../../types";
Expand Down Expand Up @@ -473,7 +472,6 @@ const IS_INSIGHT_JIRA_TICKET_HINT_SHOWN_PERSISTENCE_KEY =
"isInsightJiraTicketHintShown";

export const InsightsPage = (props: InsightPageProps) => {
const previousInsights = usePrevious(props.insights);
const [isInsightJiraTicketHintShown, setIsInsightJiraTicketHintShown] =
usePersistence<isInsightJiraTicketHintShownPayload>(
IS_INSIGHT_JIRA_TICKET_HINT_SHOWN_PERSISTENCE_KEY,
Expand All @@ -482,12 +480,6 @@ export const InsightsPage = (props: InsightPageProps) => {

const insightIndexWithJiraHint = getInsightToShowJiraHint(props.insights);

useEffect(() => {
if (props.insights !== previousInsights) {
window.scrollTo(0, 0);
}
}, [props.insights, previousInsights]);

useEffect(() => {
window.sendMessageToDigma({
action: actions.MARK_INSIGHT_TYPES_AS_VIEWED,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Insights/NPlusOneInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const NPlusOneInsight = (props: NPlusOneInsightProps) => {
return (
<InsightCard
data={props.insight}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
content={
<s.ContentContainer>
<Description>Check the following SELECT statement:</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Insights/NoScalingIssueInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const NoScalingIssueInsight = (props: NoScalingIssueInsightProps) => {
return (
<InsightCard
key={props.insight.type}
title={props.insight.spanInfo?.displayName}
spanInfo={props.insight.spanInfo}
data={props.insight}
content={<div>This code is scaling well at concurrent executions</div>}
buttons={[
Expand Down
Loading