Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/empty states #1035

Merged
merged 11 commits into from
Sep 6, 2024
4 changes: 4 additions & 0 deletions src/components/Assets/AssetList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { usePrevious } from "../../../hooks/usePrevious";
import { useConfigSelector } from "../../../store/config/useConfigSelector";
import { isEnvironment } from "../../../typeGuards/isEnvironment";
import { changeScope } from "../../../utils/actions/changeScope";
import { sendUserActionTrackingEvent } from "../../../utils/actions/sendUserActionTrackingEvent";
import { SCOPE_CHANGE_EVENTS } from "../../Main/types";
import { EmptyState } from "../../common/EmptyState";
import { Menu } from "../../common/Menu";
Expand All @@ -19,6 +20,7 @@ import { SortIcon } from "../../common/icons/SortIcon";
import { Direction } from "../../common/icons/types";
import { AssetFilterQuery } from "../AssetsFilter/types";
import { actions } from "../actions";
import { trackingEvents } from "../tracking";
import { checkIfAnyFiltersApplied, getAssetTypeInfo } from "../utils";
import { AssetEntry as AssetEntryComponent } from "./AssetEntry";
import * as s from "./styles";
Expand Down Expand Up @@ -272,6 +274,8 @@ export const AssetList = ({
]);

const handleAllAssetsLinkClick = () => {
sendUserActionTrackingEvent(trackingEvents.ALL_ASSETS_LINK_CLICKED);

onGoToAllAssets();
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/Assets/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const trackingEvents = addPrefix(
{
FILTER_APPLIED: "filter applied",
REFRESH_BUTTON_CLICKED: "refresh button clicked",
FILTERS_POPUP_CLOSE_BUTTON_CLICKED: "filter popup close button clicked"
FILTERS_POPUP_CLOSE_BUTTON_CLICKED: "filter popup close button clicked",
ALL_ASSETS_LINK_CLICKED: "all assets link clicked"
},
" "
);
2 changes: 1 addition & 1 deletion src/components/Errors/ErrorDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
useFetchData
} from "../../../hooks/useFetchData";
import { NewCircleLoader } from "../../common/NewCircleLoader";
import { EmptyStateContainer } from "../ErrorsList/styles";
import { actions } from "../actions";
import { EmptyStateContainer } from "../styles";
import { ErrorDetailsCardContent } from "./ErrorDetailsCardContent";
import { ErrorDetailsCardHeader } from "./ErrorDetailsCardHeader";
import * as s from "./styles";
Expand Down
14 changes: 14 additions & 0 deletions src/components/Errors/ErrorsList/ErrorsList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@ export const Empty: Story = {
}, 1000);
}
};

