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

Add tailwarden banners #1172

Merged
merged 6 commits into from
Nov 8, 2023
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
27 changes: 25 additions & 2 deletions dashboard/components/button/Button.mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const base: ButtonProps = {
size: 'lg',
disabled: false,
loading: false,
onClick: () => {}
onClick: () => {},
href: '',
target: ''
};

const secondary: ButtonProps = {
Expand Down Expand Up @@ -63,13 +65,34 @@ const deleteButton: ButtonProps = {
onClick: () => {}
};

const linkButton: ButtonProps = {
children: 'Link button',
asLink: true,
style: 'primary',
size: 'lg',
loading: false,
href: 'https://komiser.io'
};

const newTabLinkButton: ButtonProps = {
children: 'New Tab Link button',
asLink: true,
style: 'secondary',
size: 'lg',
loading: false,
href: 'https://komiser.io',
target: '_blank'
};

const mockButtonProps = {
base,
secondary,
ghost,
text,
dropdown,
deleteButton
deleteButton,
linkButton,
newTabLinkButton
};

export default mockButtonProps;
12 changes: 12 additions & 0 deletions dashboard/components/button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,15 @@ export const Delete: Story = {
...mockButtonProps.deleteButton
}
};

export const Link: Story = {
args: {
...mockButtonProps.linkButton
}
};

export const NewTabLink: Story = {
args: {
...mockButtonProps.newTabLinkButton
}
};
44 changes: 33 additions & 11 deletions dashboard/components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ export type ButtonProps = {
gap?: 'md';
transition?: boolean;
onClick?: (e?: any) => void;
asLink?: boolean;
href?: string;
target?: string;
};

