PromucFlow_constructor/app/client/src/ce/pages/Home/LeftPaneBottomSection.tsx

130 lines
3.9 KiB
TypeScript
Raw Normal View History

2022-03-03 10:56:53 +00:00
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import styled from "styled-components";
feat: Renamed design system package (#19854) ## Description This PR includes changes for renaming design system package. Since we are building new package for the refactored design system components, the old package is renaming to design-system-old. Fixes #19536 ## Type of change - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-01-23 03:50:47 +00:00
import { MenuItem } from "design-system-old";
2022-03-03 10:56:53 +00:00
import {
ADMIN_SETTINGS,
APPSMITH_DISPLAY_VERSION,
2022-03-03 10:56:53 +00:00
createMessage,
DOCUMENTATION,
WELCOME_TOUR,
} from "@appsmith/constants/messages";
import { getIsFetchingApplications } from "selectors/applicationSelectors";
import { getOnboardingWorkspaces } from "selectors/onboardingSelectors";
2022-03-03 10:56:53 +00:00
import { getAppsmithConfigs } from "@appsmith/configs";
import AnalyticsUtil from "utils/AnalyticsUtil";
import { howMuchTimeBeforeText } from "utils/helpers";
import { onboardingCreateApplication } from "actions/onboardingActions";
import ProductUpdatesModal from "pages/Applications/ProductUpdatesModal";
import { Colors } from "constants/Colors";
import {
DropdownOnSelectActions,
getOnSelectAction,
} from "pages/common/CustomizedDropdown/dropdownHelpers";
import { getCurrentUser } from "selectors/usersSelectors";
import {
getDefaultAdminSettingsPath,
showAdminSettings,
} from "@appsmith/utils/adminSettingsHelpers";
import { getTenantPermissions } from "@appsmith/selectors/tenantSelectors";
2022-03-03 10:56:53 +00:00
export const Wrapper = styled.div`
2022-03-03 10:56:53 +00:00
padding-bottom: ${(props) => props.theme.spaces[3]}px;
background-color: ${Colors.WHITE};
width: 100%;
margin-top: auto;
2022-03-03 10:56:53 +00:00
& .ads-dialog-trigger {
margin-top: ${(props) => props.theme.spaces[1]}px;
}
& .ads-dialog-trigger > div {
position: initial;
width: 92%;
padding: ${(props) =>
`${props.theme.spaces[0]}px ${props.theme.spaces[6]}px`};
}
`;
export const LeftPaneVersionData = styled.div`
2022-03-03 10:56:53 +00:00
display: flex;
justify-content: space-between;
color: ${Colors.MIRAGE_2};
font-size: 8px;
width: 92%;
margin-top: ${(props) => props.theme.spaces[3]}px;
`;
function LeftPaneBottomSection() {
const dispatch = useDispatch();
const onboardingWorkspaces = useSelector(getOnboardingWorkspaces);
2022-03-03 10:56:53 +00:00
const isFetchingApplications = useSelector(getIsFetchingApplications);
const { appVersion, cloudHosting } = getAppsmithConfigs();
2022-03-03 10:56:53 +00:00
const howMuchTimeBefore = howMuchTimeBeforeText(appVersion.releaseDate);
const user = useSelector(getCurrentUser);
const tenantPermissions = useSelector(getTenantPermissions);
2022-03-03 10:56:53 +00:00
return (
<Wrapper>
{showAdminSettings(user) && !isFetchingApplications && (
<MenuItem
className="admin-settings-menu-option"
icon="setting"
onSelect={() => {
getOnSelectAction(DropdownOnSelectActions.REDIRECT, {
path: getDefaultAdminSettingsPath({
isSuperUser: user?.isSuperUser,
tenantPermissions,
}),
});
}}
text={createMessage(ADMIN_SETTINGS)}
/>
)}
2022-03-03 10:56:53 +00:00
<MenuItem
icon="discord"
onSelect={() => {
window.open("https://discord.gg/rBTTVJp", "_blank");
}}
text={"Join our Discord"}
/>
<MenuItem
icon="book"
onSelect={() => {
window.open("https://docs.appsmith.com/", "_blank");
}}
text={createMessage(DOCUMENTATION)}
/>
<MenuItem
containerClassName={"t--welcome-tour"}
icon="guide"
onSelect={() => {
if (!isFetchingApplications && !!onboardingWorkspaces.length) {
2022-03-03 10:56:53 +00:00
AnalyticsUtil.logEvent("WELCOME_TOUR_CLICK");
dispatch(onboardingCreateApplication());
}
}}
text={createMessage(WELCOME_TOUR)}
/>
2022-03-03 10:56:53 +00:00
<ProductUpdatesModal />
<LeftPaneVersionData>
<span>
{createMessage(
APPSMITH_DISPLAY_VERSION,
appVersion.edition,
appVersion.id,
cloudHosting,
)}
</span>
2022-03-03 10:56:53 +00:00
{howMuchTimeBefore !== "" && (
<span>Released {howMuchTimeBefore} ago</span>
)}
</LeftPaneVersionData>
</Wrapper>
);
}
export default LeftPaneBottomSection;