Skip to content

Commit

Permalink
Merge branch 'develop' into ovh
Browse files Browse the repository at this point in the history
  • Loading branch information
mlabouardy authored Nov 9, 2023
2 parents b80f981 + ff4f225 commit f961451
Show file tree
Hide file tree
Showing 17 changed files with 1,130 additions and 698 deletions.
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
2 changes: 1 addition & 1 deletion dashboard/components/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function Navbar() {
</a>
<a
className="hidden items-center gap-2 transition-colors hover:text-primary md:flex"
href="https://www.tailwarden.com/changelog?utm_source=komiser&utm_medium=referral&utm_campaign=static"
href="https://www.tailwarden.com/changelog/komiser"
target="_blank"
rel="noopener noreferrer"
>
Expand Down
Loading

0 comments on commit f961451

Please sign in to comment.