Merge branch 'release' of https://github.com/appsmithorg/appsmith into release

This commit is contained in:
Automated Github Action 2020-09-18 11:06:09 +00:00
commit 91b9d4ec66
5 changed files with 76 additions and 14 deletions

View File

@ -35,6 +35,7 @@
"bottomRow": 9, "bottomRow": 9,
"snapColumns": 16, "snapColumns": 16,
"orientation": "VERTICAL", "orientation": "VERTICAL",
"parentId": "0",
"children": [ "children": [
{ {
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -51,6 +52,7 @@
"bottomRow": 342, "bottomRow": 342,
"snapColumns": 16, "snapColumns": 16,
"orientation": "VERTICAL", "orientation": "VERTICAL",
"parentId": "4kiuclj7on",
"children": [ "children": [
{ {
"text": "Title", "text": "Title",
@ -66,7 +68,8 @@
"rightColumn": 3, "rightColumn": 3,
"topRow": 0, "topRow": 0,
"bottomRow": 1, "bottomRow": 1,
"widgetId": "jnusumakb5" "widgetId": "jnusumakb5",
"parentId": "xe6a0w50jz"
} }
], ],
"widgetId": "xe6a0w50jz", "widgetId": "xe6a0w50jz",
@ -92,6 +95,7 @@
"bottomRow": 23, "bottomRow": 23,
"snapColumns": 16, "snapColumns": 16,
"orientation": "VERTICAL", "orientation": "VERTICAL",
"parentId": "0",
"children": [ "children": [
{ {
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -107,6 +111,7 @@
"topRow": 0, "topRow": 0,
"bottomRow": 532, "bottomRow": 532,
"snapColumns": 16, "snapColumns": 16,
"parentId": "9lr328fusr",
"orientation": "VERTICAL", "orientation": "VERTICAL",
"children": [ "children": [
{ {
@ -123,7 +128,8 @@
"rightColumn": 3, "rightColumn": 3,
"topRow": 0, "topRow": 0,
"bottomRow": 1, "bottomRow": 1,
"widgetId": "2p0avl6plv" "widgetId": "2p0avl6plv",
"parentId": "p7cexs0qo5"
}, },
{ {
"isVisible": true, "isVisible": true,
@ -189,7 +195,7 @@
"topRow": 0, "topRow": 0,
"shouldShowTabs": true, "shouldShowTabs": true,
"bottomRow": 7, "bottomRow": 7,
"parentId": "xe6a0w50jz", "parentId": "p7cexs0qo5",
"widgetId": "wuzxcyyjma", "widgetId": "wuzxcyyjma",
"children": [ "children": [
{ {
@ -258,6 +264,7 @@
"bottomRow": 9, "bottomRow": 9,
"snapColumns": 16, "snapColumns": 16,
"orientation": "VERTICAL", "orientation": "VERTICAL",
"parentId": "0",
"children": [ "children": [
{ {
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -274,6 +281,7 @@
"bottomRow": 342, "bottomRow": 342,
"snapColumns": 16, "snapColumns": 16,
"orientation": "VERTICAL", "orientation": "VERTICAL",
"parentId": "47gso3f7ll",
"children": [ "children": [
{ {
"text": "Title", "text": "Title",
@ -289,7 +297,8 @@
"rightColumn": 3, "rightColumn": 3,
"topRow": 0, "topRow": 0,
"bottomRow": 1, "bottomRow": 1,
"widgetId": "0tknsgos8i" "widgetId": "0tknsgos8i",
"parentId": "nixoni01d8"
} }
], ],
"widgetId": "nixoni01d8", "widgetId": "nixoni01d8",

View File

@ -6,6 +6,8 @@ export interface StyledImageProps {
defaultImageUrl: string; defaultImageUrl: string;
imageUrl?: string; imageUrl?: string;
backgroundColor?: string; backgroundColor?: string;
showHoverPointer?: boolean;
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
} }
export const StyledImage = styled.div< export const StyledImage = styled.div<
@ -16,6 +18,8 @@ export const StyledImage = styled.div<
position: relative; position: relative;
display: flex; display: flex;
flex-direction: "row"; flex-direction: "row";
cursor: ${props =>
props.showHoverPointer && props.onClick ? "pointer" : "inherit"};
background: ${props => props.backgroundColor}; background: ${props => props.backgroundColor};
background-image: url("${props => background-image: url("${props =>
props.imageError ? props.defaultImageUrl : props.imageUrl}"); props.imageError ? props.defaultImageUrl : props.imageUrl}");
@ -53,6 +57,7 @@ class ImageComponent extends React.Component<
src={this.props.imageUrl} src={this.props.imageUrl}
onError={this.onImageError} onError={this.onImageError}
onLoad={this.onImageLoad} onLoad={this.onImageLoad}
onClick={this.props.onClick}
></img> ></img>
</StyledImage> </StyledImage>
); );
@ -75,6 +80,8 @@ export interface ImageComponentProps extends ComponentProps {
imageUrl: string; imageUrl: string;
defaultImageUrl: string; defaultImageUrl: string;
isLoading: boolean; isLoading: boolean;
showHoverPointer?: boolean;
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
} }
export default ImageComponent; export default ImageComponent;

View File

@ -234,6 +234,21 @@ const PropertyPaneConfigResponse: PropertyPaneConfigsResponse["data"] = {
}, },
], ],
}, },
{
id: "3.2",
sectionName: "Actions",
children: [
{
id: "3.2.1",
helpText:
"Triggers an action when a user changes the selected option",
propertyName: "onClick",
label: "onClick",
controlType: "ACTION_SELECTOR",
isJSConvertible: true,
},
],
},
], ],
RADIO_GROUP_WIDGET: [ RADIO_GROUP_WIDGET: [
{ {

View File

@ -70,6 +70,7 @@ import { generateReactKey } from "utils/generators";
import { flashElementById } from "utils/helpers"; import { flashElementById } from "utils/helpers";
import AnalyticsUtil from "utils/AnalyticsUtil"; import AnalyticsUtil from "utils/AnalyticsUtil";
import { cloneDeep } from "lodash"; import { cloneDeep } from "lodash";
import log from "loglevel";
function getChildWidgetProps( function getChildWidgetProps(
parent: FlattenedWidgetProps, parent: FlattenedWidgetProps,
@ -358,6 +359,7 @@ export function* undoDeleteSaga(action: ReduxAction<{ widgetId: string }>) {
if (widget.tabId && widget.type === WidgetTypes.CANVAS_WIDGET) { if (widget.tabId && widget.type === WidgetTypes.CANVAS_WIDGET) {
const parent = widgets[widget.parentId]; const parent = widgets[widget.parentId];
if (parent.tabs) { if (parent.tabs) {
try {
const tabs = _.isString(parent.tabs) const tabs = _.isString(parent.tabs)
? JSON.parse(parent.tabs) ? JSON.parse(parent.tabs)
: parent.tabs; : parent.tabs;
@ -367,6 +369,9 @@ export function* undoDeleteSaga(action: ReduxAction<{ widgetId: string }>) {
label: widget.tabName || widget.widgetName, label: widget.tabName || widget.widgetName,
}); });
widgets[widget.parentId].tabs = JSON.stringify(tabs); widgets[widget.parentId].tabs = JSON.stringify(tabs);
} catch (error) {
log.debug("Error deleting tabs widget: ", { error });
}
} else { } else {
parent.tabs = JSON.stringify([ parent.tabs = JSON.stringify([
{ {
@ -706,6 +711,7 @@ function* pasteWidgetSaga() {
// the main container // the main container
if ( if (
selectedWidget.parentId !== MAIN_CONTAINER_WIDGET_ID && selectedWidget.parentId !== MAIN_CONTAINER_WIDGET_ID &&
widgets[selectedWidget.parentId] &&
widgets[selectedWidget.parentId].children && widgets[selectedWidget.parentId].children &&
widgets[selectedWidget.parentId].children.length > 0 widgets[selectedWidget.parentId].children.length > 0
) { ) {

View File

@ -1,6 +1,6 @@
import * as React from "react"; import * as React from "react";
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget"; import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
import { WidgetType } from "constants/WidgetConstants"; import { WidgetType, RenderModes } from "constants/WidgetConstants";
import ImageComponent from "components/designSystems/appsmith/ImageComponent"; import ImageComponent from "components/designSystems/appsmith/ImageComponent";
import { import {
WidgetPropertyValidationType, WidgetPropertyValidationType,
@ -8,8 +8,14 @@ import {
} from "utils/ValidationFactory"; } from "utils/ValidationFactory";
import { VALIDATION_TYPES } from "constants/WidgetValidation"; import { VALIDATION_TYPES } from "constants/WidgetValidation";
import * as Sentry from "@sentry/react"; import * as Sentry from "@sentry/react";
import { EventType } from "constants/ActionConstants";
import { TriggerPropertiesMap } from "utils/WidgetFactory";
class ImageWidget extends BaseWidget<ImageWidgetProps, WidgetState> { class ImageWidget extends BaseWidget<ImageWidgetProps, WidgetState> {
constructor(props: ImageWidgetProps) {
super(props);
this.onImageClick = this.onImageClick.bind(this);
}
static getPropertyValidationMap(): WidgetPropertyValidationType { static getPropertyValidationMap(): WidgetPropertyValidationType {
return { return {
...BASE_WIDGET_VALIDATION, ...BASE_WIDGET_VALIDATION,
@ -18,17 +24,35 @@ class ImageWidget extends BaseWidget<ImageWidgetProps, WidgetState> {
defaultImage: VALIDATION_TYPES.TEXT, defaultImage: VALIDATION_TYPES.TEXT,
}; };
} }
static getTriggerPropertyMap(): TriggerPropertiesMap {
return {
onClick: true,
};
}
getPageView() { getPageView() {
return ( return (
<ImageComponent <ImageComponent
widgetId={this.props.widgetId} widgetId={this.props.widgetId}
imageUrl={this.props.image} imageUrl={this.props.image}
onClick={this.props.onClick ? this.onImageClick : undefined}
showHoverPointer={this.props.renderMode === RenderModes.PAGE}
defaultImageUrl={this.props.defaultImage} defaultImageUrl={this.props.defaultImage}
isLoading={this.props.isLoading} isLoading={this.props.isLoading}
/> />
); );
} }
onImageClick() {
if (this.props.onClick) {
super.executeAction({
dynamicString: this.props.onClick,
event: {
type: EventType.ON_CLICK,
},
});
}
}
getWidgetType(): WidgetType { getWidgetType(): WidgetType {
return "IMAGE_WIDGET"; return "IMAGE_WIDGET";
} }
@ -40,6 +64,7 @@ export interface ImageWidgetProps extends WidgetProps {
image: string; image: string;
imageShape: ImageShape; imageShape: ImageShape;
defaultImage: string; defaultImage: string;
onClick?: string;
} }
export default ImageWidget; export default ImageWidget;