PromucFlow_constructor/app/client/src/pages/Templates/TemplateViewHeader.tsx

86 lines
2.2 KiB
TypeScript
Raw Normal View History

feat: move `Use this template` to top of iframe (#24361) ## Description * Moved `Use this template` from description to header. * Restructured template `Header` to its separate component. #### PR fixes following issue(s) Fixes #15946 #### Media ![Screenshot 2023-06-12 at 2 54 42 PM](https://github.com/appsmithorg/appsmith/assets/6761673/65d968b1-7f67-42b6-8ea0-e668b59d4f61) #### Type of change - New feature (non-breaking change which adds functionality) ## Testing > #### How Has This Been Tested? - [x] 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 - [ ] 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
2023-06-15 05:26:42 +00:00
import {
FORK_THIS_TEMPLATE,
GO_BACK,
createMessage,
} from "@appsmith/constants/messages";
import { templateIdUrl } from "RouteBuilder";
import { Button, Link, Text } from "design-system";
import { useQuery } from "pages/Editor/utils";
import React from "react";
import { useSelector } from "react-redux";
import {
getActiveTemplateSelector,
getForkableWorkspaces,
} from "selectors/templatesSelectors";
import styled from "styled-components";
import history from "utils/history";
import ForkTemplate from "./ForkTemplate";
const HeaderWrapper = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
`;
const Title = styled(Text)`
display: inline-block;
color: var(--ads-v2-color-fg-emphasis-plus);
`;
type Props = {
templateId: string;
};
const SHOW_FORK_MODAL_PARAM = "showForkTemplateModal";
function TemplateViewHeader({ templateId }: Props) {
const currentTemplate = useSelector(getActiveTemplateSelector);
const query = useQuery();
const workspaceList = useSelector(getForkableWorkspaces);
const goBack = () => {
history.goBack();
};
const onForkModalClose = () => {
history.replace(`${templateIdUrl({ id: templateId })}`);
};
const onForkButtonTrigger = () => {
history.replace(
`${templateIdUrl({ id: templateId })}?${SHOW_FORK_MODAL_PARAM}=true`,
);
};
return (
<HeaderWrapper>
fix: Reset templates filter for templates modal (#24192) ## Description * Currently we do not reset the template filters when we close template modal and open it again in `add page from template flow` This becomes confusing for some users. * Also increases test coverage of templates filtering #### PR fixes following issue(s) Fixes #17276 #### Media https://github.com/appsmithorg/appsmith/assets/6761673/3c94e21b-e8a9-4c6b-bc81-e677269bb5ea #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [x] 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
2023-06-29 06:22:05 +00:00
<Link
data-testid="t--template-view-goback"
onClick={goBack}
startIcon="arrow-left-line"
>
feat: move `Use this template` to top of iframe (#24361) ## Description * Moved `Use this template` from description to header. * Restructured template `Header` to its separate component. #### PR fixes following issue(s) Fixes #15946 #### Media ![Screenshot 2023-06-12 at 2 54 42 PM](https://github.com/appsmithorg/appsmith/assets/6761673/65d968b1-7f67-42b6-8ea0-e668b59d4f61) #### Type of change - New feature (non-breaking change which adds functionality) ## Testing > #### How Has This Been Tested? - [x] 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 - [ ] 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
2023-06-15 05:26:42 +00:00
{createMessage(GO_BACK)}
</Link>
<Title kind="heading-l" renderAs="h1">
{currentTemplate?.title}
</Title>
<section>
{!!workspaceList.length && (
<ForkTemplate
onClose={onForkModalClose}
showForkModal={!!query.get(SHOW_FORK_MODAL_PARAM)}
templateId={templateId}
>
<Button
className="template-fork-button"
data-testid="template-fork-button"
onClick={onForkButtonTrigger}
size="md"
startIcon="fork-2"
>
{createMessage(FORK_THIS_TEMPLATE)}
</Button>
</ForkTemplate>
)}
</section>
</HeaderWrapper>
);
}
export default TemplateViewHeader;