chore: highlight name input field for newly created js objects (#13212)

This commit is contained in:
Favour Ohanekwu 2022-05-04 02:47:41 -07:00 committed by GitHub
parent 809a633306
commit 59710de95b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 4 deletions

View File

@ -45,6 +45,16 @@ export class JSEditor {
.click({ force: true }); .click({ force: true });
cy.get(this._newJSobj).click({ force: true }); cy.get(this._newJSobj).click({ force: true });
// Assert that the name of the JS Object is focused when newly created
cy.get(this._jsObjTxt)
.should("be.focused")
.type("{enter}");
cy.wait(1000);
// Assert that the name of the JS Object is no longer in the editable form after pressing "enter"
cy.get(this._jsObjTxt).should("not.exist");
//cy.waitUntil(() => cy.get(this.locator._toastMsg).should('not.be.visible')) // fails sometimes //cy.waitUntil(() => cy.get(this.locator._toastMsg).should('not.be.visible')) // fails sometimes
//this.agHelper.WaitUntilEleDisappear(this.locator._toastMsg, 'created successfully') //this.agHelper.WaitUntilEleDisappear(this.locator._toastMsg, 'created successfully')
this.agHelper.Sleep(); this.agHelper.Sleep();

View File

@ -10,12 +10,14 @@ import { toggleShowDeviationDialog } from "actions/onboardingActions";
import { import {
getUsedActionNames, getUsedActionNames,
getSavingStatusForActionName, getSavingStatusForActionName,
getSavingStatusForJSObjectName,
} from "selectors/actionSelectors"; } from "selectors/actionSelectors";
import { import {
ACTION_INVALID_NAME_ERROR, ACTION_INVALID_NAME_ERROR,
ACTION_NAME_CONFLICT_ERROR, ACTION_NAME_CONFLICT_ERROR,
createMessage, createMessage,
} from "@appsmith/constants/messages"; } from "@appsmith/constants/messages";
import { PluginType } from "entities/Action";
type NameEditorProps = { type NameEditorProps = {
checkForGuidedTour?: boolean; checkForGuidedTour?: boolean;
@ -23,6 +25,7 @@ type NameEditorProps = {
currentActionConfig: { id: string; name: string } | undefined; currentActionConfig: { id: string; name: string } | undefined;
dispatchAction: (a: any) => any; dispatchAction: (a: any) => any;
suffixErrorMessage?: (params?: any) => string; suffixErrorMessage?: (params?: any) => string;
pluginType?: PluginType;
}; };
/** /**
@ -44,7 +47,13 @@ function NameEditor(props: NameEditorProps) {
const [forceUpdate, setForceUpdate] = useState(false); const [forceUpdate, setForceUpdate] = useState(false);
const dispatch = useDispatch(); const dispatch = useDispatch();
if (!currentActionConfig?.id) { if (!currentActionConfig?.id) {
log.error("No correct API id or Query id found in the url."); log.error(
`No correct ${
props.pluginType === PluginType.JS
? "JSObject Id"
: "API id or Query id"
} found in the url.`,
);
} }
const guidedTourEnabled = useSelector(inGuidedTour); const guidedTourEnabled = useSelector(inGuidedTour);
@ -52,7 +61,9 @@ function NameEditor(props: NameEditorProps) {
isSaving: boolean; isSaving: boolean;
error: boolean; error: boolean;
} = useSelector((state: AppState) => } = useSelector((state: AppState) =>
getSavingStatusForActionName(state, currentActionConfig?.id || ""), props.pluginType === PluginType.JS
? getSavingStatusForJSObjectName(state, currentActionConfig?.id || "")
: getSavingStatusForActionName(state, currentActionConfig?.id || ""),
); );
const conflictingNames = useSelector( const conflictingNames = useSelector(

View File

@ -19,6 +19,7 @@ import {
ACTION_NAME_PLACEHOLDER, ACTION_NAME_PLACEHOLDER,
createMessage, createMessage,
} from "@appsmith/constants/messages"; } from "@appsmith/constants/messages";
import { PluginType } from "entities/Action";
const JSObjectNameWrapper = styled.div<{ page?: string }>` const JSObjectNameWrapper = styled.div<{ page?: string }>`
min-width: 50%; min-width: 50%;
@ -67,6 +68,7 @@ export function JSObjectNameEditor(props: ActionNameEditorProps) {
<NameEditorComponent <NameEditorComponent
currentActionConfig={currentJSObjectConfig} currentActionConfig={currentJSObjectConfig}
dispatchAction={saveJSObjectName} dispatchAction={saveJSObjectName}
pluginType={PluginType.JS}
> >
{({ {({
forceUpdate, forceUpdate,

View File

@ -123,7 +123,9 @@ function* handleJSCollectionCreatedSaga(
history.push( history.push(
jsCollectionIdURL({ jsCollectionIdURL({
collectionId: id, collectionId: id,
params: {}, params: {
editName: true,
},
}), }),
); );
} }

View File

@ -4,7 +4,12 @@ import WidgetFactory from "utils/WidgetFactory";
import { FlattenedWidgetProps } from "widgets/constants"; import { FlattenedWidgetProps } from "widgets/constants";
import { getDataTree } from "./dataTreeSelectors"; import { getDataTree } from "./dataTreeSelectors";
import { getExistingPageNames } from "./entitiesSelector"; import { getExistingPageNames } from "./entitiesSelector";
import { getErrorForApiName, getIsSavingForApiName } from "./ui"; import {
getErrorForApiName,
getErrorForJSObjectName,
getIsSavingForApiName,
getIsSavingForJSObjectName,
} from "./ui";
import { getParentWidget } from "./widgetSelectors"; import { getParentWidget } from "./widgetSelectors";
/** /**
@ -50,3 +55,12 @@ export const getSavingStatusForActionName = createSelector(
error, error,
}), }),
); );
export const getSavingStatusForJSObjectName = createSelector(
getIsSavingForJSObjectName,
getErrorForJSObjectName,
(isSaving: boolean, error: boolean) => ({
isSaving,
error,
}),
);

View File

@ -17,3 +17,15 @@ export const getIsSavingForApiName = (state: AppState, id: string) =>
*/ */
export const getErrorForApiName = (state: AppState, id: string) => export const getErrorForApiName = (state: AppState, id: string) =>
state.ui.apiName.errors[id]; state.ui.apiName.errors[id];
/**
* Selector to use id and provide the status of saving a JS Object.
*/
export const getIsSavingForJSObjectName = (state: AppState, id: string) =>
state.ui.jsObjectName.isSaving[id];
/**
* Selector to use id and provide the status of error in a JS Object.
*/
export const getErrorForJSObjectName = (state: AppState, id: string) =>
state.ui.jsObjectName.errors[id];