Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
import React from "react";
|
2019-09-09 09:08:54 +00:00
|
|
|
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
|
|
|
|
|
import { WidgetType } from "../constants/WidgetConstants";
|
2019-10-31 05:28:11 +00:00
|
|
|
import ButtonComponent from "../components/blueprint/ButtonComponent";
|
2019-09-13 11:59:45 +00:00
|
|
|
import { ActionPayload } from "../constants/ActionConstants";
|
2019-03-18 13:50:24 +00:00
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
class ButtonWidget extends BaseWidget<ButtonWidgetProps, WidgetState> {
|
2019-10-30 10:23:20 +00:00
|
|
|
onButtonClickBound: (event: React.MouseEvent<HTMLElement>) => void;
|
|
|
|
|
|
|
|
|
|
constructor(props: ButtonWidgetProps) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.onButtonClickBound = this.onButtonClick.bind(this);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 10:11:50 +00:00
|
|
|
onButtonClick() {
|
2019-10-03 16:24:29 +00:00
|
|
|
super.executeAction(this.props.onClick);
|
2019-09-17 10:11:50 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-18 15:10:30 +00:00
|
|
|
getPageView() {
|
2019-03-18 13:50:24 +00:00
|
|
|
return (
|
|
|
|
|
<ButtonComponent
|
2019-03-19 14:05:48 +00:00
|
|
|
style={this.getPositionStyle()}
|
2019-10-31 05:28:11 +00:00
|
|
|
buttonStyle={this.props.buttonStyle}
|
2019-03-18 13:50:24 +00:00
|
|
|
widgetId={this.props.widgetId}
|
2019-10-02 18:13:04 +00:00
|
|
|
widgetName={this.props.widgetName}
|
2019-03-18 13:50:24 +00:00
|
|
|
key={this.props.widgetId}
|
2019-09-17 10:11:50 +00:00
|
|
|
text={this.props.text}
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
disabled={this.props.isDisabled}
|
2019-10-30 10:23:20 +00:00
|
|
|
onClick={this.onButtonClickBound}
|
2019-03-18 13:50:24 +00:00
|
|
|
/>
|
2019-09-09 09:08:54 +00:00
|
|
|
);
|
2019-03-18 13:50:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getWidgetType(): WidgetType {
|
2019-09-09 09:08:54 +00:00
|
|
|
return "BUTTON_WIDGET";
|
2019-03-18 13:50:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 10:45:49 +00:00
|
|
|
export type ButtonStyle =
|
|
|
|
|
| "PRIMARY_BUTTON"
|
|
|
|
|
| "SECONDARY_BUTTON"
|
|
|
|
|
| "SUCCESS_BUTTON"
|
|
|
|
|
| "DANGER_BUTTON";
|
2019-09-12 08:11:25 +00:00
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export interface ButtonWidgetProps extends WidgetProps {
|
2019-08-29 11:22:09 +00:00
|
|
|
text?: string;
|
2019-09-13 10:45:49 +00:00
|
|
|
buttonStyle?: ButtonStyle;
|
2019-09-13 11:59:45 +00:00
|
|
|
onClick?: ActionPayload[];
|
2019-09-19 11:29:24 +00:00
|
|
|
isDisabled?: boolean;
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
isVisible?: boolean;
|
2019-03-18 13:50:24 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export default ButtonWidget;
|