fix: push js object after creation (#11123)

This commit is contained in:
Apeksha Bhosale 2022-02-18 19:27:38 +05:30 committed by GitHub
parent c1f89e5830
commit 92a8df8f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 18 deletions

View File

@ -35,9 +35,11 @@ export const ExplorerJSCollectionEntity = memo(
getJSCollection(state, props.id),
) as JSCollection;
const navigateToJSCollection = useCallback(() => {
history.push(
JS_COLLECTION_ID_URL(applicationId, pageId, jsAction.id, {}),
);
if (jsAction.id) {
history.push(
JS_COLLECTION_ID_URL(applicationId, pageId, jsAction.id, {}),
);
}
}, [pageId]);
const contextMenu = (
<JSCollectionEntityContextMenu

View File

@ -40,29 +40,16 @@ const jsActionsReducer = createReducer(initialState, {
});
},
[ReduxActionErrorTypes.FETCH_JS_ACTIONS_ERROR]: () => initialState,
[ReduxActionTypes.CREATE_JS_ACTION_INIT]: (
[ReduxActionTypes.CREATE_JS_ACTION_SUCCESS]: (
state: JSCollectionDataState,
action: ReduxAction<JSCollection>,
): JSCollectionDataState =>
state.concat([
{
config: { ...action.payload, id: action.payload.name },
config: { ...action.payload },
isLoading: false,
},
]),
[ReduxActionTypes.CREATE_JS_ACTION_SUCCESS]: (
state: JSCollectionDataState,
action: ReduxAction<JSCollection>,
): JSCollectionDataState =>
state.map((a) => {
if (
a.config.pageId === action.payload.pageId &&
a.config.id === action.payload.name
) {
return { ...a, config: action.payload };
}
return a;
}),
[ReduxActionErrorTypes.CREATE_JS_ACTION_ERROR]: (
state: JSCollectionDataState,
action: ReduxAction<JSCollection>,