-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement basic cloud account management UI in HeroSection
- Loading branch information
1 parent
7305c2d
commit 6c3b326
Showing
6 changed files
with
251 additions
and
27 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
frontend/src/container/CloudIntegrationPage/HeroSection/AccountActions.style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
.hero-section__actions { | ||
margin-top: 12px; | ||
|
||
&-with-account { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} | ||
} | ||
.hero-section__action-buttons { | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
} | ||
|
||
.hero-section__action-button { | ||
font-family: 'Inter'; | ||
border-radius: 2px; | ||
cursor: pointer; | ||
font-size: 12px; | ||
font-weight: 500; | ||
line-height: 16px; | ||
padding: 8px 17px; | ||
|
||
&.primary { | ||
background: var(--bg-robin-500); | ||
border: none; | ||
color: var(--bg-vanilla-100); | ||
} | ||
|
||
&.secondary { | ||
display: flex; | ||
align-items: center; | ||
border: 1px solid var(--bg-ink-300); | ||
color: var(--bg-vanilla-100); | ||
border-radius: 2px; | ||
background: var(--bg-slate-400); | ||
box-shadow: none; | ||
} | ||
} | ||
|
||
.cloud-account-selector { | ||
border-radius: 2px; | ||
border: 1px solid var(--bg-ink-300); | ||
background: linear-gradient( | ||
139deg, | ||
rgba(18, 19, 23, 0.8) 0%, | ||
rgba(18, 19, 23, 0.9) 98.68% | ||
); | ||
box-shadow: 4px 10px 16px 2px rgba(0, 0, 0, 0.2); | ||
-webkit-backdrop-filter: blur(20px); | ||
backdrop-filter: blur(20px); | ||
.ant-select-selector { | ||
border-color: var(--bg-slate-400) !important; | ||
background: var(--bg-ink-300) !important; | ||
padding: 6px 8px !important; | ||
} | ||
.ant-select-selection-item { | ||
color: var(--bg-vanilla-400); | ||
font-size: 12px; | ||
font-weight: 400; | ||
line-height: 16px; | ||
} | ||
|
||
.account-option-item { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
&__selected { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 14px; | ||
width: 14px; | ||
background-color: rgba(192, 193, 195, 0.2); /* #C0C1C3 with 0.2 opacity */ | ||
border-radius: 2px; | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
frontend/src/container/CloudIntegrationPage/HeroSection/AccountActions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import './AccountActions.style.scss'; | ||
|
||
import { Color } from '@signozhq/design-tokens'; | ||
import { Button, Select } from 'antd'; | ||
import { SelectProps } from 'antd/lib'; | ||
import useUrlQuery from 'hooks/useUrlQuery'; | ||
import { Check, ChevronDown } from 'lucide-react'; | ||
import { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom-v5-compat'; | ||
|
||
import { CloudAccount } from '../ServicesSection/types'; | ||
|
||
interface AccountActionsProps { | ||
accounts: CloudAccount[]; | ||
} | ||
|
||
interface AccountOptionItemProps { | ||
label: React.ReactNode; | ||
isSelected: boolean; | ||
} | ||
|
||
function AccountOptionItem({ | ||
label, | ||
isSelected, | ||
}: AccountOptionItemProps): JSX.Element { | ||
return ( | ||
<div className="account-option-item"> | ||
{label} | ||
{isSelected && ( | ||
<div className="account-option-item__selected"> | ||
<Check size={12} color={Color.BG_VANILLA_100} /> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
function renderOption( | ||
option: any, | ||
activeAccountId: string | null, | ||
): JSX.Element { | ||
return ( | ||
<AccountOptionItem | ||
label={option.label} | ||
isSelected={option.value === activeAccountId} | ||
/> | ||
); | ||
} | ||
|
||
function AccountActions({ accounts }: AccountActionsProps): JSX.Element { | ||
const urlQuery = useUrlQuery(); | ||
const navigate = useNavigate(); | ||
const [activeAccountId, setActiveAccountId] = useState<string | null>( | ||
urlQuery.get('accountId') ?? accounts[0]?.cloud_account_id ?? null, | ||
); | ||
|
||
const selectOptions: SelectProps['options'] = accounts.map((account) => ({ | ||
value: account.cloud_account_id, | ||
label: account.cloud_account_id, | ||
})); | ||
|
||
return ( | ||
<div className="hero-section__actions"> | ||
{accounts.length ? ( | ||
<div className="hero-section__actions-with-account"> | ||
<Select | ||
value={`Account: ${activeAccountId}`} | ||
options={selectOptions} | ||
rootClassName="cloud-account-selector" | ||
placeholder="Select AWS Account" | ||
suffixIcon={<ChevronDown size={16} color={Color.BG_VANILLA_400} />} | ||
optionRender={(option): JSX.Element => | ||
renderOption(option, activeAccountId) | ||
} | ||
onChange={(value): void => { | ||
setActiveAccountId(value); | ||
urlQuery.set('accountId', value); | ||
navigate({ search: urlQuery.toString() }); | ||
}} | ||
/> | ||
<div className="hero-section__action-buttons"> | ||
<Button type="primary" className="hero-section__action-button primary"> | ||
Add New AWS Account | ||
</Button> | ||
<Button type="default" className="hero-section__action-button secondary"> | ||
Account Settings | ||
</Button> | ||
</div> | ||
</div> | ||
) : ( | ||
<Button type="primary" className="hero-section__action-button primary"> | ||
Integrate Now | ||
</Button> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default AccountActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters