PromucFlow_constructor/app/client/src/utils/DatasourceSagaUtils.tsx

23 lines
654 B
TypeScript
Raw Normal View History

feat: Datasource autosave improvements (#17649) * Datasource autosave improvements WIP * authenticated API and ds name updates * popup updates, api to datasource updates * issue fixes for new ds in new workspace * formatter issue fixed * console warning issue fixed * refresh edge case handled for temp ds * DS creation cypress update * datasource improvements issue fixes * CreateDS flow change cypress update * reconnect issue fixed * added space * Create Ds related script updates * SaveDs changes updated * DatasourceForm_spec.js fix * GoogleSheetsQuery_spec.js - still spec will fail * GoogleSheetsStub_spec.ts fix * MongoDatasource_spec.js fix * ElasticSearchDatasource_spec.js fix * AuthenticatedApiDatasource_spec.js * RestApiDatasource_spec.js - will stil fail * RedshiftDataSourceStub_spec.js fix * issue fixes for datasource autosave * save as datasource issue fixed * SKipped - Bug 18035 * MySQL spec fix * PostgresDatasource_spec.js fix * MySQLDataSourceStub_spec.js fix * MsSQLDataSourceStub_spec.js fix * Bug16702_Spec.ts fix * SwitchDatasource_spec.js fix * ArangoDataSourceStub_spec.js fix * code review changes, save and authorise issue fixed * cypress test issue and cypress tests fixed * client build failure issue fixed * test failure fixes * ReconnectDatasource_spec.js fix * Entity_Explorer_CopyQuery_RenameDatasource_spec.js fix * GitImport_spec.js fix * Index add * undo redo test issue fixed * fixed cypress tests of rest api ds * globalsearch_spec.js fixed * code review changes * code review comments addressed * ds schema cypress issue fixed * cypress test updates * fix updateDatasource path * rest api cypress test fixed * cypress code review changes * Removing few random .only's * replay editor fix * indexed * adding .skip Co-authored-by: “sneha122” <“sneha@appsmith.com”> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-11-30 05:59:45 +00:00
import { DATASOURCE_NAME_DEFAULT_PREFIX } from "constants/Datasource";
import { Datasource } from "entities/Datasource";
/**
*
* @param datasoures Array of datasource objects
* @returns next sequence number for untitled datasources
*/
export function getUntitledDatasourceSequence(
dsList: Array<Datasource>,
): number {
let maxSeq = Number.MIN_VALUE;
dsList
.filter((ele) => ele.name.includes(DATASOURCE_NAME_DEFAULT_PREFIX))
.forEach((ele) => {
const seq = parseInt(ele.name.split(" ")[2]);
if (!isNaN(seq) && maxSeq < seq) {
maxSeq = seq;
}
});
return maxSeq === Number.MIN_VALUE ? 1 : maxSeq + 1;
}