export const EmptyHome: Story = {
play: () => {
window.setTimeout(() => {
window.postMessage({
type: "digma",
action: actions.SET_ERRORS_DATA,
payload: {
errors: []
}
});
}, 1000);
}
};
kshmidt-digma marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 7 additions & 6 deletions src/components/Errors/ErrorsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { NewCircleLoader } from "../../common/NewCircleLoader";
import { CheckCircleIcon } from "../../common/icons/38px/CheckCircleIcon";
import { ErrorCard } from "../ErrorCard";
import { actions } from "../actions";
import { EmptyStateContainer, EmptyStateTextContainer } from "../styles";
import { trackingEvents } from "../tracking";
import { GetErrorsDataPayload, SetErrorsDataPayload } from "../types";
import * as s from "./styles";
Expand Down Expand Up @@ -45,27 +46,27 @@ export const ErrorsList = ({
if (!data) {
// TODO: replace with skeletons
return (
<s.EmptyStateContainer>
<EmptyStateContainer>
<NewCircleLoader size={32} />
</s.EmptyStateContainer>
</EmptyStateContainer>
);
}

if (data.errors.length === 0) {
return (
<s.EmptyStateContainer>
<EmptyStateContainer>
<s.EmptyStateIconContainer>
<CheckCircleIcon size={38} color={"currentColor"} />
</s.EmptyStateIconContainer>
<s.EmptyStateTextContainer>
<EmptyStateTextContainer>
<s.EmptyStateTitle>
<span>Good News!</span>
<span>No Errors Recorded Yet</span>
</s.EmptyStateTitle>
You should return to this page if any exceptions do occur to see more
details.
</s.EmptyStateTextContainer>
</s.EmptyStateContainer>
</EmptyStateTextContainer>
</EmptyStateContainer>
);
}

Expand Down
26 changes: 1 addition & 25 deletions src/components/Errors/ErrorsList/styles.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import styled from "styled-components";
import {
bodySemiboldTypography,
footnoteRegularTypography
} from "../../common/App/typographies";
import { bodySemiboldTypography } from "../../common/App/typographies";

export const Container = styled.div`
display: flex;
Expand All @@ -12,17 +9,6 @@ export const Container = styled.div`
overflow: auto;
`;

export const EmptyStateContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
justify-content: center;
flex-grow: 1;
width: 210px;
align-self: center;
`;

export const EmptyStateIconContainer = styled.div`
display: flex;
align-items: center;
Expand All @@ -34,16 +20,6 @@ export const EmptyStateIconContainer = styled.div`
background: ${({ theme }) => theme.colors.v3.surface.sidePanelHeader};
`;

export const EmptyStateTextContainer = styled.div`
${footnoteRegularTypography}

display: flex;
flex-direction: column;
text-align: center;
gap: 4px;
color: ${({ theme }) => theme.colors.v3.text.tertiary};
`;

export const EmptyStateTitle = styled.div`
${bodySemiboldTypography}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Errors/ErrorsList/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface ErrorsListProps {
spanCodeObjectId: string;
spanCodeObjectId?: string;
kshmidt-digma marked this conversation as resolved.
Show resolved Hide resolved
methodId?: string;
onErrorSelect: (id: string) => void;
}
50 changes: 43 additions & 7 deletions src/components/Errors/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { useParams } from "react-router-dom";
import { useConfigSelector } from "../../store/config/useConfigSelector";
import { trackingEvents as globalEvents } from "../../trackingEvents";
import { sendUserActionTrackingEvent } from "../../utils/actions/sendUserActionTrackingEvent";
import { ErrorIcon } from "../common/icons/16px/ErrorIcon";
import { NewButton } from "../common/v3/NewButton";
import { NewEmptyState } from "../common/v3/NewEmptyState";
import { useHistory } from "../Main/useHistory";
import { TAB_IDS } from "../Navigation/Tabs/types";
import { ErrorDetails } from "./ErrorDetails";
import { ErrorsList } from "./ErrorsList";
import * as s from "./styles";
Expand All @@ -21,6 +27,13 @@ export const Errors = () => {
goTo("..");
};

const handleSeeAllAssetsClick = () => {
sendUserActionTrackingEvent(globalEvents.GOT_TO_ALL_ASSETS_CLICKED, {
source: "Error tab"
});
goTo(`/${TAB_IDS.ASSETS}`);
};

const renderContent = () => {
if (selectedErrorId) {
return (
Expand All @@ -31,17 +44,40 @@ export const Errors = () => {
);
}

if (spanCodeObjectId) {
if (!spanCodeObjectId) {
return (
<ErrorsList
onErrorSelect={handleErrorSelect}
spanCodeObjectId={spanCodeObjectId}
methodId={methodId}
/>
<s.EmptyStateContainer>
<NewEmptyState
icon={ErrorIcon}
title={"Select an asset to view errors"}
content={
<>
<s.EmptyStateTextContainer>
<span>The Errors tab shows details for</span>
<span>exceptions for each Digma-tracked</span>
<span>asset. See all tracked assets on the</span>
<span>Assets page.</span>
</s.EmptyStateTextContainer>

<NewButton
buttonType="primary"
onClick={handleSeeAllAssetsClick}
label="See all assets"
/>
</>
}
/>
</s.EmptyStateContainer>
);
}

return null;
return (
kshmidt-digma marked this conversation as resolved.
Show resolved Hide resolved
<ErrorsList
onErrorSelect={handleErrorSelect}
spanCodeObjectId={spanCodeObjectId}
methodId={methodId}
/>
);
};

return <s.Container>{renderContent()}</s.Container>;
Expand Down
23 changes: 23 additions & 0 deletions src/components/Errors/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
import styled from "styled-components";
import { footnoteRegularTypography } from "../common/App/typographies";

export const Container = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`;

export const EmptyStateTextContainer = styled.div`
${footnoteRegularTypography}

display: flex;
flex-direction: column;
text-align: center;
gap: 4px;
padding-top: 4px;
padding-bottom: 4px;
color: ${({ theme }) => theme.colors.v3.text.tertiary};
`;

export const EmptyStateContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
justify-content: center;
flex-grow: 1;
align-self: center;
`;
2 changes: 1 addition & 1 deletion src/components/Errors/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface GetErrorsDataPayload {
spanCodeObjectId: string;
spanCodeObjectId?: string;
kshmidt-digma marked this conversation as resolved.
Show resolved Hide resolved
methodId?: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const props: InsightsPageProps = {
return undefined;
},
page: 0,
isMarkAsReadButtonEnabled: false
isMarkAsReadButtonEnabled: false,
insightsViewType: "Analytics"
};

export const WithInsights: Story = {
Expand Down Expand Up @@ -144,3 +145,22 @@ export const NoInsightsButAnalyticsExist: Story = {
],
args: props
};

export const NoAnalyticsInsightsOnHomeScope: Story = {
decorators: [
(Story) => (
<ConfigContext.Provider
value={{
...initialState,
scope: undefined
}}
>
<Story />
</ConfigContext.Provider>
)
],
args: {
...props,
insightsViewType: "Analytics"
}
};
Loading
Loading