-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small Refactor: Do not fetch account id if not on service map page (#169
- Loading branch information
1 parent
5addb24
commit 499c093
Showing
3 changed files
with
89 additions
and
29 deletions.
There are no files selected for viewing
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,41 @@ | ||
import { XrayDataSource } from 'DataSource'; | ||
import { useAccountIds } from './useAccountIds'; | ||
import { XrayQuery } from '../../types'; | ||
import { TimeRange } from '@grafana/data'; | ||
import { config } from '@grafana/runtime'; | ||
import React from 'react'; | ||
import { InlineFormLabel, MultiSelect } from '@grafana/ui'; | ||
|
||
type Props = { | ||
datasource: XrayDataSource; | ||
query: XrayQuery; | ||
range?: TimeRange; | ||
onChange: (items: string[]) => void; | ||
}; | ||
|
||
export const AccountIdDropdown = (props: Props) => { | ||
const accountIds = useAccountIds(props.datasource, props.query, props.range); | ||
const hasStoredAccountIdFilter = !!(props.query.accountIds && props.query.accountIds.length); | ||
const showAccountIdDropdown = config.featureToggles.cloudWatchCrossAccountQuerying || hasStoredAccountIdFilter; | ||
|
||
if (!showAccountIdDropdown) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="gf-form"> | ||
<InlineFormLabel className="query-keyword" width="auto"> | ||
AccountId | ||
</InlineFormLabel> | ||
<MultiSelect | ||
options={(accountIds || []).map((accountId: string) => ({ | ||
value: accountId, | ||
label: accountId, | ||
}))} | ||
value={props.query.accountIds} | ||
onChange={(items) => props.onChange(items.map((item) => item.value || ''))} | ||
placeholder={'All'} | ||
/> | ||
</div> | ||
); | ||
}; |
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