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

feat: add empty state for empty page filters apllied on resource expl… #1096

Merged
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
3 changes: 2 additions & 1 deletion dashboard/components/empty-state/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ type Poses =
| 'shirt'
| 'whiteboard'
| 'thinking'
| 'working';
| 'working'
| 'tablet';

export type EmptyStateProps = {
title: string;
Expand Down
86 changes: 53 additions & 33 deletions dashboard/components/explorer/DependencyGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useState, memo } from 'react';
import React, { useState, memo, useEffect } from 'react';
import CytoscapeComponent from 'react-cytoscapejs';
import Cytoscape, { EventObject } from 'cytoscape';
import popper from 'cytoscape-popper';
Expand All @@ -12,6 +12,8 @@ import nodeHtmlLabel, {
// @ts-ignore
import COSEBilkent from 'cytoscape-cose-bilkent';

import EmptyState from '@components/empty-state/EmptyState';

import Tooltip from '@components/tooltip/Tooltip';
import WarningIcon from '@components/icons/WarningIcon';
import { ReactFlowData } from './hooks/useDependencyGraph';
Expand All @@ -36,6 +38,8 @@ Cytoscape.use(popper);
const DependencyGraph = ({ data }: DependencyGraphProps) => {
const [initDone, setInitDone] = useState(false);

const dataIsEmpty: boolean = data.nodes.length === 0;

// Type technically is Cytoscape.EdgeCollection but that throws an unexpected error
const loopAnimation = (eles: any) => {
const ani = eles.animation(edgeAnimationConfig[0], edgeAnimationConfig[1]);
Expand Down Expand Up @@ -122,39 +126,55 @@ const DependencyGraph = ({ data }: DependencyGraphProps) => {

return (
<div className="relative h-full flex-1 bg-dependency-graph bg-[length:40px_40px]">
<CytoscapeComponent
className="h-full w-full"
elements={CytoscapeComponent.normalizeElements({
nodes: data.nodes,
edges: data.edges
})}
maxZoom={maxZoom}
minZoom={minZoom}
layout={graphLayoutConfig}
stylesheet={[
{
selector: 'node',
style: nodeStyeConfig
},
{
selector: 'edge',
style: edgeStyleConfig
},
{
selector: '.leaf',
style: leafStyleConfig
}
]}
cy={(cy: Cytoscape.Core) => cyActionHandlers(cy)}
/>
<div className="absolute bottom-0 left-0 flex gap-2 overflow-visible overflow-visible bg-black-100 text-black-400">
{dataIsEmpty ? (
<>
<div className="translate-y-[201px]">
<EmptyState
title="No results for this filter"
message="It seems like you have no cloud resources matching the filters you added"
mascotPose="tablet"
/>
</div>
</>
) : (
<>
<CytoscapeComponent
className="h-full w-full"
elements={CytoscapeComponent.normalizeElements({
nodes: data.nodes,
edges: data.edges
})}
maxZoom={maxZoom}
minZoom={minZoom}
layout={graphLayoutConfig}
stylesheet={[
{
selector: 'node',
style: nodeStyeConfig
},
{
selector: 'edge',
style: edgeStyleConfig
},
{
selector: '.leaf',
style: leafStyleConfig
}
]}
cy={(cy: Cytoscape.Core) => cyActionHandlers(cy)}
/>
</>
)}
<div className="absolute bottom-0 left-0 flex gap-2 overflow-visible bg-black-100 text-black-400">
{data?.nodes?.length} Resources
<div className="relative">
<WarningIcon className="peer" height="16" width="16" />
<Tooltip bottom="xs" align="left" width="lg">
Only AWS resources are currently supported on the explorer.
</Tooltip>
</div>
{!dataIsEmpty && (
<div className="relative">
<WarningIcon className="peer" height="16" width="16" />
<Tooltip bottom="xs" align="left" width="lg">
Only AWS resources are currently supported on the explorer.
</Tooltip>
</div>
)}
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "next build && next export",
"start": "next start -p 3002",
"lint": "next lint",
"format": "prettier --write \"**/*.{ts,tsx,json,css,scss,md}\"",
"prepare": "cd .. && husky install dashboard/.husky",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
Expand Down