> Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description In this pr we are fixing - Unwanted text selection during DnD and canvas resizing in Safari - In Anvil Shift + Click will still work like Ctrl + Click to pick and select widgets instead of pick all widgets in between a node on Entity Explorer like in Fixed Layout. - We are also fixing canvas resizer being stuck in resizing mode when mouse right is clicked. #### PR fixes following issue(s) Fixes #28193 > if no issue exists, please create an issue and ask the maintainers about this first > > #### 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 > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## 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
103 lines
2.6 KiB
TypeScript
103 lines
2.6 KiB
TypeScript
import React from "react";
|
|
import type { WidgetCardProps } from "widgets/BaseWidget";
|
|
import styled from "styled-components";
|
|
import { useWidgetDragResize } from "utils/hooks/dragResizeHooks";
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
|
import { generateReactKey } from "utils/generators";
|
|
import { useWidgetSelection } from "utils/hooks/useWidgetSelection";
|
|
import { IconWrapper } from "constants/IconConstants";
|
|
import { Text } from "design-system";
|
|
|
|
interface CardProps {
|
|
details: WidgetCardProps;
|
|
}
|
|
|
|
export const Wrapper = styled.div`
|
|
border-radius: var(--ads-v2-border-radius);
|
|
border: none;
|
|
position: relative;
|
|
color: var(--ads-v2-color-fg);
|
|
min-height: 70px;
|
|
display: flex;
|
|
align-items: flex-start;
|
|
justify-content: center;
|
|
cursor: grab;
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
img {
|
|
cursor: grab;
|
|
}
|
|
|
|
& > div {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-bottom: 2px;
|
|
text-align: center;
|
|
}
|
|
|
|
&:hover {
|
|
background: var(--ads-v2-color-bg-subtle);
|
|
}
|
|
|
|
& i {
|
|
font-family: ${(props) => props.theme.fonts.text};
|
|
font-size: ${(props) => props.theme.fontSizes[7]}px;
|
|
}
|
|
`;
|
|
|
|
export const BetaLabel = styled.div`
|
|
font-size: 10px;
|
|
background: var(--ads-v2-color-bg-emphasis);
|
|
margin-top: 3px;
|
|
padding: 2px 4px;
|
|
border-radius: 3px;
|
|
position: absolute;
|
|
top: 0;
|
|
right: -2%;
|
|
`;
|
|
|
|
function WidgetCard(props: CardProps) {
|
|
const { setDraggingNewWidget } = useWidgetDragResize();
|
|
const { deselectAll } = useWidgetSelection();
|
|
|
|
const onDragStart = (e: any) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
AnalyticsUtil.logEvent("WIDGET_CARD_DRAG", {
|
|
widgetType: props.details.type,
|
|
widgetName: props.details.displayName,
|
|
});
|
|
setDraggingNewWidget &&
|
|
setDraggingNewWidget(true, {
|
|
...props.details,
|
|
widgetId: generateReactKey(),
|
|
});
|
|
deselectAll();
|
|
};
|
|
|
|
const type = `${props.details.type.split("_").join("").toLowerCase()}`;
|
|
const className = `t--widget-card-draggable t--widget-card-draggable-${type}`;
|
|
|
|
return (
|
|
<Wrapper
|
|
className={className}
|
|
data-guided-tour-id={`widget-card-${type}`}
|
|
draggable
|
|
id={`widget-card-draggable-${type}`}
|
|
onDragStart={onDragStart}
|
|
>
|
|
<div className="gap-2 mt-2">
|
|
<IconWrapper>
|
|
<img className="w-6 h-6" src={props.details.icon} />
|
|
</IconWrapper>
|
|
<Text kind="body-s">{props.details.displayName}</Text>
|
|
{props.details.isBeta && <BetaLabel>Beta</BetaLabel>}
|
|
</div>
|
|
</Wrapper>
|
|
);
|
|
}
|
|
|
|
export default WidgetCard;
|