## Description Added ESLint rule to force blank lines between statements. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > 🔴 🔴 🔴 Some tests have failed. > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10924926728> > Commit: 34f57714a1575ee04e94e03cbcaf95e57a96c86c > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10924926728&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail" target="_blank">Cypress dashboard</a>. > Tags: @tag.All > Spec: > The following are new failures, please fix them before merging the PR: <ol> > <li>cypress/e2e/Regression/ClientSide/Anvil/AnvilModal_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCheckboxGroupWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCurrencyInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilIconButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInlineButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilParagraphWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilPhoneInputWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilStatsWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchGroupWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilToolbarButtonWidgetSnapshot_spec.ts > <li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilZoneSectionWidgetSnapshot_spec.ts</ol> > <a href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master" target="_blank">List of identified flaky tests</a>. > <hr>Wed, 18 Sep 2024 16:33:36 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No --------- Co-authored-by: Valera Melnikov <valera@appsmith.com>
165 lines
5.0 KiB
TypeScript
165 lines
5.0 KiB
TypeScript
import React, { useEffect, useState } from "react";
|
|
import { useLocation, useParams } from "react-router-dom";
|
|
import { getFetchedWorkspaces } from "ee/selectors/workspaceSelectors";
|
|
import { useSelector, useDispatch } from "react-redux";
|
|
import styled from "styled-components";
|
|
import { useMediaQuery } from "react-responsive";
|
|
import { BackButton, StickyHeader } from "components/utils/helperComponents";
|
|
import WorkspaceInviteUsersForm from "pages/workspace/WorkspaceInviteUsersForm";
|
|
import { SettingsPageHeader } from "./SettingsPageHeader";
|
|
import { isPermitted, PERMISSION_TYPE } from "ee/utils/permissionHelpers";
|
|
import {
|
|
createMessage,
|
|
DOCUMENTATION,
|
|
INVITE_USERS_PLACEHOLDER,
|
|
SEARCH_USERS,
|
|
} from "ee/constants/messages";
|
|
import FormDialogComponent from "components/editorComponents/form/FormDialogComponent";
|
|
import { debounce } from "lodash";
|
|
import { WorkspaceSettingsTabs } from "ee/components/WorkspaceSettingsTabs";
|
|
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
|
|
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";
|
|
import { fetchAllWorkspaces } from "ee/actions/workspaceActions";
|
|
|
|
const SettingsWrapper = styled.div<{
|
|
isMobile?: boolean;
|
|
}>`
|
|
width: ${(props) => (props.isMobile ? "345px" : "978px")};
|
|
margin: var(--ads-v2-spaces-7) auto;
|
|
height: 100%;
|
|
padding-left: var(--ads-v2-spaces-7);
|
|
overflow: hidden;
|
|
padding-left: ${(props) =>
|
|
props.isMobile ? "0" : "var(--ads-v2-spaces-7);"};
|
|
&::-webkit-scrollbar {
|
|
width: 0px;
|
|
}
|
|
.tabs-wrapper {
|
|
height: 100%;
|
|
${({ isMobile }) =>
|
|
!isMobile &&
|
|
`
|
|
padding: 106px 0 0;
|
|
`}
|
|
}
|
|
`;
|
|
|
|
const StyledStickyHeader = styled(StickyHeader)<{ isMobile?: boolean }>`
|
|
/* padding-top: 24px; */
|
|
${({ isMobile }) =>
|
|
!isMobile &&
|
|
`
|
|
top: 72px;
|
|
position: fixed;
|
|
width: 954px;
|
|
`}
|
|
`;
|
|
|
|
enum TABS {
|
|
GENERAL = "general",
|
|
MEMBERS = "members",
|
|
}
|
|
|
|
export default function Settings() {
|
|
const { workspaceId } = useParams<{ workspaceId: string }>();
|
|
const currentWorkspace = useSelector(getFetchedWorkspaces).filter(
|
|
(el) => el.id === workspaceId,
|
|
)[0];
|
|
const location = useLocation();
|
|
const dispatch = useDispatch();
|
|
|
|
const [showModal, setShowModal] = useState(false);
|
|
const [searchValue, setSearchValue] = useState("");
|
|
|
|
const [pageTitle, setPageTitle] = useState<string>("");
|
|
const [tabArrLen, setTabArrLen] = useState<number>(0);
|
|
|
|
const isGACEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
|
|
|
|
const currentTab = location.pathname.split("/").pop();
|
|
|
|
const isMemberofTheWorkspace = isPermitted(
|
|
currentWorkspace?.userPermissions || [],
|
|
PERMISSION_TYPE.INVITE_USER_TO_WORKSPACE,
|
|
);
|
|
const hasManageWorkspacePermissions = isPermitted(
|
|
currentWorkspace?.userPermissions,
|
|
PERMISSION_TYPE.MANAGE_WORKSPACE,
|
|
);
|
|
const showMembersTab =
|
|
isMemberofTheWorkspace && hasManageWorkspacePermissions;
|
|
|
|
const onButtonClick = () => {
|
|
setShowModal(true);
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (!currentWorkspace) {
|
|
dispatch(fetchAllWorkspaces({ fetchEntities: true }));
|
|
} else {
|
|
setPageTitle(`${currentWorkspace?.name}`);
|
|
}
|
|
}, [dispatch, currentWorkspace]);
|
|
|
|
// TODO: Fix this the next time the file is edited
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const pageMenuItems: any[] = [
|
|
{
|
|
icon: "book-line",
|
|
className: "documentation-page-menu-item",
|
|
onSelect: () => {},
|
|
text: createMessage(DOCUMENTATION),
|
|
},
|
|
];
|
|
|
|
const isMembersPage = tabArrLen > 1 && currentTab === TABS.MEMBERS;
|
|
|
|
const onSearch = debounce((search: string) => {
|
|
if (search.trim().length > 0) {
|
|
setSearchValue(search);
|
|
} else {
|
|
setSearchValue("");
|
|
}
|
|
}, 300);
|
|
|
|
const isMobile: boolean = useMediaQuery({ maxWidth: 767 });
|
|
|
|
return (
|
|
<>
|
|
<SettingsWrapper data-testid="t--settings-wrapper" isMobile={isMobile}>
|
|
<StyledStickyHeader isMobile={isMobile}>
|
|
<BackButton />
|
|
<SettingsPageHeader
|
|
buttonText="Add users"
|
|
onButtonClick={onButtonClick}
|
|
onSearch={onSearch}
|
|
pageMenuItems={pageMenuItems}
|
|
searchPlaceholder={createMessage(SEARCH_USERS, !isGACEnabled)}
|
|
showMoreOptions={false}
|
|
showSearchNButton={isMembersPage}
|
|
title={pageTitle}
|
|
/>
|
|
</StyledStickyHeader>
|
|
<WorkspaceSettingsTabs
|
|
currentTab={currentTab}
|
|
hasManageWorkspacePermissions={hasManageWorkspacePermissions}
|
|
isMemberofTheWorkspace={showMembersTab}
|
|
searchValue={searchValue}
|
|
setTabArrLen={setTabArrLen}
|
|
workspacePermissions={currentWorkspace?.userPermissions}
|
|
/>
|
|
</SettingsWrapper>
|
|
{currentWorkspace && (
|
|
<FormDialogComponent
|
|
Form={WorkspaceInviteUsersForm}
|
|
hideDefaultTrigger
|
|
isOpen={showModal}
|
|
onClose={() => setShowModal(false)}
|
|
placeholder={createMessage(INVITE_USERS_PLACEHOLDER, !isGACEnabled)}
|
|
workspace={currentWorkspace}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|