Fix/api editor enhancement (#5095)

* Keep datasource tab open when there are datasources configured in API editor

* Save headers when users save an action as datasource
This commit is contained in:
arunvjn 2021-06-15 11:24:14 +05:30 committed by GitHub
parent d54dbd1596
commit 4ee614b132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -432,7 +432,9 @@ function ImportedHeaders(props: { headers: any }) {
function ApiEditorForm(props: Props) {
const [selectedIndex, setSelectedIndex] = useState(0);
const [showDatasources, toggleDatasources] = useState(false);
const [showDatasources, toggleDatasources] = useState(
!!props.datasources.length,
);
const [
apiBindHelpSectionVisible,
setApiBindHelpSectionVisible,

View File

@ -76,6 +76,7 @@ import { APPSMITH_TOKEN_STORAGE_KEY } from "pages/Editor/SaaSEditor/constants";
import { checkAndGetPluginFormConfigsSaga } from "sagas/PluginSagas";
import { PluginType } from "entities/Action";
import LOG_TYPE from "entities/AppsmithConsole/logtype";
import { isDynamicValue } from "utils/DynamicBindingUtils";
function* fetchDatasourcesSaga() {
try {
@ -573,7 +574,21 @@ function* storeAsDatasourceSaga() {
const pageId = yield select(getCurrentPageId);
let datasource = _.get(values, "datasource");
datasource = _.omit(datasource, ["name"]);
const originalHeaders = _.get(values, "actionConfiguration.headers", []);
const [datasourceHeaders, actionHeaders] = _.partition(
originalHeaders,
({ key, value }: { key: string; value: string }) => {
return !(isDynamicValue(key) || isDynamicValue(value));
},
);
yield put(
setActionProperty({
actionId: values.id,
propertyName: "actionConfiguration.headers",
value: actionHeaders,
}),
);
_.set(datasource, "datasourceConfiguration.headers", datasourceHeaders);
history.push(DATA_SOURCES_EDITOR_URL(applicationId, pageId));
yield put(createDatasourceFromForm(datasource));