Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8da2910
Add Select and Asset Filters component
kshmidt-digma Jan 23, 2024
9eabfec
Merge branch 'main' into feature/assets-filters
kshmidt-digma Jan 23, 2024
2094469
Merge branch 'main' into feature/assets-filters
kshmidt-digma Jan 27, 2024
06d28a0
Merge branch 'main' into feature/assets-filters
kshmidt-digma Jan 27, 2024
87a79da
Populate filter selects with data
kshmidt-digma Jan 29, 2024
2ea85de
Fix filters message payload
kshmidt-digma Jan 29, 2024
b888451
Merge branch 'main' into feature/assets-filters
kshmidt-digma Jan 29, 2024
3c9f6e7
Enable new filter
kshmidt-digma Jan 29, 2024
8fe31ff
Move search bar to the global level in the Assets
kshmidt-digma Jan 30, 2024
ff04781
Update styles
kshmidt-digma Jan 30, 2024
d85a2e3
Merge branch 'main' into feature/assets-filters
kshmidt-digma Jan 30, 2024
bf80654
Bump feature flag version, fix Select
kshmidt-digma Jan 30, 2024
e3928b9
Add filter refresh, handle empty response
kshmidt-digma Jan 30, 2024
27ff64c
Add API to persist data
kshmidt-digma Jan 31, 2024
9f7274a
Remove redundant util
kshmidt-digma Jan 31, 2024
49702d2
Improve filters and Select logic
kshmidt-digma Jan 31, 2024
38fbbfc
Merge branch 'feature/assets-filters' into feature/persisted-asset-fi…
kshmidt-digma Jan 31, 2024
96f08e8
Add Jira button hint popup
kshmidt-digma Jan 31, 2024
24ded42
Remove redundant attribute
kshmidt-digma Jan 31, 2024
fbd6df6
Remove redundant attribute
kshmidt-digma Jan 31, 2024
dfb74b2
Merge branch 'main' into feature/assets-filters
kshmidt-digma Jan 31, 2024
6fd1232
Merge branch 'feature/assets-filters' into feature/persisted-asset-fi…
kshmidt-digma Jan 31, 2024
639cc6c
Merge branch 'feature/persisted-asset-filters' into feature/jira-hint
kshmidt-digma Jan 31, 2024
5d8c261
Merge branch 'main' into feature/jira-hint
kshmidt-digma Feb 5, 2024
f217d23
Merge branch 'main' into feature/jira-hint
kshmidt-digma Feb 5, 2024
f8b626e
Remove deprecated component
kshmidt-digma Feb 5, 2024
b23b52a
Fix precommit hook
kshmidt-digma Feb 5, 2024
e8b825d
Fix styles, add persistence
kshmidt-digma Feb 6, 2024
039b6c5
Fix tooltip state
kshmidt-digma Feb 6, 2024
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
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run precommit
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
"build:troubleshooting:prod": "webpack --config webpack.prod.ts --env app=troubleshooting",
"build:prod": "webpack --config webpack.prod.ts",
"build:prod:web": "webpack --config webpack.prod.ts --env platform=Web",
"precommit": "lint-staged"
"precommit": "lint-staged",
"prepare": "husky"
},
"lint-staged": {
"*.{js,ts}": [
"*.{js,ts,tsx}": [
"eslint --cache"
],
"src/**/*.ts": [
Expand Down Expand Up @@ -83,7 +84,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-storybook": "^0.6.15",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.0",
"husky": "^9.0.10",
"lint-staged": "^13.2.2",
"postcss-styled-syntax": "^0.5.0",
"prettier": "^2.8.3",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Assets/AssetsFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
AssetsFiltersData
} from "./types";

const PERSISTENCE_KEY = "assetsFilters";

const REFRESH_INTERVAL = isNumber(window.assetsRefreshInterval)
? window.assetsRefreshInterval
: 10 * 1000; // in milliseconds
Expand Down Expand Up @@ -68,7 +70,7 @@ export const AssetsFilter = (props: AssetsFilterProps) => {
const [isOpen, setIsOpen] = useState(false);
const previousIsOpen = usePrevious(isOpen);
const [persistedFilters, setPersistedFilters] =
usePersistence<AssetFilterQuery>("assetsFilters", "project");
usePersistence<AssetFilterQuery>(PERSISTENCE_KEY, "project");
const previousPersistedFilters = usePrevious(persistedFilters);
const [selectedServices, setSelectedServices] = useState<string[]>([]);
const [selectedEndpoints, setSelectedEndpoints] = useState<string[]>([]);
Expand Down
1 change: 1 addition & 0 deletions src/components/Insights/BottleneckInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const BottleneckInsight = (props: BottleneckInsightProps) => {
spanCodeObjectId={props.insight.spanInfo?.spanCodeObjectId}
ticketLink={props.insight.ticketLink}
buttonType={"large"}
isHintEnabled={props.isJiraHintEnabled}
/>
</s.Box>
</s.Container>
Expand Down
1 change: 1 addition & 0 deletions src/components/Insights/EndpointNPlusOneInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const EndpointNPlusOneInsight = (
spanCodeObjectId={spanInfo.spanCodeObjectId}
ticketLink={span.ticketLink}
buttonType={"small"}
isHintEnabled={props.isJiraHintEnabled}
/>
{config.isJaegerEnabled && (
<Tooltip title={"Trace"}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const HighNumberOfQueriesInsight = (
spanCodeObjectId={insight.spanInfo?.spanCodeObjectId}
ticketLink={insight.ticketLink}
buttonType={"small"}
isHintEnabled={props.isJiraHintEnabled}
/>
{traceId && (
<Tooltip title={"Trace"}>
Expand Down
7 changes: 3 additions & 4 deletions src/components/Insights/InsightJiraTicket/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ export const InsightJiraTicket = (props: InsightJiraTicketProps) => {
);
const config = useContext(ConfigContext);

const isLinkUnlinkInputVisible = getFeatureFlagValue(
config,
FeatureFlag.IS_INSIGHT_TICKET_LINKAGE_ENABLED
const isLinkUnlinkInputVisible = Boolean(
getFeatureFlagValue(config, FeatureFlag.IS_INSIGHT_TICKET_LINKAGE_ENABLED)
);

const linkTicket = (link: string) => {
Expand Down Expand Up @@ -95,7 +94,7 @@ export const InsightJiraTicket = (props: InsightJiraTicketProps) => {
ticketLink={{ link: ticketLink, errorMessage }}
unlinkTicket={unlinkTicket}
linkTicket={linkTicket}
showLinkButton={!!isLinkUnlinkInputVisible}
showLinkButton={isLinkUnlinkInputVisible}
/>
);
};
82 changes: 76 additions & 6 deletions src/components/Insights/InsightList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useEffect, useState } from "react";
import { DefaultTheme, useTheme } from "styled-components";
import { usePersistence } from "../../../hooks/usePersistence";
import { trackingEvents as globalTrackingEvents } from "../../../trackingEvents";
import { isUndefined } from "../../../typeGuards/isUndefined";
import { InsightType } from "../../../types";
import { getInsightTypeInfo } from "../../../utils/getInsightTypeInfo";
import { sendTrackingEvent } from "../../../utils/sendTrackingEvent";
Expand Down Expand Up @@ -68,7 +70,7 @@ import {
Trace
} from "../types";
import * as s from "./styles";
import { InsightListProps } from "./types";
import { InsightListProps, isInsightJiraTicketHintShownPayload } from "./types";

export const getInsightTypeOrderPriority = (type: string): number => {
const insightOrderPriorityMap: Record<string, number> = {
Expand Down Expand Up @@ -103,6 +105,39 @@ export const getInsightTypeOrderPriority = (type: string): number => {
return insightOrderPriorityMap[type] || -Infinity;
};

const getInsightToShowJiraHint = (
insightGroups: InsightGroup[]
): { groupIndex: number; insightIndex: number } | null => {
const insightsWithJiraButton = [
InsightType.EndpointSpanNPlusOne,
InsightType.SpanNPlusOne,
InsightType.SpanEndpointBottleneck,
InsightType.SlowestSpans,
InsightType.SpanQueryOptimization,
InsightType.EndpointHighNumberOfQueries
];

let insightIndex = -1;
const insightsWithJiraButtonIndex = insightGroups.findIndex((x) =>
x.insights.some((insight, i) => {
if (insightsWithJiraButton.includes(insight.type)) {
insightIndex = i;
return true;
}
return false;
})
);

if ([insightsWithJiraButtonIndex, insightIndex].includes(-1)) {
return null;
}

return {
groupIndex: insightsWithJiraButtonIndex,
insightIndex: insightIndex
};
};

const groupInsights = (
insights: GenericCodeObjectInsight[],
spans: MethodSpan[]
Expand Down Expand Up @@ -222,7 +257,8 @@ const renderInsightCard = (
onJiraTicketCreate: (
insight: GenericCodeObjectInsight,
spanCodeObjectId?: string
) => void
) => void,
isJiraHintEnabled: boolean
): JSX.Element | undefined => {
const handleErrorSelect = (errorId: string, insightType: InsightType) => {
sendTrackingEvent(globalTrackingEvents.USER_ACTION, {
Expand Down Expand Up @@ -378,6 +414,7 @@ const renderInsightCard = (
onRecalculate={handleRecalculate}
onRefresh={handleRefresh}
onJiraTicketCreate={onJiraTicketCreate}
isJiraHintEnabled={isJiraHintEnabled}
/>
);
}
Expand All @@ -390,6 +427,7 @@ const renderInsightCard = (
onRecalculate={handleRecalculate}
onRefresh={handleRefresh}
onJiraTicketCreate={onJiraTicketCreate}
isJiraHintEnabled={isJiraHintEnabled}
/>
);
}
Expand Down Expand Up @@ -439,6 +477,7 @@ const renderInsightCard = (
onRecalculate={handleRecalculate}
onRefresh={handleRefresh}
onJiraTicketCreate={onJiraTicketCreate}
isJiraHintEnabled={isJiraHintEnabled}
/>
);
}
Expand All @@ -452,6 +491,7 @@ const renderInsightCard = (
onRecalculate={handleRecalculate}
onRefresh={handleRefresh}
onJiraTicketCreate={onJiraTicketCreate}
isJiraHintEnabled={isJiraHintEnabled}
/>
);
}
Expand Down Expand Up @@ -565,6 +605,7 @@ const renderInsightCard = (
onRecalculate={handleRecalculate}
onRefresh={handleRefresh}
onJiraTicketCreate={onJiraTicketCreate}
isJiraHintEnabled={isJiraHintEnabled}
/>
);
}
Expand All @@ -590,16 +631,27 @@ const renderInsightCard = (
onRecalculate={handleRecalculate}
onRefresh={handleRefresh}
onJiraTicketCreate={onJiraTicketCreate}
isJiraHintEnabled={isJiraHintEnabled}
/>
);
}
};

const IS_INSIGHT_JIRA_TICKET_HINT_SHOWN_PERSISTENCE_KEY =
"isInsightJiraTicketHintShown";

export const InsightList = (props: InsightListProps) => {
const [insightGroups, setInsightGroups] = useState<InsightGroup[]>([]);
const [isAutofixing, setIsAutofixing] = useState(false);
const theme = useTheme();
const insightGroupIconColor = getInsightGroupIconColor(theme);
const [isInsightJiraTicketHintShown, setIsInsightJiraTicketHintShown] =
usePersistence<isInsightJiraTicketHintShownPayload>(
IS_INSIGHT_JIRA_TICKET_HINT_SHOWN_PERSISTENCE_KEY,
"application"
);

const insightWithJiraHint = getInsightToShowJiraHint(insightGroups);

useEffect(() => {
window.scrollTo(0, 0);
Expand Down Expand Up @@ -640,9 +692,17 @@ export const InsightList = (props: InsightListProps) => {
setIsAutofixing(true);
};

const handleShowJiraTicket = (
insight: GenericCodeObjectInsight,
spanCodeObjectId?: string
) => {
props.onJiraTicketCreate(insight, spanCodeObjectId);
setIsInsightJiraTicketHintShown({ value: true });
};

return (
<s.Container>
{insightGroups.map((x) => (
{insightGroups.map((x, i) => (
<s.InsightGroup key={x.name || "__ungrouped"}>
{x.name && (
<s.InsightGroupHeader>
Expand All @@ -655,9 +715,19 @@ export const InsightList = (props: InsightListProps) => {
</s.InsightGroupHeader>
)}
{x.insights.length > 0 ? (
x.insights.map((insight) =>
renderInsightCard(insight, props.onJiraTicketCreate)
)
x.insights.map((insight, j) => {
const isJiraHintEnabled =
!isUndefined(isInsightJiraTicketHintShown) &&
!isInsightJiraTicketHintShown?.value &&
i === insightWithJiraHint?.groupIndex &&
j === insightWithJiraHint?.insightIndex;

return renderInsightCard(
insight,
handleShowJiraTicket,
isJiraHintEnabled
);
})
) : (
<Card
header={<>No data yet</>}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Insights/InsightList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ export interface InsightListProps {
spanCodeObjectId?: string
) => void;
}

export interface isInsightJiraTicketHintShownPayload {
value: boolean;
}
1 change: 1 addition & 0 deletions src/components/Insights/NPlusOneInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const NPlusOneInsight = (props: NPlusOneInsightProps) => {
spanCodeObjectId={props.insight.spanInfo?.spanCodeObjectId}
ticketLink={props.insight.ticketLink}
buttonType={"large"}
isHintEnabled={props.isJiraHintEnabled}
/>
]}
/>
Expand Down
1 change: 1 addition & 0 deletions src/components/Insights/QueryOptimizationInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const QueryOptimizationInsight = (
spanCodeObjectId={props.insight.spanInfo?.spanCodeObjectId}
ticketLink={props.insight.ticketLink}
buttonType={"large"}
isHintEnabled={props.isJiraHintEnabled}
/>
]}
/>
Expand Down
1 change: 1 addition & 0 deletions src/components/Insights/SpanBottleneckInsight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const SpanBottleneckInsight = (props: SpanBottleneckInsightProps) => {
spanCodeObjectId={spanCodeObjectId}
ticketLink={span.ticketLink}
buttonType={"small"}
isHintEnabled={props.isJiraHintEnabled}
/>
</s.ButtonsContainer>
</s.Span>
Expand Down
Loading