PromucFlow_constructor/app/client/src/pages/Templates/ForkTemplate.tsx
Tanvi Bhakta 4fca7da51d
fix: ads-v2 fixes (#23543)
## Description

Notion Issues: 

1. Issues with link component:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=4121a76714cb49f2ba76d20fbeab9766&pm=s
2. GraphQL code editor heading color:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=82bbeaa2749642268eada28fcf5ec6a6&pm=s
3. tooltip on long JS Object names:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=353552b086de45329390bd4dfae98ee4&pm=s
4. Multiple scroll bars on response tab:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=111515d90ec5447687b1b573d64bd6eb&pm=s
5. Save and delete buttons:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=1ac1fed293994b51b4c31bc44dd2d736&pm=s
6. Js Objects always on tooltip:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=59f3e5b452d24ab9aa05e9fdd169113f&pm=s
7. Error message alignment:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=a6f2cc4e79994b77894c0293d50be3b9&pm=s
8. Max width of field on Admin settings page:
https://www.notion.so/appsmith/Text-boxes-too-small-in-Auth-Pages-ef2d0fb97f8247848113f9a419e3da09?pvs=4


Other issues:
1. Added data testid for branch create spinner.
7. Fix: branch name button have a fixed width even if text length is
small.


#### Type of change
- 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
- [ ] 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/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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

---------

Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
Co-authored-by: Preet Sidhu <preetsidhu.bits@gmail.com>
Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
Co-authored-by: rahulramesha <rahul@appsmith.com>
Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
Co-authored-by: Vijetha-Kaja <vijetha@appsmith.com>
Co-authored-by: Apple <nandan@thinkify.io>
Co-authored-by: Arsalan Yaldram <arsalanyaldram0211@outlook.com>
Co-authored-by: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com>
Co-authored-by: Aswath K <aswath.sana@gmail.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
Co-authored-by: Aman Agarwal <aman@appsmith.com>
Co-authored-by: Sangeeth Sivan <74818788+berzerkeer@users.noreply.github.com>
Co-authored-by: Saroj <43822041+sarojsarab@users.noreply.github.com>
Co-authored-by: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com>
Co-authored-by: Parthvi <80334441+Parthvi12@users.noreply.github.com>
Co-authored-by: Vijetha-Kaja <119562824+Vijetha-Kaja@users.noreply.github.com>
Co-authored-by: Ayush Pahwa <ayushpahwa96@gmail.com>
Co-authored-by: Rohit Agarwal <rohit_agarwal@live.in>
2023-05-29 13:40:41 +08:00

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;