* updated import application modal design as v2 * updated import flow * added title, description, uploadIcon on filepicker ads component for custom file picker * adding modal of add credential for git import * added "Git Import" modal * added generating ssh key for importing flow * fixed issue of merging * chore: fix import * chore: show old import modal based on feature flag * seperated import api from connect * added datasource list on reconnect credential modal * chore: minor changes * chore: move ssh keys to git sync reducer from applications reducer * chore: minor fixes * chore: fetch datasource config for import * for pulling * for review of displaying of datasource * added reconnect datasources after git import * fix: initialize datasource with default values * fix: initialise redux for after updating datasource with default values * fixed issue of git connection init when importing * if there is a datasource config missing in import, reconnect modal should be opened * updated logic for unconfigured datasources * commented unnecessary code * fixed issue of successful import * updated import app error logic * Add un-configured datasources to Import via file response * Add test * fix * chore: refactors * change per review * fix: reset ssh keys / url * Fix issue with newly created datasources not sent * fix * chore: minor updates * chore: minor fix * WIP * added saas and rest api datasource form * feat: fixes and updates for file import flow * chore: close on upload * Refactor logic ofr finding unconfigured datasources * fix: minor fixes * Fix issue with IsPartialImport * fix * Add PartialImport flag for ImportExport service * refactoring of datasource editor form for both of importing app and editing app * fixed collapse config * Fix tests * Handle redirection back to the /applications for oAuth type * Show reconnect button on the datasources pages if the datasource configuration is skipped * added analytic events for reconnecting datasource modal * Fix the repo limit check for git import * updated test of importing app from json as new work flow * updated exported app json while testing automatically * Add isImport flag for handling OAuth redirection in import flow * WIP * updated card UI for import from git title and message in import app modal * chore: cleanup * chore: lint * fix: add is import query param to get token for oauth * fix * When the user imports the application there should not be any uncommitted changes displayed on the commit icon * Add flag to identify OAuth redirection for git import * Update the variable name * refactoring reconnect datasource modal * close git import modal when repo limit error responded * fixed issue of restoring draft data of datasource form without save on reconnect datasource modal * chore: update query * updated query name of oauth redirection url * Fix duplicate name issue in git import * fixed rest api reconnect issue on reconnect modal * init datasources and plugins after imported app, updated reconnect modal as new design * added unconfigured datasource list logic when importing and updated rest api form delete button visible * removed put default config of datasource and fixed issue on it * Add logic to check isCOnfugred in datasource API * Expose API to get un configured datasources for git import * added fetch unconfigured datasource list api when redirecting form OAuth * Remove sensitive fields from application json during export * update put call response to check for datasourceConfig * chore: use @appsmith for constants/messages * chore: use download icon and Import for Importing application label * chore: move import application text up a bit * Fix bad merge * chore: update skip to application tooltip text * fixed tooltip content of skip to application CTA * init values of datasource when importing * updated ui of git import modal as figma design * fixing padding issue of reconnect datasource modal * fixed cursor issue on import app modal * Fix issue with datasource config * chore: make code compile * chore: sort lines * fixed save button issue of dbform on reconnecting modal * fixed style of import application modal * Fix iisue with wrong value updated to flag * reverted from reconnection form style * fix: update design as per slack discussions on 2022.02.23 * fix: move modal close button to the left * Remove check for the flag and use the one from db * Set siCOnfigured as true for mockdata sets * updated creating datasource with isConfigured as false * Fix NPE while importing * fixed scrollbar issue and text alignment on reconnect datasource modal * fixed style of form container in reconnect datasource and redirecting to app if all are configured * remove unwanted fields from application json * FIx NPE for file import * fix: move close button up in import modal * remove delete button on reconnect datasource modal * Add isConfigured false while creating datasources * fix: add a gap and update color gap between git import dialog title and subtitle update color of subtext to GREY_800 * fix: use git import feature flag * fix: do not use older modal * updated selecting logic of unconfigured datasource in reconnect modal * cleanup: auto format * cleanup: refactor react component * cleanup: refactor some more * cleanup: autoformat * Fix reconnect flag for mockdatasource * During git import set the isConfigured to false for datasources * Remove decrypted field from the applicationJson file * Remove decrypted field from the applicationJson file * Add app slug to remote repo * fixed cypress test related with git * updated json while testing * Changes per review * Update the method name * fixed cypress test related with git * fixed migration cypress test * set is configured field as true on tour app * Fix issue with datasource creation for welcome tour * fixed issue of replay_editor cypress test Co-authored-by: Rishabh Saxena <rishabh@appsmith.com> Co-authored-by: Anagh Hegde <anagh@appsmith.com> Co-authored-by: Anubhav <anubhav@appsmith.com> Co-authored-by: f0c1s <iamanubhavsaini+git@gmail.com>
278 lines
7.3 KiB
TypeScript
278 lines
7.3 KiB
TypeScript
import Api from "api/Api";
|
|
import { ApiResponse } from "./ApiResponses";
|
|
import { AxiosPromise } from "axios";
|
|
import { AppColorCode } from "constants/DefaultTheme";
|
|
import { AppIconName } from "components/ads/AppIcon";
|
|
import { AppLayoutConfig } from "reducers/entityReducers/pageListReducer";
|
|
import { Datasource } from "entities/Datasource";
|
|
|
|
export type EvaluationVersion = number;
|
|
|
|
export interface PublishApplicationRequest {
|
|
applicationId: string;
|
|
}
|
|
|
|
export interface ChangeAppViewAccessRequest {
|
|
applicationId: string;
|
|
publicAccess: boolean;
|
|
}
|
|
|
|
export interface PublishApplicationResponse extends ApiResponse {
|
|
data: unknown;
|
|
}
|
|
|
|
export interface ApplicationPagePayload {
|
|
id: string;
|
|
name: string;
|
|
isDefault: boolean;
|
|
}
|
|
|
|
export type GitApplicationMetadata =
|
|
| {
|
|
branchName: string;
|
|
defaultBranchName: string;
|
|
remoteUrl: string;
|
|
repoName: string;
|
|
browserSupportedUrl?: string;
|
|
isRepoPrivate?: boolean;
|
|
browserSupportedRemoteUrl: string;
|
|
defaultApplicationId: string;
|
|
}
|
|
| undefined;
|
|
|
|
export interface ApplicationResponsePayload {
|
|
id: string;
|
|
name: string;
|
|
organizationId: string;
|
|
evaluationVersion?: EvaluationVersion;
|
|
pages?: ApplicationPagePayload[];
|
|
appIsExample: boolean;
|
|
appLayout?: AppLayoutConfig;
|
|
unreadCommentThreads?: number;
|
|
gitApplicationMetadata: GitApplicationMetadata;
|
|
}
|
|
|
|
export interface FetchApplicationResponse extends ApiResponse {
|
|
data: ApplicationResponsePayload & { pages: ApplicationPagePayload[] };
|
|
}
|
|
|
|
export interface FetchApplicationsResponse extends ApiResponse {
|
|
data: Array<ApplicationResponsePayload & { pages: ApplicationPagePayload[] }>;
|
|
}
|
|
|
|
export interface CreateApplicationResponse extends ApiResponse {
|
|
data: ApplicationResponsePayload;
|
|
}
|
|
|
|
export interface CreateApplicationRequest {
|
|
name: string;
|
|
orgId: string;
|
|
color?: AppColorCode;
|
|
icon?: AppIconName;
|
|
}
|
|
|
|
export interface SetDefaultPageRequest {
|
|
id: string;
|
|
applicationId: string;
|
|
}
|
|
|
|
export interface DeleteApplicationRequest {
|
|
applicationId: string;
|
|
}
|
|
|
|
export interface DuplicateApplicationRequest {
|
|
applicationId: string;
|
|
}
|
|
export interface ForkApplicationRequest {
|
|
applicationId: string;
|
|
organizationId: string;
|
|
}
|
|
|
|
export interface GetAllApplicationResponse extends ApiResponse {
|
|
data: Array<ApplicationResponsePayload & { pages: ApplicationPagePayload[] }>;
|
|
}
|
|
|
|
export type UpdateApplicationPayload = {
|
|
icon?: string;
|
|
color?: string;
|
|
name?: string;
|
|
currentApp?: boolean;
|
|
appLayout?: AppLayoutConfig;
|
|
};
|
|
|
|
export type UpdateApplicationRequest = UpdateApplicationPayload & {
|
|
id: string;
|
|
};
|
|
|
|
export interface ApplicationObject {
|
|
id: string;
|
|
name: string;
|
|
icon?: string;
|
|
color?: string;
|
|
organizationId: string;
|
|
pages: ApplicationPagePayload[];
|
|
userPermissions: string[];
|
|
}
|
|
|
|
export interface UserRoles {
|
|
name: string;
|
|
roleName: string;
|
|
username: string;
|
|
}
|
|
|
|
export interface OrganizationApplicationObject {
|
|
applications: Array<ApplicationObject>;
|
|
organization: {
|
|
id: string;
|
|
name: string;
|
|
};
|
|
userRoles: Array<UserRoles>;
|
|
}
|
|
export interface FetchUsersApplicationsOrgsResponse extends ApiResponse {
|
|
data: {
|
|
organizationApplications: Array<OrganizationApplicationObject>;
|
|
user: string;
|
|
newReleasesCount: string;
|
|
releaseItems: Array<Record<string, any>>;
|
|
};
|
|
}
|
|
|
|
export interface FetchUnconfiguredDatasourceListResponse extends ApiResponse {
|
|
data: Array<Datasource>;
|
|
}
|
|
|
|
export interface ImportApplicationRequest {
|
|
orgId: string;
|
|
applicationFile?: File;
|
|
progress?: (progressEvent: ProgressEvent) => void;
|
|
onSuccessCallback?: () => void;
|
|
}
|
|
|
|
class ApplicationApi extends Api {
|
|
static baseURL = "v1/applications";
|
|
static publishURLPath = (applicationId: string) =>
|
|
`/publish/${applicationId}`;
|
|
static createApplicationPath = (orgId: string) => `?orgId=${orgId}`;
|
|
static changeAppViewAccessPath = (applicationId: string) =>
|
|
`/${applicationId}/changeAccess`;
|
|
static setDefaultPagePath = (request: SetDefaultPageRequest) =>
|
|
`${ApplicationApi.baseURL}/${request.applicationId}/page/${request.id}/makeDefault`;
|
|
static publishApplication(
|
|
publishApplicationRequest: PublishApplicationRequest,
|
|
): AxiosPromise<PublishApplicationResponse> {
|
|
return Api.post(
|
|
ApplicationApi.baseURL +
|
|
ApplicationApi.publishURLPath(publishApplicationRequest.applicationId),
|
|
undefined,
|
|
{},
|
|
);
|
|
}
|
|
static fetchApplications(): AxiosPromise<FetchApplicationsResponse> {
|
|
return Api.get(ApplicationApi.baseURL);
|
|
}
|
|
|
|
static getAllApplication(): AxiosPromise<GetAllApplicationResponse> {
|
|
return Api.get(ApplicationApi.baseURL + "/new");
|
|
}
|
|
|
|
static fetchApplication(
|
|
applicationId: string,
|
|
): AxiosPromise<FetchApplicationResponse> {
|
|
return Api.get(ApplicationApi.baseURL + "/" + applicationId);
|
|
}
|
|
|
|
static fetchUnconfiguredDatasourceList(payload: {
|
|
applicationId: string;
|
|
orgId: string;
|
|
}): AxiosPromise<FetchUnconfiguredDatasourceListResponse> {
|
|
return Api.get(
|
|
`${ApplicationApi.baseURL}/import/${payload.orgId}/datasources?defaultApplicationId=${payload.applicationId}`,
|
|
);
|
|
}
|
|
|
|
static fetchApplicationForViewMode(
|
|
applicationId: string,
|
|
): AxiosPromise<FetchApplicationResponse> {
|
|
return Api.get(ApplicationApi.baseURL + `/view/${applicationId}`);
|
|
}
|
|
|
|
static createApplication(
|
|
request: CreateApplicationRequest,
|
|
): AxiosPromise<PublishApplicationResponse> {
|
|
return Api.post(
|
|
ApplicationApi.baseURL +
|
|
ApplicationApi.createApplicationPath(request.orgId),
|
|
{ name: request.name, color: request.color, icon: request.icon },
|
|
);
|
|
}
|
|
|
|
static setDefaultApplicationPage(
|
|
request: SetDefaultPageRequest,
|
|
): AxiosPromise<ApiResponse> {
|
|
return Api.put(ApplicationApi.setDefaultPagePath(request));
|
|
}
|
|
|
|
static changeAppViewAccess(
|
|
request: ChangeAppViewAccessRequest,
|
|
): AxiosPromise<ApiResponse> {
|
|
return Api.put(
|
|
ApplicationApi.baseURL +
|
|
ApplicationApi.changeAppViewAccessPath(request.applicationId),
|
|
{ publicAccess: request.publicAccess },
|
|
);
|
|
}
|
|
|
|
static updateApplication(
|
|
request: UpdateApplicationRequest,
|
|
): AxiosPromise<ApiResponse> {
|
|
const { id, ...rest } = request;
|
|
return Api.put(ApplicationApi.baseURL + "/" + id, rest);
|
|
}
|
|
|
|
static deleteApplication(
|
|
request: DeleteApplicationRequest,
|
|
): AxiosPromise<ApiResponse> {
|
|
return Api.delete(ApplicationApi.baseURL + "/" + request.applicationId);
|
|
}
|
|
|
|
static duplicateApplication(
|
|
request: DuplicateApplicationRequest,
|
|
): AxiosPromise<ApiResponse> {
|
|
return Api.post(ApplicationApi.baseURL + "/clone/" + request.applicationId);
|
|
}
|
|
|
|
static forkApplication(
|
|
request: ForkApplicationRequest,
|
|
): AxiosPromise<ApiResponse> {
|
|
return Api.post(
|
|
ApplicationApi.baseURL +
|
|
"/" +
|
|
request.applicationId +
|
|
"/fork/" +
|
|
request.organizationId,
|
|
);
|
|
}
|
|
|
|
static importApplicationToOrg(
|
|
request: ImportApplicationRequest,
|
|
): AxiosPromise<ApiResponse> {
|
|
const formData = new FormData();
|
|
if (request.applicationFile) {
|
|
formData.append("file", request.applicationFile);
|
|
}
|
|
return Api.post(
|
|
ApplicationApi.baseURL + "/import/" + request.orgId,
|
|
formData,
|
|
null,
|
|
{
|
|
headers: {
|
|
"Content-Type": "multipart/form-data",
|
|
},
|
|
onUploadProgress: request.progress,
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
export default ApplicationApi;
|