2019-12-23 12:16:33 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import Badge from "./Badge";
|
|
|
|
|
import { Directions } from "utils/helpers";
|
|
|
|
|
import { ReduxActionTypes } from "constants/ReduxActionConstants";
|
|
|
|
|
import { getOnSelectAction, DropdownOnSelectActions } from "./dropdownHelpers";
|
2020-02-03 10:37:03 +00:00
|
|
|
import DropdownComponent, { CustomizedDropdownProps } from "./index";
|
2019-12-23 12:16:33 +00:00
|
|
|
import { Org } from "constants/orgConstants";
|
|
|
|
|
import { User } from "constants/userConstants";
|
2020-06-17 10:19:56 +00:00
|
|
|
import InviteUsersFormv2 from "pages/organization/InviteUsersFromv2";
|
|
|
|
|
import _ from "lodash";
|
2020-02-03 10:37:03 +00:00
|
|
|
import FormDialogComponent from "components/editorComponents/form/FormDialogComponent";
|
2020-06-17 10:19:56 +00:00
|
|
|
import { Button } from "@blueprintjs/core";
|
2019-12-23 12:16:33 +00:00
|
|
|
|
2020-02-03 10:37:03 +00:00
|
|
|
const switchdropdown = (
|
|
|
|
|
orgs: Org[],
|
|
|
|
|
currentOrg: Org,
|
|
|
|
|
): CustomizedDropdownProps => ({
|
|
|
|
|
sections: [
|
|
|
|
|
{
|
|
|
|
|
isSticky: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
options: orgs
|
|
|
|
|
.filter(org => org.id !== currentOrg.id)
|
|
|
|
|
.map(org => ({
|
|
|
|
|
content: org.name,
|
|
|
|
|
onSelect: () =>
|
|
|
|
|
getOnSelectAction(DropdownOnSelectActions.DISPATCH, {
|
|
|
|
|
type: ReduxActionTypes.SWITCH_ORGANIZATION_INIT,
|
|
|
|
|
payload: {
|
|
|
|
|
orgId: org.id,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
})),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
trigger: {
|
|
|
|
|
text: "Switch Organization",
|
|
|
|
|
},
|
|
|
|
|
openDirection: Directions.RIGHT,
|
|
|
|
|
openOnHover: true,
|
|
|
|
|
});
|
2019-12-23 12:16:33 +00:00
|
|
|
|
|
|
|
|
export const options = (
|
|
|
|
|
user: User,
|
2020-06-17 10:19:56 +00:00
|
|
|
orgName: string,
|
|
|
|
|
orgId: string,
|
|
|
|
|
): CustomizedDropdownProps => {
|
|
|
|
|
return {
|
|
|
|
|
sections: [
|
|
|
|
|
{
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
content: (
|
|
|
|
|
<Badge text={orgName} imageURL="https://via.placeholder.com/32" />
|
|
|
|
|
),
|
|
|
|
|
disabled: true,
|
|
|
|
|
shouldCloseDropdown: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
content: "Organization Settings",
|
|
|
|
|
onSelect: () =>
|
|
|
|
|
getOnSelectAction(DropdownOnSelectActions.REDIRECT, {
|
|
|
|
|
path: `/org/${orgId}/settings`,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
content: "Share",
|
|
|
|
|
onSelect: () => _.noop("Share option selected"),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
content: "Members",
|
|
|
|
|
onSelect: () =>
|
|
|
|
|
getOnSelectAction(DropdownOnSelectActions.REDIRECT, {
|
|
|
|
|
path: `/org/${orgId}/settings`,
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
trigger: {
|
|
|
|
|
icon: "ORG_ICON",
|
|
|
|
|
text: orgName,
|
|
|
|
|
outline: false,
|
2019-12-23 12:16:33 +00:00
|
|
|
},
|
2020-06-17 10:19:56 +00:00
|
|
|
openDirection: Directions.DOWN,
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-12-23 12:16:33 +00:00
|
|
|
|
|
|
|
|
export default options;
|