mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-06 19:19:56 +00:00
Migrated Hosted Explorer to React (#360)
Co-authored-by: Victor Meng <vimeng@microsoft.com> Co-authored-by: Steve Faulkner <stfaul@microsoft.com>
This commit is contained in:
38
src/Platform/Hosted/Components/SwitchSubscription.tsx
Normal file
38
src/Platform/Hosted/Components/SwitchSubscription.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Dropdown } from "office-ui-fabric-react/lib/Dropdown";
|
||||
import * as React from "react";
|
||||
import { FunctionComponent } from "react";
|
||||
import { Subscription } from "../../../Contracts/DataModels";
|
||||
|
||||
interface Props {
|
||||
subscriptions: Subscription[];
|
||||
selectedSubscription: Subscription;
|
||||
setSelectedSubscriptionId: (id: string) => void;
|
||||
}
|
||||
|
||||
export const SwitchSubscription: FunctionComponent<Props> = ({
|
||||
subscriptions,
|
||||
setSelectedSubscriptionId,
|
||||
selectedSubscription
|
||||
}: Props) => {
|
||||
return (
|
||||
<Dropdown
|
||||
label="Subscription"
|
||||
className="accountSwitchSubscriptionDropdown"
|
||||
options={subscriptions?.map(sub => {
|
||||
return {
|
||||
key: sub.subscriptionId,
|
||||
text: sub.displayName,
|
||||
data: sub
|
||||
};
|
||||
})}
|
||||
onChange={(_, option) => {
|
||||
setSelectedSubscriptionId(String(option.key));
|
||||
}}
|
||||
defaultSelectedKey={selectedSubscription?.subscriptionId}
|
||||
placeholder={subscriptions && subscriptions.length === 0 ? "No Subscriptions Found" : "Select a Subscription"}
|
||||
styles={{
|
||||
callout: "accountSwitchSubscriptionDropdownMenu"
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user