## Description Complete the following fixes to tests 1. Remove data-testid from ForkTemplate modal. This is because the test case for that includes this component is going to be removed in another [PR](https://github.com/appsmithorg/appsmith/pull/30160/files). 2. Remove redundant comments from BuildingBlock.test #### PR fixes following issue(s) Fixes #30024 #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] 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 - [ ] My code follows the style guidelines of this project - [ ] 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 - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated the `ForkTemplate` modal rendering logic. - **Tests** - Removed a test case related to the fork modal interaction. - **Style** - Removed `data-testid` attribute from the `ModalBody` component for cleaner UI code. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
104 lines
2.8 KiB
TypeScript
104 lines
2.8 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import React, { useState } from "react";
|
|
import {
|
|
Button,
|
|
Modal,
|
|
ModalBody,
|
|
ModalContent,
|
|
ModalFooter,
|
|
ModalHeader,
|
|
Select,
|
|
} from "design-system";
|
|
import { useDispatch, useSelector } from "react-redux";
|
|
import {
|
|
getForkableWorkspaces,
|
|
isImportingTemplateSelector,
|
|
} from "selectors/templatesSelectors";
|
|
import { importTemplateToWorkspace } from "actions/templateActions";
|
|
import {
|
|
CANCEL,
|
|
CHOOSE_WHERE_TO_FORK,
|
|
createMessage,
|
|
FORK_TEMPLATE,
|
|
SELECT_WORKSPACE,
|
|
} from "@appsmith/constants/messages";
|
|
|
|
interface ForkTemplateProps {
|
|
children?: ReactNode;
|
|
showForkModal: boolean;
|
|
onClose: (e?: React.MouseEvent<HTMLElement>) => void;
|
|
templateId: string;
|
|
}
|
|
|
|
function ForkTemplate({
|
|
children,
|
|
onClose,
|
|
showForkModal,
|
|
templateId,
|
|
}: ForkTemplateProps) {
|
|
const workspaceList = useSelector(getForkableWorkspaces);
|
|
const [selectedWorkspace, setSelectedWorkspace] = useState(workspaceList[0]);
|
|
const isImportingTemplate = useSelector(isImportingTemplateSelector);
|
|
const dispatch = useDispatch();
|
|
|
|
const onFork = () => {
|
|
dispatch(importTemplateToWorkspace(templateId, selectedWorkspace.value));
|
|
};
|
|
|
|
const closeModal = (isOpen: boolean) => {
|
|
if (!isOpen && !isImportingTemplate) {
|
|
onClose();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
{children}
|
|
<Modal onOpenChange={closeModal} open={showForkModal}>
|
|
<ModalContent style={{ width: "640px" }}>
|
|
<ModalHeader>{createMessage(CHOOSE_WHERE_TO_FORK)}</ModalHeader>
|
|
<ModalBody style={{ overflow: "unset", paddingBottom: "4px" }}>
|
|
<Select
|
|
dropdownMatchSelectWidth
|
|
getPopupContainer={(triggerNode) => triggerNode.parentNode}
|
|
// TODO: (Albin) Fix this
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
//@ts-ignore
|
|
onSelect={(
|
|
dropdownOptionValue: string,
|
|
dropdownOption: {
|
|
label: string;
|
|
value: string;
|
|
},
|
|
) => setSelectedWorkspace(dropdownOption)}
|
|
options={workspaceList}
|
|
placeholder={createMessage(SELECT_WORKSPACE)}
|
|
value={selectedWorkspace}
|
|
/>
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<Button
|
|
isDisabled={isImportingTemplate}
|
|
kind="secondary"
|
|
onClick={onClose}
|
|
size="md"
|
|
>
|
|
{createMessage(CANCEL)}
|
|
</Button>
|
|
<Button
|
|
className="t--fork-template-button"
|
|
isLoading={isImportingTemplate}
|
|
onClick={onFork}
|
|
size="md"
|
|
>
|
|
{createMessage(FORK_TEMPLATE)}
|
|
</Button>
|
|
</ModalFooter>
|
|
</ModalContent>
|
|
</Modal>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default ForkTemplate;
|