Merge branch 'fix/api-pane-creation' into 'release'

Api pane creation fixes

See merge request theappsmith/internal-tools-client!511
This commit is contained in:
Hetu Nandu 2020-04-22 09:15:24 +00:00
commit 21fc20e488
7 changed files with 57 additions and 25 deletions

View File

@ -28,6 +28,7 @@ type TreeDropdownProps = {
defaultText: string; defaultText: string;
onSelect: (value: TreeDropdownOption, defaultVal?: string) => void; onSelect: (value: TreeDropdownOption, defaultVal?: string) => void;
selectedLabelModifier?: (option: TreeDropdownOption) => string; selectedLabelModifier?: (option: TreeDropdownOption) => string;
toggle?: React.ReactNode;
}; };
function getSelectedOption( function getSelectedOption(
@ -64,6 +65,7 @@ export default function TreeDropdown(props: TreeDropdownProps) {
onSelect, onSelect,
getDefaults, getDefaults,
selectedLabelModifier, selectedLabelModifier,
toggle,
} = props; } = props;
const selectedOption = getSelectedOption( const selectedOption = getSelectedOption(
selectedValue, selectedValue,
@ -90,6 +92,7 @@ export default function TreeDropdown(props: TreeDropdownProps) {
icon={option.id === "create" ? "plus" : undefined} icon={option.id === "create" ? "plus" : undefined}
onClick={option.children ? _.noop : () => handleSelect(option)} onClick={option.children ? _.noop : () => handleSelect(option)}
text={option.label} text={option.label}
intent={option.intent}
popoverProps={{ popoverProps={{
minimal: true, minimal: true,
interactionKind: PopoverInteractionKind.CLICK, interactionKind: PopoverInteractionKind.CLICK,
@ -103,19 +106,27 @@ export default function TreeDropdown(props: TreeDropdownProps) {
const list = optionTree.map(renderTreeOption); const list = optionTree.map(renderTreeOption);
const menuItems = <Menu>{list}</Menu>; const menuItems = <Menu>{list}</Menu>;
return ( const defaultToggle = (
<StyledDropDownContainer> <StyledDropDownContainer>
<StyledPopover usePortal={true} minimal={true} content={menuItems}> <BlueprintButton
<BlueprintButton rightIcon={IconNames.CHEVRON_DOWN}
rightIcon={IconNames.CHEVRON_DOWN} text={
text={ selectedLabelModifier
selectedLabelModifier ? selectedLabelModifier(selectedOption)
? selectedLabelModifier(selectedOption) : selectedOption.label
: selectedOption.label }
} className={`t--open-dropdown-${defaultText.split(" ").join("-")}`}
className={`t--open-dropdown-${defaultText.split(" ").join("-")}`} />
/>
</StyledPopover>
</StyledDropDownContainer> </StyledDropDownContainer>
); );
return (
<StyledPopover
usePortal={true}
minimal={true}
content={menuItems}
position={PopoverPosition.AUTO_END}
>
{toggle ? toggle : defaultToggle}
</StyledPopover>
);
} }

View File

@ -154,6 +154,9 @@ export const StyledDropDown = styled(DropDown)`
`; `;
export const StyledPopover = styled(Popover)` export const StyledPopover = styled(Popover)`
.${Classes.POPOVER_TARGET} {
display: flex;
}
div { div {
flex: 1 1 auto; flex: 1 1 auto;
} }
@ -188,6 +191,9 @@ export const StyledMenuItem = styled(MenuItem)`
border-radius: ${props => props.theme.radii[1]}px; border-radius: ${props => props.theme.radii[1]}px;
&:hover { &:hover {
background: ${Colors.POLAR}; background: ${Colors.POLAR};
&&&.bp3-menu-item.bp3-intent-danger:hover {
background: ${props => props.theme.colors.error};
}
} }
&.${Classes.ACTIVE} { &.${Classes.ACTIVE} {
background: ${Colors.POLAR}; background: ${Colors.POLAR};

View File

@ -37,6 +37,8 @@ const HTTPMethod = styled.span<{ method?: string }>`
return "#F7C75B"; return "#F7C75B";
case "PUT": case "PUT":
return "#30A5E0"; return "#30A5E0";
case "PATCH":
return "#8E8E8E";
case "DELETE": case "DELETE":
return "#CE4257"; return "#CE4257";
default: default:

View File

@ -17,9 +17,10 @@ import {
DropResult, DropResult,
} from "react-beautiful-dnd"; } from "react-beautiful-dnd";
import { PageListPayload } from "constants/ReduxActionConstants"; import { PageListPayload } from "constants/ReduxActionConstants";
import ContextDropdown from "components/editorComponents/ContextDropdown"; import TreeDropdown from "components/editorComponents/actioncreator/TreeDropdown";
import { theme } from "constants/DefaultTheme"; import { theme } from "constants/DefaultTheme";
import { Colors } from "constants/Colors"; import { Colors } from "constants/Colors";
import { ControlIcons } from "icons/ControlIcons";
const LoadingContainer = styled(CenteredWrapper)` const LoadingContainer = styled(CenteredWrapper)`
height: 50%; height: 50%;
@ -411,8 +412,13 @@ class EditorSidebar extends React.Component<Props, State> {
draftIds.indexOf(item.id) === -1 draftIds.indexOf(item.id) === -1
} }
/> />
<ContextDropdown <TreeDropdown
options={[ defaultText=""
onSelect={() => {
return null;
}}
selectedValue=""
optionTree={[
{ {
value: "copy", value: "copy",
onSelect: () => null, onSelect: () => null,
@ -461,12 +467,12 @@ class EditorSidebar extends React.Component<Props, State> {
intent: "danger", intent: "danger",
}, },
]} ]}
toggle={{ toggle={
type: "icon", <ControlIcons.MORE_HORIZONTAL_CONTROL
icon: "MORE_HORIZONTAL_CONTROL", width={theme.fontSizes[4]}
iconSize: theme.fontSizes[4], height={theme.fontSizes[4]}
}} />
className="more" }
/> />
</React.Fragment> </React.Fragment>
)} )}

View File

@ -49,7 +49,12 @@ const actionsReducer = createReducer(initialState, {
state: ActionDataState, state: ActionDataState,
action: ReduxAction<RestAction>, action: ReduxAction<RestAction>,
): ActionDataState => ): ActionDataState =>
state.concat([{ config: action.payload, isLoading: false }]), state.concat([
{
config: { ...action.payload, id: action.payload.name },
isLoading: false,
},
]),
[ReduxActionTypes.CREATE_ACTION_SUCCESS]: ( [ReduxActionTypes.CREATE_ACTION_SUCCESS]: (
state: ActionDataState, state: ActionDataState,
action: ReduxAction<RestAction>, action: ReduxAction<RestAction>,
@ -57,7 +62,7 @@ const actionsReducer = createReducer(initialState, {
state.map(a => { state.map(a => {
if ( if (
a.config.pageId === action.payload.pageId && a.config.pageId === action.payload.pageId &&
a.config.name === action.payload.name a.config.id === action.payload.name
) { ) {
return { ...a, config: action.payload }; return { ...a, config: action.payload };
} }
@ -70,7 +75,7 @@ const actionsReducer = createReducer(initialState, {
state.filter( state.filter(
a => a =>
a.config.name !== action.payload.name && a.config.name !== action.payload.name &&
a.config.pageId !== action.payload.pageId, a.config.id !== action.payload.name,
), ),
[ReduxActionTypes.UPDATE_ACTION_SUCCESS]: ( [ReduxActionTypes.UPDATE_ACTION_SUCCESS]: (
state: ActionDataState, state: ActionDataState,

View File

@ -701,7 +701,7 @@ export function* watchActionSagas() {
takeEvery(ReduxActionTypes.FETCH_ACTIONS_INIT, fetchActionsSaga), takeEvery(ReduxActionTypes.FETCH_ACTIONS_INIT, fetchActionsSaga),
takeEvery(ReduxActionTypes.EXECUTE_ACTION, executeAppAction), takeEvery(ReduxActionTypes.EXECUTE_ACTION, executeAppAction),
takeLatest(ReduxActionTypes.RUN_API_REQUEST, runApiActionSaga), takeLatest(ReduxActionTypes.RUN_API_REQUEST, runApiActionSaga),
takeLatest(ReduxActionTypes.CREATE_ACTION_INIT, createActionSaga), takeEvery(ReduxActionTypes.CREATE_ACTION_INIT, createActionSaga),
takeLatest(ReduxActionTypes.UPDATE_ACTION_INIT, updateActionSaga), takeLatest(ReduxActionTypes.UPDATE_ACTION_INIT, updateActionSaga),
takeLatest(ReduxActionTypes.DELETE_ACTION_INIT, deleteActionSaga), takeLatest(ReduxActionTypes.DELETE_ACTION_INIT, deleteActionSaga),
takeLatest( takeLatest(

View File

@ -12,6 +12,7 @@ import { VALIDATION_TYPES } from "constants/WidgetValidation";
import { TriggerPropertiesMap } from "utils/WidgetFactory"; import { TriggerPropertiesMap } from "utils/WidgetFactory";
import { VALIDATORS } from "utils/Validators"; import { VALIDATORS } from "utils/Validators";
import { DataTree } from "entities/DataTree/dataTreeFactory"; import { DataTree } from "entities/DataTree/dataTreeFactory";
import { Intent as BlueprintIntent } from "@blueprintjs/core";
class DropdownWidget extends BaseWidget<DropdownWidgetProps, WidgetState> { class DropdownWidget extends BaseWidget<DropdownWidgetProps, WidgetState> {
static getPropertyValidationMap(): WidgetPropertyValidationType { static getPropertyValidationMap(): WidgetPropertyValidationType {
@ -181,6 +182,7 @@ export interface DropdownOption {
id?: string; id?: string;
onSelect?: (option: DropdownOption) => void; onSelect?: (option: DropdownOption) => void;
children?: DropdownOption[]; children?: DropdownOption[];
intent?: BlueprintIntent;
} }
export interface DropdownWidgetProps extends WidgetProps { export interface DropdownWidgetProps extends WidgetProps {