2020-09-16 11:50:47 +00:00
|
|
|
import React, { Component, useState } from "react";
|
2019-11-07 04:59:40 +00:00
|
|
|
import styled from "styled-components";
|
2020-09-16 11:50:47 +00:00
|
|
|
import { connect, useSelector, useDispatch } from "react-redux";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { AppState } from "reducers";
|
2020-09-16 11:50:47 +00:00
|
|
|
import { Card, Dialog, Classes as BlueprintClasses } from "@blueprintjs/core";
|
2019-11-07 04:59:40 +00:00
|
|
|
import {
|
|
|
|
|
getApplicationList,
|
|
|
|
|
getIsFetchingApplications,
|
|
|
|
|
getIsCreatingApplication,
|
2019-11-21 10:52:49 +00:00
|
|
|
getCreateApplicationError,
|
2020-02-03 12:19:10 +00:00
|
|
|
getIsDeletingApplication,
|
2020-06-01 05:12:10 +00:00
|
|
|
getUserApplicationsOrgsList,
|
2020-09-16 11:50:47 +00:00
|
|
|
getUserApplicationsOrgs,
|
2020-09-01 07:16:54 +00:00
|
|
|
getIsDuplicatingApplication,
|
2019-11-25 05:07:27 +00:00
|
|
|
} from "selectors/applicationSelectors";
|
2019-11-07 04:59:40 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionTypes,
|
|
|
|
|
ApplicationPayload,
|
2019-11-25 05:07:27 +00:00
|
|
|
} from "constants/ReduxActionConstants";
|
2019-12-23 12:16:33 +00:00
|
|
|
import PageWrapper from "pages/common/PageWrapper";
|
2019-11-21 10:52:49 +00:00
|
|
|
import SubHeader from "pages/common/SubHeader";
|
2019-12-23 12:16:33 +00:00
|
|
|
import PageSectionDivider from "pages/common/PageSectionDivider";
|
2019-11-21 10:52:49 +00:00
|
|
|
import ApplicationCard from "./ApplicationCard";
|
2019-11-07 04:59:40 +00:00
|
|
|
import CreateApplicationForm from "./CreateApplicationForm";
|
2020-08-12 11:41:56 +00:00
|
|
|
import OrgInviteUsersForm from "pages/organization/OrgInviteUsersForm";
|
2020-06-17 04:17:25 +00:00
|
|
|
import { PERMISSION_TYPE, isPermitted } from "./permissionHelpers";
|
2020-05-14 10:47:13 +00:00
|
|
|
import FormDialogComponent from "components/editorComponents/form/FormDialogComponent";
|
2020-05-27 13:36:06 +00:00
|
|
|
import { User } from "constants/userConstants";
|
|
|
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
|
|
|
|
import CreateOrganizationForm from "pages/organization/CreateOrganizationForm";
|
|
|
|
|
import { CREATE_ORGANIZATION_FORM_NAME } from "constants/forms";
|
2020-06-11 11:31:32 +00:00
|
|
|
import {
|
|
|
|
|
getOnSelectAction,
|
|
|
|
|
DropdownOnSelectActions,
|
|
|
|
|
} from "pages/common/CustomizedDropdown/dropdownHelpers";
|
2020-09-16 11:50:47 +00:00
|
|
|
import Button, { Size } from "components/ads/Button";
|
|
|
|
|
import Text, { TextType } from "components/ads/Text";
|
|
|
|
|
import Icon, { IconName, IconSize } from "components/ads/Icon";
|
|
|
|
|
import MenuItem from "components/ads/MenuItem";
|
|
|
|
|
import {
|
|
|
|
|
duplicateApplication,
|
|
|
|
|
updateApplication,
|
|
|
|
|
} from "actions/applicationActions";
|
|
|
|
|
import { Classes } from "components/ads/common";
|
|
|
|
|
import Menu from "components/ads/Menu";
|
|
|
|
|
import { Position } from "@blueprintjs/core/lib/esm/common/position";
|
2020-09-09 05:18:36 +00:00
|
|
|
import HelpModal from "components/designSystems/appsmith/help/HelpModal";
|
2020-09-16 11:50:47 +00:00
|
|
|
import { UpdateApplicationPayload } from "api/ApplicationApi";
|
2020-09-28 06:29:41 +00:00
|
|
|
import PerformanceTracker, {
|
|
|
|
|
PerformanceTransactionName,
|
|
|
|
|
} from "utils/PerformanceTracker";
|
2020-05-27 13:36:06 +00:00
|
|
|
|
|
|
|
|
const OrgDropDown = styled.div`
|
|
|
|
|
display: flex;
|
2020-08-03 11:44:18 +00:00
|
|
|
padding: ${props => props.theme.spaces[4]}px
|
|
|
|
|
${props => props.theme.spaces[4]}px;
|
2020-05-27 13:36:06 +00:00
|
|
|
font-size: ${props => props.theme.fontSizes[1]}px;
|
2020-06-03 13:54:42 +00:00
|
|
|
justify-content: space-between;
|
2020-09-28 05:06:06 +00:00
|
|
|
align-items: center;
|
2020-05-27 13:36:06 +00:00
|
|
|
`;
|
2019-11-07 04:59:40 +00:00
|
|
|
|
|
|
|
|
const ApplicationCardsWrapper = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-flow: row wrap;
|
2019-11-21 10:52:49 +00:00
|
|
|
justify-content: flex-start;
|
|
|
|
|
align-items: space-evenly;
|
2020-05-20 14:09:51 +00:00
|
|
|
font-size: ${props => props.theme.fontSizes[4]}px;
|
2019-11-07 04:59:40 +00:00
|
|
|
`;
|
|
|
|
|
|
2020-07-16 10:39:07 +00:00
|
|
|
const OrgSection = styled.div``;
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
const PaddingWrapper = styled.div`
|
|
|
|
|
width: ${props => props.theme.card.minWidth + props.theme.spaces[5] * 2}px;
|
|
|
|
|
margin: ${props => props.theme.spaces[5]}px
|
|
|
|
|
${props => props.theme.spaces[5]}px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledDialog = styled(Dialog)<{ setMaxWidth?: boolean }>`
|
|
|
|
|
&& {
|
|
|
|
|
background: white;
|
|
|
|
|
& .bp3-dialog-header {
|
|
|
|
|
padding: ${props => props.theme.spaces[4]}px
|
|
|
|
|
${props => props.theme.spaces[4]}px;
|
|
|
|
|
}
|
|
|
|
|
& .bp3-dialog-footer-actions {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
${props => props.setMaxWidth && `width: 100vh;`}
|
2020-06-17 04:17:25 +00:00
|
|
|
}
|
2020-05-20 14:09:51 +00:00
|
|
|
`;
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
const LeftPaneWrapper = styled.div`
|
|
|
|
|
// height: 50vh;
|
2020-09-17 07:57:19 +00:00
|
|
|
overflow: auto;
|
2020-09-16 11:50:47 +00:00
|
|
|
width: 256px;
|
|
|
|
|
display: flex;
|
|
|
|
|
padding-left: 16px;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 77px;
|
|
|
|
|
`;
|
|
|
|
|
const ApplicationContainer = styled.div`
|
|
|
|
|
height: calc(100vh - ${props => props.theme.homePage.search.height - 40}px);
|
2020-09-17 07:57:19 +00:00
|
|
|
overflow: auto;
|
2020-09-16 11:50:47 +00:00
|
|
|
padding-right: ${props => props.theme.homePage.leftPane.rightMargin}px;
|
|
|
|
|
margin-top: ${props => props.theme.homePage.search.height}px;
|
|
|
|
|
margin-left: ${props =>
|
|
|
|
|
props.theme.homePage.leftPane.width +
|
|
|
|
|
props.theme.homePage.leftPane.rightMargin +
|
|
|
|
|
props.theme.homePage.leftPane.leftPadding}px;
|
|
|
|
|
width: calc(
|
|
|
|
|
100% -
|
|
|
|
|
${props =>
|
|
|
|
|
props.theme.homePage.leftPane.width +
|
|
|
|
|
props.theme.homePage.leftPane.rightMargin +
|
|
|
|
|
props.theme.homePage.leftPane.leftPadding}px
|
|
|
|
|
);
|
2020-08-03 11:44:18 +00:00
|
|
|
`;
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
const ItemWrapper = styled.div`
|
|
|
|
|
padding: 9px 15px;
|
|
|
|
|
`;
|
|
|
|
|
const StyledIcon = styled(Icon)`
|
|
|
|
|
margin-right: 11px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
function Item(props: { label: string; textType: TextType; icon?: IconName }) {
|
|
|
|
|
return (
|
|
|
|
|
<ItemWrapper>
|
|
|
|
|
{props.icon && <StyledIcon />}
|
|
|
|
|
<Text type={props.textType}> {props.label}</Text>
|
|
|
|
|
</ItemWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
function LeftPaneSection(props: { heading: string; children?: any }) {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{/* <MenuItem text={props.heading}/> */}
|
|
|
|
|
<Item label={props.heading} textType={TextType.H6}></Item>
|
|
|
|
|
{props.children}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const StyledAnchor = styled.a`
|
|
|
|
|
position: relative;
|
|
|
|
|
top: -24px;
|
|
|
|
|
// width: 0;
|
|
|
|
|
// height: 0;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const WorkpsacesNavigator = styled.div`
|
2020-09-17 07:57:19 +00:00
|
|
|
overflow: auto;
|
2020-09-16 11:50:47 +00:00
|
|
|
height: calc(100vh - ${props => props.theme.homePage.header + 36 + 25}px);
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const textIconStyles = (props: { color: string; hover: string }) => {
|
|
|
|
|
return `
|
|
|
|
|
&&&&&& {
|
|
|
|
|
.${Classes.TEXT},.${Classes.ICON} svg path {
|
|
|
|
|
color: ${props.color};
|
|
|
|
|
stroke: ${props.color};
|
|
|
|
|
fill: ${props.color};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
.${Classes.TEXT},.${Classes.ICON} svg path {
|
|
|
|
|
color: ${props.hover};
|
|
|
|
|
stroke: ${props.hover};
|
|
|
|
|
fill: ${props.hover};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const NewWorkspaceWrapper = styled.div`
|
|
|
|
|
${props => {
|
|
|
|
|
return `${textIconStyles({
|
2020-09-23 14:06:50 +00:00
|
|
|
color: props.theme.colors.applications.textColor,
|
|
|
|
|
hover: props.theme.colors.applications.hover.textColor,
|
2020-09-16 11:50:47 +00:00
|
|
|
})}`;
|
|
|
|
|
}}
|
2020-08-18 06:40:11 +00:00
|
|
|
`;
|
|
|
|
|
|
2020-05-20 14:09:51 +00:00
|
|
|
const ApplicationAddCardWrapper = styled(Card)`
|
2020-05-14 10:47:13 +00:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2020-09-28 05:06:06 +00:00
|
|
|
justify-content: center;
|
2020-09-23 14:06:50 +00:00
|
|
|
background: ${props => props.theme.colors.applications.bg};
|
2020-05-14 10:47:13 +00:00
|
|
|
align-items: center;
|
|
|
|
|
width: ${props => props.theme.card.minWidth}px;
|
|
|
|
|
height: ${props => props.theme.card.minHeight}px;
|
|
|
|
|
position: relative;
|
2020-08-18 06:40:11 +00:00
|
|
|
box-shadow: none;
|
2020-09-16 11:50:47 +00:00
|
|
|
border-radius: 0;
|
|
|
|
|
padding: 0;
|
2020-09-28 05:06:06 +00:00
|
|
|
margin: ${props => props.theme.spaces[11] - 2}px
|
2020-05-14 10:47:13 +00:00
|
|
|
${props => props.theme.spaces[5]}px;
|
|
|
|
|
a {
|
|
|
|
|
display: block;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0;
|
|
|
|
|
top: 0;
|
|
|
|
|
height: calc(100% - ${props => props.theme.card.titleHeight}px);
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
2020-06-18 12:31:56 +00:00
|
|
|
cursor: pointer;
|
2020-09-16 11:50:47 +00:00
|
|
|
&:hover {
|
2020-09-23 14:06:50 +00:00
|
|
|
background: ${props => props.theme.colors.applications.hover.bg};
|
2020-09-16 11:50:47 +00:00
|
|
|
}
|
|
|
|
|
${props => {
|
|
|
|
|
return `${textIconStyles({
|
2020-09-23 14:06:50 +00:00
|
|
|
color: props.theme.colors.applications.textColor,
|
|
|
|
|
hover: props.theme.colors.applications.hover.textColor,
|
2020-09-16 11:50:47 +00:00
|
|
|
})}`;
|
|
|
|
|
}}
|
2020-05-14 10:47:13 +00:00
|
|
|
`;
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
function LeftPane() {
|
|
|
|
|
const userOrgs = useSelector(getUserApplicationsOrgs);
|
|
|
|
|
const NewWorkspaceTrigger = (
|
|
|
|
|
<NewWorkspaceWrapper>
|
|
|
|
|
<MenuItem
|
|
|
|
|
key={"new-workspace"}
|
|
|
|
|
text={"Create Organization"}
|
|
|
|
|
icon="plus"
|
|
|
|
|
/>
|
|
|
|
|
</NewWorkspaceWrapper>
|
|
|
|
|
);
|
|
|
|
|
return (
|
|
|
|
|
<LeftPaneWrapper>
|
|
|
|
|
<LeftPaneSection heading="ORGANIZATIONS">
|
|
|
|
|
<WorkpsacesNavigator>
|
|
|
|
|
<FormDialogComponent
|
|
|
|
|
trigger={NewWorkspaceTrigger}
|
|
|
|
|
Form={CreateOrganizationForm}
|
|
|
|
|
title={CREATE_ORGANIZATION_FORM_NAME}
|
|
|
|
|
/>
|
|
|
|
|
{/* {CreateOrg} */}
|
|
|
|
|
{userOrgs &&
|
|
|
|
|
userOrgs.map((org: any) => (
|
|
|
|
|
<MenuItem
|
|
|
|
|
icon="workspace"
|
|
|
|
|
key={org.organization.name}
|
|
|
|
|
href={`${window.location.pathname}#${org.organization.name}`}
|
|
|
|
|
text={org.organization.name}
|
2020-10-09 05:25:00 +00:00
|
|
|
ellipsize={20}
|
2020-09-16 11:50:47 +00:00
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</WorkpsacesNavigator>
|
|
|
|
|
</LeftPaneSection>
|
|
|
|
|
{/* <LeftPaneSection heading="GETTING STARTED"></LeftPaneSection> */}
|
|
|
|
|
</LeftPaneWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CreateNewLabel = styled(Text)`
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
`;
|
|
|
|
|
|
2020-10-08 09:49:15 +00:00
|
|
|
const OrgNameElement = styled(Text)`
|
|
|
|
|
max-width: 500px;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
display: block;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const OrgNameHolder = styled(Text)`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const OrgNameInMenu = styled(Text)`
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
display: block;
|
|
|
|
|
padding: 9px ${props => props.theme.spaces[6]}px;
|
|
|
|
|
`;
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
const OrgNameWrapper = styled.div<{ disabled?: boolean }>`
|
|
|
|
|
cursor: ${props => (!props.disabled ? "pointer" : "inherit")};
|
|
|
|
|
${props => {
|
|
|
|
|
const color = props.disabled
|
2020-09-23 14:06:50 +00:00
|
|
|
? props.theme.colors.applications.orgColor
|
|
|
|
|
: props.theme.colors.applications.hover.orgColor[9];
|
2020-09-16 11:50:47 +00:00
|
|
|
return `${textIconStyles({
|
|
|
|
|
color: color,
|
|
|
|
|
hover: color,
|
|
|
|
|
})}`;
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
.${Classes.ICON} {
|
|
|
|
|
display: ${props => (!props.disabled ? "inline" : "none")};;
|
|
|
|
|
margin-left: 8px;
|
2020-09-23 14:06:50 +00:00
|
|
|
color: ${props => props.theme.colors.applications.iconColor};
|
2020-09-16 11:50:47 +00:00
|
|
|
}
|
2020-06-11 11:31:32 +00:00
|
|
|
`;
|
|
|
|
|
|
2020-09-16 11:50:47 +00:00
|
|
|
const ApplicationsSection = () => {
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
const userOrgs = useSelector(getUserApplicationsOrgsList);
|
|
|
|
|
const currentUser = useSelector(getCurrentUser);
|
|
|
|
|
const deleteApplication = (applicationId: string) => {
|
|
|
|
|
if (applicationId && applicationId.length > 0) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: ReduxActionTypes.DELETE_APPLICATION_INIT,
|
|
|
|
|
payload: {
|
|
|
|
|
applicationId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const updateApplicationDispatch = (
|
|
|
|
|
id: string,
|
|
|
|
|
data: UpdateApplicationPayload,
|
|
|
|
|
) => {
|
|
|
|
|
dispatch(updateApplication(id, data));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const duplicateApplicationDispatch = (applicationId: string) => {
|
|
|
|
|
dispatch(duplicateApplication(applicationId));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const [selectedOrgId, setSelectedOrgId] = useState();
|
|
|
|
|
const Form: any = OrgInviteUsersForm;
|
|
|
|
|
const OrgMenu = (props: {
|
|
|
|
|
orgName: string;
|
|
|
|
|
orgId: string;
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
setSelectedOrgId: Function;
|
|
|
|
|
}) => {
|
|
|
|
|
const { orgName, orgId, disabled } = props;
|
|
|
|
|
|
|
|
|
|
const OrgName = (
|
|
|
|
|
<OrgNameWrapper disabled={disabled} className="t--org-name">
|
|
|
|
|
<StyledAnchor id={orgName}></StyledAnchor>
|
2020-10-08 09:49:15 +00:00
|
|
|
<OrgNameHolder type={TextType.H1}>
|
|
|
|
|
<OrgNameElement type={TextType.H1}>{orgName}</OrgNameElement>
|
2020-09-16 11:50:47 +00:00
|
|
|
<Icon name="downArrow" size={IconSize.XXS}></Icon>
|
2020-10-08 09:49:15 +00:00
|
|
|
</OrgNameHolder>
|
2020-09-16 11:50:47 +00:00
|
|
|
</OrgNameWrapper>
|
|
|
|
|
);
|
|
|
|
|
return disabled ? (
|
|
|
|
|
OrgName
|
|
|
|
|
) : (
|
|
|
|
|
<Menu
|
|
|
|
|
target={OrgName}
|
|
|
|
|
position={Position.BOTTOM_RIGHT}
|
|
|
|
|
className="t--org-name"
|
|
|
|
|
>
|
2020-10-08 09:49:15 +00:00
|
|
|
<OrgNameInMenu type={TextType.H5}>{orgName}</OrgNameInMenu>
|
2020-09-16 11:50:47 +00:00
|
|
|
<MenuItem
|
|
|
|
|
icon="general"
|
|
|
|
|
text="Organization Settings"
|
|
|
|
|
onSelect={() =>
|
|
|
|
|
getOnSelectAction(DropdownOnSelectActions.REDIRECT, {
|
|
|
|
|
path: `/org/${orgId}/settings/general`,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<MenuItem
|
|
|
|
|
text="Share"
|
|
|
|
|
icon="share"
|
|
|
|
|
onSelect={() => setSelectedOrgId(orgId)}
|
|
|
|
|
></MenuItem>
|
|
|
|
|
<MenuItem
|
|
|
|
|
icon="user"
|
|
|
|
|
text="Members"
|
|
|
|
|
onSelect={() =>
|
|
|
|
|
getOnSelectAction(DropdownOnSelectActions.REDIRECT, {
|
|
|
|
|
path: `/org/${orgId}/settings/members`,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</Menu>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ApplicationContainer className="t--applications-container">
|
|
|
|
|
{userOrgs &&
|
|
|
|
|
userOrgs.map((organizationObject: any, index: number) => {
|
|
|
|
|
const { organization, applications } = organizationObject;
|
|
|
|
|
const hasManageOrgPermissions = isPermitted(
|
|
|
|
|
organization.userPermissions,
|
|
|
|
|
PERMISSION_TYPE.MANAGE_ORGANIZATION,
|
|
|
|
|
);
|
|
|
|
|
return (
|
|
|
|
|
<OrgSection className="t--org-section" key={index}>
|
|
|
|
|
<OrgDropDown>
|
|
|
|
|
{currentUser && (
|
|
|
|
|
<OrgMenu
|
|
|
|
|
setSelectedOrgId={setSelectedOrgId}
|
|
|
|
|
orgId={organization.id}
|
|
|
|
|
orgName={organization.name}
|
|
|
|
|
disabled={!hasManageOrgPermissions}
|
|
|
|
|
></OrgMenu>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{hasManageOrgPermissions && (
|
|
|
|
|
<StyledDialog
|
|
|
|
|
canOutsideClickClose={false}
|
|
|
|
|
canEscapeKeyClose={false}
|
|
|
|
|
title={`Invite Users to ${organization.name}`}
|
|
|
|
|
onClose={() => setSelectedOrgId("")}
|
|
|
|
|
isOpen={selectedOrgId === organization.id}
|
|
|
|
|
setMaxWidth
|
|
|
|
|
>
|
|
|
|
|
<div className={BlueprintClasses.DIALOG_BODY}>
|
|
|
|
|
<Form orgId={organization.id} />
|
|
|
|
|
</div>
|
|
|
|
|
</StyledDialog>
|
|
|
|
|
)}
|
|
|
|
|
{isPermitted(
|
|
|
|
|
organization.userPermissions,
|
|
|
|
|
PERMISSION_TYPE.INVITE_USER_TO_ORGANIZATION,
|
|
|
|
|
) && (
|
|
|
|
|
<FormDialogComponent
|
|
|
|
|
trigger={
|
|
|
|
|
<Button text={"Share"} icon={"share"} size={Size.small} />
|
|
|
|
|
}
|
|
|
|
|
canOutsideClickClose={true}
|
|
|
|
|
Form={OrgInviteUsersForm}
|
|
|
|
|
orgId={organization.id}
|
|
|
|
|
title={`Invite Users to ${organization.name}`}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</OrgDropDown>
|
|
|
|
|
<ApplicationCardsWrapper key={organization.id}>
|
2020-09-23 14:06:50 +00:00
|
|
|
{isPermitted(
|
|
|
|
|
organization.userPermissions,
|
|
|
|
|
PERMISSION_TYPE.CREATE_APPLICATION,
|
|
|
|
|
) && (
|
|
|
|
|
<PaddingWrapper>
|
|
|
|
|
<FormDialogComponent
|
|
|
|
|
permissions={organization.userPermissions}
|
|
|
|
|
permissionRequired={PERMISSION_TYPE.CREATE_APPLICATION}
|
|
|
|
|
trigger={
|
|
|
|
|
<ApplicationAddCardWrapper>
|
|
|
|
|
<Icon
|
|
|
|
|
className="t--create-app-popup"
|
|
|
|
|
name={"plus"}
|
|
|
|
|
size={IconSize.LARGE}
|
|
|
|
|
></Icon>
|
|
|
|
|
<CreateNewLabel
|
|
|
|
|
type={TextType.H4}
|
|
|
|
|
className="createnew"
|
|
|
|
|
// cypressSelector={"t--create-new-app"}
|
|
|
|
|
>
|
|
|
|
|
Create New
|
|
|
|
|
</CreateNewLabel>
|
|
|
|
|
</ApplicationAddCardWrapper>
|
|
|
|
|
}
|
|
|
|
|
Form={CreateApplicationForm}
|
|
|
|
|
orgId={organization.id}
|
|
|
|
|
title={"Create Application"}
|
|
|
|
|
/>
|
|
|
|
|
</PaddingWrapper>
|
|
|
|
|
)}
|
2020-09-16 11:50:47 +00:00
|
|
|
{applications.map((application: any) => {
|
|
|
|
|
return (
|
|
|
|
|
application.pages?.length > 0 && (
|
2020-09-23 14:06:50 +00:00
|
|
|
<PaddingWrapper>
|
|
|
|
|
<ApplicationCard
|
|
|
|
|
key={application.id}
|
|
|
|
|
application={application}
|
|
|
|
|
delete={deleteApplication}
|
|
|
|
|
update={updateApplicationDispatch}
|
|
|
|
|
duplicate={duplicateApplicationDispatch}
|
|
|
|
|
/>
|
|
|
|
|
</PaddingWrapper>
|
2020-09-16 11:50:47 +00:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
<PageSectionDivider />
|
|
|
|
|
</ApplicationCardsWrapper>
|
|
|
|
|
</OrgSection>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
<HelpModal page={"Applications"} />
|
|
|
|
|
</ApplicationContainer>
|
|
|
|
|
);
|
|
|
|
|
};
|
2019-11-07 04:59:40 +00:00
|
|
|
type ApplicationProps = {
|
|
|
|
|
applicationList: ApplicationPayload[];
|
|
|
|
|
createApplication: (appName: string) => void;
|
2020-09-16 11:50:47 +00:00
|
|
|
searchApplications: (keyword: string) => void;
|
2019-11-07 04:59:40 +00:00
|
|
|
isCreatingApplication: boolean;
|
2019-11-21 10:52:49 +00:00
|
|
|
isFetchingApplications: boolean;
|
|
|
|
|
createApplicationError?: string;
|
2020-01-27 08:24:58 +00:00
|
|
|
deleteApplication: (id: string) => void;
|
2020-02-03 12:19:10 +00:00
|
|
|
deletingApplication: boolean;
|
2020-09-01 07:16:54 +00:00
|
|
|
duplicatingApplication: boolean;
|
2020-05-27 13:36:06 +00:00
|
|
|
getAllApplication: () => void;
|
2020-06-10 08:29:21 +00:00
|
|
|
userOrgs: any;
|
2020-05-27 13:36:06 +00:00
|
|
|
currentUser?: User;
|
2019-11-07 04:59:40 +00:00
|
|
|
};
|
2020-06-11 11:31:32 +00:00
|
|
|
class Applications extends Component<
|
|
|
|
|
ApplicationProps,
|
|
|
|
|
{ selectedOrgId: string }
|
|
|
|
|
> {
|
|
|
|
|
constructor(props: ApplicationProps) {
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
|
selectedOrgId: "",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-07 04:59:40 +00:00
|
|
|
componentDidMount() {
|
2020-09-28 06:29:41 +00:00
|
|
|
PerformanceTracker.stopTracking(PerformanceTransactionName.LOGIN_CLICK);
|
|
|
|
|
PerformanceTracker.stopTracking(PerformanceTransactionName.SIGN_UP);
|
2020-05-27 13:36:06 +00:00
|
|
|
this.props.getAllApplication();
|
2019-11-07 04:59:40 +00:00
|
|
|
}
|
|
|
|
|
public render() {
|
|
|
|
|
return (
|
2019-12-23 12:16:33 +00:00
|
|
|
<PageWrapper displayName="Applications">
|
2020-09-16 11:50:47 +00:00
|
|
|
<LeftPane />
|
2019-12-23 12:16:33 +00:00
|
|
|
<SubHeader
|
|
|
|
|
search={{
|
2020-09-16 11:50:47 +00:00
|
|
|
placeholder: "Search for apps...",
|
2020-01-20 08:07:00 +00:00
|
|
|
queryFn: this.props.searchApplications,
|
2019-12-23 12:16:33 +00:00
|
|
|
}}
|
|
|
|
|
/>
|
2020-09-16 11:50:47 +00:00
|
|
|
<ApplicationsSection></ApplicationsSection>
|
2019-12-23 12:16:33 +00:00
|
|
|
</PageWrapper>
|
2019-11-07 04:59:40 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-01 07:16:54 +00:00
|
|
|
|
2019-11-07 04:59:40 +00:00
|
|
|
const mapStateToProps = (state: AppState) => ({
|
|
|
|
|
applicationList: getApplicationList(state),
|
|
|
|
|
isFetchingApplications: getIsFetchingApplications(state),
|
|
|
|
|
isCreatingApplication: getIsCreatingApplication(state),
|
2019-11-21 10:52:49 +00:00
|
|
|
createApplicationError: getCreateApplicationError(state),
|
2020-02-03 12:19:10 +00:00
|
|
|
deletingApplication: getIsDeletingApplication(state),
|
2020-09-01 07:16:54 +00:00
|
|
|
duplicatingApplication: getIsDuplicatingApplication(state),
|
2020-06-10 08:29:21 +00:00
|
|
|
userOrgs: getUserApplicationsOrgsList(state),
|
2020-05-27 13:36:06 +00:00
|
|
|
currentUser: getCurrentUser(state),
|
2019-11-07 04:59:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch: any) => ({
|
2020-05-27 13:36:06 +00:00
|
|
|
getAllApplication: () =>
|
|
|
|
|
dispatch({ type: ReduxActionTypes.GET_ALL_APPLICATION_INIT }),
|
2019-11-07 04:59:40 +00:00
|
|
|
createApplication: (appName: string) => {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: ReduxActionTypes.CREATE_APPLICATION_INIT,
|
|
|
|
|
payload: {
|
|
|
|
|
name: appName,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
2020-01-20 08:07:00 +00:00
|
|
|
searchApplications: (keyword: string) => {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: ReduxActionTypes.SEARCH_APPLICATIONS,
|
|
|
|
|
payload: {
|
|
|
|
|
keyword,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
2019-11-07 04:59:40 +00:00
|
|
|
});
|
|
|
|
|
|
2019-11-22 14:02:55 +00:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Applications);
|