## Description > This is a helper PR which contains the following changes: > - Remove Appsmith Roles: `APPLICATION_DEVELOPER`/ `APPLICATION_VIEWER` > - `PolicyGenerator.getChildPermissions`: Get all hierarechical permissions for an entity, given a permission. > - Deprecate `permissions` data member in `PermissionGroup.java` > - Refactor `MemberInfoDTO.java` to hold multiple roles. > - Split `PermissionGroupInfoDTO.java` > - `TextUtils. generateDefaultRoleNameForResource(String roleType, String resourceName)` added Fixes https://github.com/appsmithorg/appsmith/issues/20719 Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? > The existing test cases should pass and the newer test cases have been written in the EE PR ### 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 - [x] 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 --------- Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com> Co-authored-by: Ankita Kinger <ankita@appsmith.com>
195 lines
5.4 KiB
TypeScript
195 lines
5.4 KiB
TypeScript
import React, { useState } from "react";
|
|
import styled from "styled-components";
|
|
import { Position } from "@blueprintjs/core";
|
|
import type { DebouncedFunc } from "lodash";
|
|
import type { MenuItemProps } from "design-system-old";
|
|
import {
|
|
Button,
|
|
IconSize,
|
|
Menu,
|
|
MenuItem,
|
|
Icon,
|
|
SearchVariant,
|
|
} from "design-system-old";
|
|
import { HeaderWrapper } from "pages/Settings/components";
|
|
import {
|
|
HelpPopoverStyle,
|
|
StyledSearchInput,
|
|
SettingsHeader,
|
|
} from "components/utils/helperComponents";
|
|
import { ARE_YOU_SURE, createMessage } from "@appsmith/constants/messages";
|
|
import { useMediaQuery } from "react-responsive";
|
|
import { TooltipComponent } from "design-system-old";
|
|
|
|
type PageHeaderProps = {
|
|
buttonText?: string;
|
|
searchPlaceholder: string;
|
|
onButtonClick?: () => void;
|
|
onSearch?: DebouncedFunc<(search: string) => void>;
|
|
pageMenuItems: MenuItemProps[];
|
|
title?: string;
|
|
showMoreOptions?: boolean;
|
|
showSearchNButton?: boolean;
|
|
};
|
|
|
|
const Container = styled.div<{ isMobile?: boolean }>`
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
gap: 24px;
|
|
flex-wrap: ${(props) => (props.isMobile ? "wrap" : "nowrap")};
|
|
h2 {
|
|
text-transform: unset;
|
|
}
|
|
|
|
.actions-icon {
|
|
color: var(--appsmith-color-black-400);
|
|
|
|
&:hover {
|
|
color: var(--appsmith-color-black-700);
|
|
}
|
|
}
|
|
`;
|
|
|
|
const StyledButton = styled(Button)`
|
|
flex: 1 0 auto;
|
|
min-width: 88px;
|
|
`;
|
|
|
|
const SearchWrapper = styled.div`
|
|
width: 100%;
|
|
`;
|
|
|
|
const ActionsWrapper = styled.div`
|
|
display: flex;
|
|
align-items: center;
|
|
width: 100%;
|
|
|
|
.menu-actions-icon {
|
|
margin-left: 12px;
|
|
}
|
|
`;
|
|
|
|
export function SettingsPageHeader(props: PageHeaderProps) {
|
|
const [showConfirmationText, setShowConfirmationText] = useState(false);
|
|
const [showOptions, setShowOptions] = useState(false);
|
|
|
|
const {
|
|
buttonText,
|
|
onSearch,
|
|
pageMenuItems,
|
|
searchPlaceholder,
|
|
showMoreOptions,
|
|
showSearchNButton = true,
|
|
title,
|
|
} = props;
|
|
|
|
const handleSearch = (search: string) => {
|
|
onSearch?.(search.toLocaleUpperCase());
|
|
};
|
|
|
|
const onOptionSelect = (
|
|
e: React.MouseEvent<Element, MouseEvent>,
|
|
menuItem: MenuItemProps,
|
|
) => {
|
|
if (menuItem.label === "delete") {
|
|
setShowOptions(true);
|
|
setShowConfirmationText(true);
|
|
showConfirmationText && menuItem?.onSelect?.(e, "delete");
|
|
} else if (menuItem.label === "rename") {
|
|
setShowOptions(false);
|
|
} else {
|
|
setShowConfirmationText(false);
|
|
setShowOptions(false);
|
|
menuItem?.onSelect?.(e, "other");
|
|
}
|
|
};
|
|
|
|
const isMobile: boolean = useMediaQuery({ maxWidth: 767 });
|
|
|
|
return (
|
|
<Container isMobile={isMobile}>
|
|
<HeaderWrapper margin={`0px`}>
|
|
<TooltipComponent
|
|
content={title}
|
|
disabled={title && title.length < 32 ? true : false}
|
|
>
|
|
<SettingsHeader data-testid="t--page-title">{title}</SettingsHeader>
|
|
</TooltipComponent>
|
|
</HeaderWrapper>
|
|
<Container isMobile={isMobile}>
|
|
<SearchWrapper>
|
|
{onSearch && showSearchNButton && (
|
|
<StyledSearchInput
|
|
className="search-input"
|
|
data-testid={"t--search-input"}
|
|
onChange={handleSearch}
|
|
placeholder={searchPlaceholder}
|
|
variant={SearchVariant.BACKGROUND}
|
|
width={isMobile ? "100%" : "376px"}
|
|
/>
|
|
)}
|
|
</SearchWrapper>
|
|
{/* <VerticalDelimeter /> */}
|
|
<ActionsWrapper>
|
|
{buttonText && showSearchNButton && (
|
|
<StyledButton
|
|
data-testid={"t--page-header-input"}
|
|
height="36"
|
|
onClick={props.onButtonClick}
|
|
tag="button"
|
|
text={buttonText}
|
|
/>
|
|
)}
|
|
{showMoreOptions && (
|
|
<Menu
|
|
canEscapeKeyClose
|
|
canOutsideClickClose
|
|
className="menu-actions-icon"
|
|
isOpen={showOptions}
|
|
menuItemWrapperWidth={"auto"}
|
|
onClose={() => setShowOptions(false)}
|
|
onClosing={() => {
|
|
setShowConfirmationText(false);
|
|
setShowOptions(false);
|
|
}}
|
|
onOpening={() => setShowOptions(true)}
|
|
position={Position.BOTTOM_RIGHT}
|
|
target={
|
|
<Icon
|
|
className="actions-icon"
|
|
data-testid="t--page-header-actions"
|
|
name="more-2-fill"
|
|
onClick={() => setShowOptions(!showOptions)}
|
|
size={IconSize.XXL}
|
|
/>
|
|
}
|
|
>
|
|
<HelpPopoverStyle />
|
|
{pageMenuItems &&
|
|
pageMenuItems.map((menuItem) => (
|
|
<MenuItem
|
|
className={menuItem.className}
|
|
icon={menuItem.icon}
|
|
key={menuItem.text}
|
|
onSelect={(e: React.MouseEvent<HTMLInputElement>) => {
|
|
onOptionSelect(e, menuItem);
|
|
}}
|
|
text={
|
|
showConfirmationText && menuItem.label === "delete"
|
|
? createMessage(ARE_YOU_SURE)
|
|
: menuItem.text
|
|
}
|
|
{...(showConfirmationText && menuItem.label === "delete"
|
|
? { type: "warning" }
|
|
: {})}
|
|
/>
|
|
))}
|
|
</Menu>
|
|
)}
|
|
</ActionsWrapper>
|
|
</Container>
|
|
</Container>
|
|
);
|
|
}
|