Skip to content

Commit

Permalink
Merge branch 'develop' into feat/cacl-cost-elasticache
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhamPalriwala authored Jun 29, 2023
2 parents 3750d19 + 317f4cd commit f24dbe5
Show file tree
Hide file tree
Showing 32 changed files with 3,976 additions and 18,701 deletions.
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var versionCmd = &cobra.Command{
Short: "Show tool version",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(logo)
fmt.Print(logo)
showLine(cmd, "Version", internal.Version)
showLine(cmd, "Go version", internal.GoVersion)
showLine(cmd, "Commit", internal.Commit)
Expand Down
1 change: 1 addition & 0 deletions dashboard/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
/package-lock.json

# testing
/coverage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function DashboardCostExplorerCard({
});

return (
<div className="w-full rounded-lg bg-white py-4 px-6 pb-6">
<div className=" -mx-6 flex flex-wrap items-center justify-between gap-4 border-b border-black-200/40 px-6 pb-4">
<div className="w-full rounded-lg bg-white px-6 py-4 pb-6">
<div className="-mx-6 flex flex-wrap items-center justify-between gap-4 border-b border-black-200/40 px-6 pb-4">
<div>
<p className="text-sm font-semibold text-black-900">Cost explorer</p>
<div className="mt-1"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function useCostExplorer() {
[startDate, endDate] = lastTwelveMonths;
}

const granularity = newGranularity.toUpperCase();
const granularity = queryGranularity.toUpperCase();
const payload = {
group: queryGroup,
granularity,
Expand Down
102 changes: 63 additions & 39 deletions dashboard/components/inventory/components/InventoryActiveFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { NextRouter } from 'next/router';
import Button from '../../button/Button';
import { InventoryFilterData } from '../hooks/useInventory/types/useInventoryTypes';
import InventoryFilterSummary from './filter/InventoryFilterSummary';
import PlusIcon from '../../icons/PlusIcon';
import useFilterWizard from './filter/hooks/useFilterWizard';
import useInventory from '../hooks/useInventory/useInventory';
import InventoryFilterDropdown from './InventoryFilterDropdown';

type InventoryActiveFiltersProps = {
hasFilters: boolean | undefined;
Expand All @@ -18,6 +22,9 @@ function InventoryActiveFilters({
deleteFilter,
router
}: InventoryActiveFiltersProps) {
const { setSkippedSearch } = useInventory();
const { toggle, isOpen } = useFilterWizard({ router, setSkippedSearch });

return (
<>
{hasFilters && (
Expand All @@ -32,47 +39,64 @@ function InventoryActiveFilters({
deleteFilter={isNotCustomView ? deleteFilter : undefined}
/>
))}

{isNotCustomView && (
<Button
size="xs"
style="ghost"
onClick={() => router.push(router.pathname)}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="none"
viewBox="0 0 24 24"
className="text-black-400"
<div className="flex items-center gap-3">
<div className="relative">
<div className="cursor-pointer" onClick={toggle}>
<PlusIcon width={16} height={16} />
</div>
{isOpen && (
<InventoryFilterDropdown
position={'top-10'}
toggle={toggle}
closeDropdownAfterAdd={false}
/>
)}
</div>

<div className="border-x-1 h-7 border"></div>
<Button
size="xxs"
style="ghost"
onClick={() => router.push(router.pathname)}
>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit="10"
strokeWidth="1.5"
d="M13.41 20.79L12 21.7c-1.31.81-3.13-.1-3.13-1.72v-5.35c0-.71-.4-1.62-.81-2.12L4.22 8.47c-.51-.51-.91-1.41-.91-2.02V4.13c0-1.21.91-2.12 2.02-2.12h13.34c1.11 0 2.02.91 2.02 2.02v2.22c0 .81-.51 1.82-1.01 2.32"
></path>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit="10"
strokeWidth="1.5"
d="M21.63 14.75c0 .89-.25 1.73-.69 2.45a4.709 4.709 0 01-4.06 2.3 4.73 4.73 0 01-4.06-2.3 4.66 4.66 0 01-.69-2.45c0-2.62 2.13-4.75 4.75-4.75s4.75 2.13 4.75 4.75zM18.15 15.99l-2.51-2.51M18.13 13.51l-2.51 2.51"
></path>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit="10"
strokeWidth="1.5"
d="M20.69 4.02v2.22c0 .81-.51 1.82-1.01 2.33l-1.76 1.55a4.42 4.42 0 00-1.04-.12c-2.62 0-4.75 2.13-4.75 4.75 0 .89.25 1.73.69 2.45.37.62.88 1.15 1.5 1.53v.34c0 .61-.4 1.42-.91 1.72L12 21.7c-1.31.81-3.13-.1-3.13-1.72v-5.35c0-.71-.41-1.62-.81-2.12L4.22 8.47c-.5-.51-.91-1.42-.91-2.02V4.12C3.31 2.91 4.22 2 5.33 2h13.34c1.11 0 2.02.91 2.02 2.02z"
></path>
</svg>
Clear filters
</Button>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="none"
viewBox="0 0 24 24"
className="text-black-400"
>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit="10"
strokeWidth="1.5"
d="M13.41 20.79L12 21.7c-1.31.81-3.13-.1-3.13-1.72v-5.35c0-.71-.4-1.62-.81-2.12L4.22 8.47c-.51-.51-.91-1.41-.91-2.02V4.13c0-1.21.91-2.12 2.02-2.12h13.34c1.11 0 2.02.91 2.02 2.02v2.22c0 .81-.51 1.82-1.01 2.32"
></path>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit="10"
strokeWidth="1.5"
d="M21.63 14.75c0 .89-.25 1.73-.69 2.45a4.709 4.709 0 01-4.06 2.3 4.73 4.73 0 01-4.06-2.3 4.66 4.66 0 01-.69-2.45c0-2.62 2.13-4.75 4.75-4.75s4.75 2.13 4.75 4.75zM18.15 15.99l-2.51-2.51M18.13 13.51l-2.51 2.51"
></path>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit="10"
strokeWidth="1.5"
d="M20.69 4.02v2.22c0 .81-.51 1.82-1.01 2.33l-1.76 1.55a4.42 4.42 0 00-1.04-.12c-2.62 0-4.75 2.13-4.75 4.75 0 .89.25 1.73.69 2.45.37.62.88 1.15 1.5 1.53v.34c0 .61-.4 1.42-.91 1.72L12 21.7c-1.31.81-3.13-.1-3.13-1.72v-5.35c0-.71-.41-1.62-.81-2.12L4.22 8.47c-.5-.51-.91-1.42-.91-2.02V4.12C3.31 2.91 4.22 2 5.33 2h13.34c1.11 0 2.02.91 2.02 2.02z"
></path>
</svg>
Clear filters
</Button>
</div>
)}
</div>
)}
Expand Down
126 changes: 126 additions & 0 deletions dashboard/components/inventory/components/InventoryFilterDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { useEffect } from 'react';
import useInventory from '../hooks/useInventory/useInventory';
import useFilterWizard from './filter/hooks/useFilterWizard';
import Button from '../../button/Button';
import InventoryFilterBreadcrumbs from './filter/InventoryFilterBreadcrumbs';
import InventoryFilterSummary from './filter/InventoryFilterSummary';
import InventoryFilterField from './filter/InventoryFilterField';
import InventoryFilterOperator from './filter/InventoryFilterOperator';
import InventoryFilterValue from './filter/InventoryFilterValue';

type InventoryFilterDropdownProps = {
position: string;
closeDropdownAfterAdd: boolean;
toggle: () => void;
};

export default function InventoryFilterDropdown({
position,
toggle,
closeDropdownAfterAdd
}: InventoryFilterDropdownProps) {
const { setSkippedSearch, router, setToast } = useInventory();

const {
// toggle,
step,
goTo,
handleField,
handleOperator,
handleTagKey,
handleValueCheck,
handleValueInput,
costBetween,
handleCostBetween,
inlineError,
data,
resetData,
cleanValues,
filter
} = useFilterWizard({ router, setSkippedSearch });

useEffect(() => {
cleanValues();
}, []);

return (
<>
{/* Dropdown transparent backdrop */}
<div
onClick={toggle}
className="fixed top-0 left-0 z-20 hidden h-screen w-screen animate-fade-in bg-transparent opacity-0 sm:block"
></div>
<div
className={`absolute ${position} z-[21] inline-flex min-w-[16rem] max-w-[21rem] rounded-lg bg-white p-4 text-sm shadow-xl`}
>
<div className="flex w-full flex-col">
{/* Filter breadcrumbs */}
<InventoryFilterBreadcrumbs step={step} goTo={goTo} />
<div className="mt-2"></div>

{/* Filter summary */}
{step !== 0 && data && data.field && (
<InventoryFilterSummary data={data} resetData={resetData} />
)}
<div className="mt-2"></div>

{/* Filter steps - 1/3 filter field */}
{step === 0 && <InventoryFilterField handleField={handleField} />}

{/* Filter steps - 2/3 filter operator */}
{step === 1 && (
<InventoryFilterOperator
data={data}
handleTagKey={handleTagKey}
handleOperator={handleOperator}
/>
)}

{/* Filter steps - 3/3 filter value */}
{step === 2 && (
<form
onSubmit={e => {
e.preventDefault();
filter();
if (closeDropdownAfterAdd) toggle();
}}
>
<div className="-mr-4 max-h-[calc(100vh-23rem)] overflow-auto pb-2">
<InventoryFilterValue
data={data}
handleValueCheck={handleValueCheck}
handleValueInput={handleValueInput}
cleanValues={cleanValues}
setToast={setToast}
costBetween={costBetween}
handleCostBetween={handleCostBetween}
/>
</div>
{inlineError.hasError && (
<p className="pb-4 text-xs font-medium text-error-600">
{inlineError.message}
</p>
)}
<div className="-mx-4 -mb-4 flex justify-end border-t px-4 py-4">
<Button
type="submit"
disabled={
data &&
data.operator !== 'IS_EMPTY' &&
data.operator !== 'IS_NOT_EMPTY' &&
data.operator !== 'EXISTS' &&
data.operator !== 'NOT_EXISTS' &&
data.values &&
data.values.length === 0
}
>
Apply filter
</Button>
</div>
</form>
)}
</div>
</div>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function InventoryTableTags({
{tags.length}
</span>
</div>
<div className="absolute right-6 top-11 z-10 hidden flex-col gap-2 rounded-lg bg-black-900 py-3 px-4 shadow-lg group-hover:flex">
<div className="absolute right-6 top-11 z-10 hidden max-w-xs flex-col gap-2 rounded-lg bg-black-900 py-3 px-4 shadow-lg group-hover:flex">
{tags.map((tag, index) => (
<div
key={index}
Expand Down Expand Up @@ -82,14 +82,14 @@ function InventoryTableTags({
onClick={e => {
setQuery(tag.key);
}}
className="cursor-pointer hover:text-komiser-500"
className="line-clamp-2 cursor-pointer hover:text-komiser-500"
>
{tag.key}:
</span>
</div>
<span
onClick={() => setQuery(tag.value)}
className="cursor-pointer font-medium hover:text-komiser-500"
className="line-clamp-2 cursor-pointer font-medium hover:text-komiser-500"
>
{tag.value}
</span>
Expand Down
Loading

0 comments on commit f24dbe5

Please sign in to comment.