function Button({
children,
asLink = false,
type = 'button',
style = 'primary',
size = 'md',
Expand All @@ -24,7 +28,9 @@ function Button({
align,
gap,
transition = true,
onClick
onClick,
href,
target
}: ButtonProps) {
const xxs = 'p-1';
const xs = 'py-2 px-4';
Expand Down Expand Up @@ -73,21 +79,37 @@ function Button({
if (style === 'text') buttonStyle = text;
if (style === 'dropdown') buttonStyle = dropdown;
if (style === 'delete') buttonStyle = deleteStyle;
if (asLink) buttonStyle = `${buttonStyle} inline-block sm:w-fit-content`;

return buttonStyle;
}

return (
<button
type={type}
onClick={onClick}
className={handleStyle()}
disabled={disabled || loading}
data-testid={style}
>
{loading && <LoadingSpinner />}
{children}
</button>
<>
{asLink ? (
<a
onClick={onClick}
className={handleStyle()}
data-testid={style}
href={href}
target={target}
>
{loading && <LoadingSpinner />}
{children}
</a>
) : (
<button
type={type}
onClick={onClick}
className={handleStyle()}
disabled={disabled || loading}
data-testid={style}
>
{loading && <LoadingSpinner />}
{children}
</button>
)}
</>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import {
import Image from 'next/image';
import { Dispatch, SetStateAction } from 'react';
import { Bar } from 'react-chartjs-2';
import SelectCheckbox from '../../../select-checkbox/SelectCheckbox';
import Select from '../../../select/Select';

import Button from '@components/button/Button';
import SelectCheckbox from '@components/select-checkbox/SelectCheckbox';
import Select from '@components/select/Select';
import { CloudIcon } from '@components/icons';
import {
CostExplorerQueryDateProps,
CostExplorerQueryGranularityProps,
Expand Down Expand Up @@ -115,17 +118,31 @@ function DashboardCostExplorerCard({
<div className="h-full min-h-[22rem]">
{chartData && <Bar data={chartData} options={options} />}
{!chartData && (
<div className="relative flex flex-col items-center">
<p className="mt-10 text-lg text-black-900">
No data for this time period
</p>
<Image
src="/assets/img/others/empty-state-cost-explorer.png"
width={940}
height={330}
alt="No data to display image"
className="absolute top-0"
/>
<div className="relative flex flex-col items-center bg-empty-cost-explorer h-[330px] w-full">
<div className="mt-10 text-lg text-black-900 border border-gray-200 px-8 py-6 flex bg-white">
<div>
<p className="text-lg">No data for this time period</p>
<p className="text-sm text-gray-400 mb-4">
Our cloud version, Tailwarden, supports <br />
historical costs from certain cloud providers
</p>
<Button
size="sm"
gap="md"
asLink
href="https://tailwarden.com/?utm_source=komiser"
target="_blank"
>
<CloudIcon width="24" /> Discover Tailwarden
</Button>
</div>
<Image
src="/assets/img/purplin/rocket.svg"
alt="Purplin on a Rocket"
width="115"
height="124"
/>
</div>
</div>
)}
</div>
Expand Down
29 changes: 29 additions & 0 deletions dashboard/components/icons/CloudIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SVGProps } from 'react';

const CloudIcon = (props: SVGProps<SVGSVGElement>) => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
{...props}
>
<path
d="M7.27004 13.01C6.74004 12.74 6.15004 12.6 5.55004 12.6C0.870039 12.93 0.870039 19.74 5.55004 20.07H16.64C17.99 20.08 19.29 19.58 20.28 18.67C23.57 15.8 21.81 10.03 17.48 9.48C15.92 0.110001 2.39004 3.67 5.60004 12.6"
stroke="white"
stroke-width="1.5"
stroke-miterlimit="10"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M15.85 9.92001C16.37 9.66001 16.94 9.52001 17.52 9.51001"
stroke="white"
stroke-width="1.5"
stroke-miterlimit="10"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
);

export default CloudIcon;
2 changes: 1 addition & 1 deletion dashboard/components/icons/Icons.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const IconsWrapper = (props: SVGProps<SVGSVGElement>) => (
<div className="inline-flex w-full flex-wrap gap-2 p-2">
{Object.entries(icons).map(([name, Icon]) => (
<div key={name} className="relative">
<div className="peer flex h-full flex-col items-center justify-center gap-2 rounded-md border bg-white p-3">
<div className="peer flex h-full flex-col items-center justify-center gap-2 rounded-md border bg-gray-200 p-3">
<Icon {...props} />
<p className="text-sm">{name}</p>
</div>
Expand Down
1 change: 1 addition & 0 deletions dashboard/components/icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { default as ChevronDownIcon } from './ChevronDownIcon';
export { default as ChevronRightIcon } from './ChevronRightIcon';
export { default as ClearFilterIcon } from './ClearFilterIcon';
export { default as CloseIcon } from './CloseIcon';
export { default as CloudIcon } from './CloudIcon';
export { default as DeleteIcon } from './DeleteIcon';
export { default as DocumentTextIcon } from './DocumentTextIcon';
export { default as DownloadIcon } from './DownloadIcon';
Expand Down
42 changes: 41 additions & 1 deletion dashboard/pages/cloud-accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,32 @@ import CloudAccountDeleteContents from '@components/cloud-account/components/Clo
import { useToast } from '@components/toast/ToastProvider';

import EmptyState from '@components/empty-state/EmptyState';
import Banner from '@components/banner/Banner';
import Button from '@components/button/Button';

function CloudAccounts() {
const [editCloudAccount, setEditCloudAccount] = useState<boolean>(false);
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState<boolean>(false);

const [isTailwardenBannerDismissed, setIsTailwardenBannerDismissed] =
useState(true);

const { toast, showToast, dismissToast } = useToast();
const router = useRouter();

const currentViewProvider = router.query.view as string;

const hideTailwardenBanner = () => {
setIsTailwardenBannerDismissed(true);
window.localStorage.setItem('tailwardenBannerDismissed', 'true');
};

useEffect(() => {
setIsTailwardenBannerDismissed(
window.localStorage.getItem('tailwardenBannerDismissed') === 'true'
);
}, []);

const {
cloudAccounts,
setCloudAccounts,
Expand Down Expand Up @@ -75,7 +91,7 @@ function CloudAccounts() {
{/* Wraps the cloud account page and handles the custom views sidebar */}
<CloudAccountsLayout router={router} cloudAccounts={cloudAccounts}>
<CloudAccountsHeader isNotCustomView={isNotCustomView} />

<div className="z-10 text-sm text-black-800 first-letter:top-0 z-10 flex w-full animate-fade-in-down-short items-center justify-center gap-6 bg-gradient-to-br from-primary to-secondary py-3 opacity-1 fixed"></div>
{filteredCloudAccounts.map(account => (
<CloudAccountItem
key={account.id}
Expand Down Expand Up @@ -135,6 +151,30 @@ function CloudAccounts() {
goTo={goTo}
/>
)}

{cloudAccounts.length >= 2 && !isTailwardenBannerDismissed && (
<div className="bg-white absolute bottom-0 left-0 right-0 z-20 px-28 border-black-170 border-t text-base py-3 flex gap-4 items-center justify-center">
For deeper insights and account-level alerts, make the switch to
Tailwarden — our recommended cloud version for production use.{' '}
<Button
size="xs"
gap="md"
asLink
href="https://tailwarden.com/?utm_source=komiser"
target="_blank"
>
Discover Tailwarden
</Button>
<Button
size="xs"
gap="md"
style="ghost"
onClick={() => hideTailwardenBanner()}
>
X
</Button>
</div>
)}
</>
);
}
Expand Down
7 changes: 6 additions & 1 deletion dashboard/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ module.exports = {
scale: 'scale 250ms ease forwards'
},
backgroundImage: {
'dependency-graph': 'radial-gradient(#EDEBEE 2px, transparent 0)'
'dependency-graph': 'radial-gradient(#EDEBEE 2px, transparent 0)',
'empty-cost-explorer':
"url('/assets/img/others/empty-state-cost-explorer.png')"
},
width: {
'fit-content': 'fit-content'
}
}
},
Expand Down
1 change: 0 additions & 1 deletion dashboard/utils/providerHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ const platform: Platform = {
}
},


getImgSrc(providerName) {
const key = providerName.toLowerCase();
if (key in this.cloudProviders) return this.cloudProviders[key].imgSrc;
Expand Down
Loading