PromucFlow_constructor/app/client/src/api/ApplicationApi.tsx

179 lines
4.6 KiB
TypeScript
Raw Normal View History

import Api from "./Api";
import { ApiResponse } from "./ApiResponses";
import { AxiosPromise } from "axios";
export interface PublishApplicationRequest {
applicationId: string;
}
export interface ChangeAppViewAccessRequest {
applicationId: string;
publicAccess: boolean;
}
export interface PublishApplicationResponse extends ApiResponse {
data: {};
}
export interface ApplicationPagePayload {
id: string;
name: string;
isDefault: boolean;
}
export interface ApplicationResponsePayload {
id: string;
name: string;
organizationId: string;
pages?: ApplicationPagePayload[];
2020-08-13 09:33:44 +00:00
appIsExample: boolean;
}
2020-06-25 10:04:57 +00:00
// export interface FetchApplicationResponse extends ApiResponse {
// data: ApplicationResponsePayload & { pages: ApplicationPagePayload[] };
// }
2020-03-06 04:59:24 +00:00
export interface FetchApplicationsResponse extends ApiResponse {
data: Array<ApplicationResponsePayload & { pages: ApplicationPagePayload[] }>;
}
export interface CreateApplicationResponse extends ApiResponse {
data: ApplicationResponsePayload;
}
export interface CreateApplicationRequest {
name: string;
orgId: string;
}
2020-01-27 08:24:58 +00:00
export interface SetDefaultPageRequest {
id: string;
2020-01-27 08:24:58 +00:00
applicationId: string;
}
export interface DeleteApplicationRequest {
applicationId: string;
}
export interface DuplicateApplicationRequest {
applicationId: string;
}
export interface GetAllApplicationResponse extends ApiResponse {
data: Array<ApplicationResponsePayload & { pages: ApplicationPagePayload[] }>;
}
Homepage redesign with themes (#482) * Updating homepage body color * WIP: Fixing scrolls and adding anchors * Removing divider from bottom of the page. * Adding hover background color to app card * Changing edit and launch icons. * Fixing app name paddding in card. * Fixing workspaces overflow * Adding right padding to applications view * Adding share icon to share btn * Fixing Application card styles. * Fixing text decoration in button. * Adding new workspace button * Fixing new workspace and new app styles. * Adding icon sizes. * Fixing Org Name and Org settings menu. * Application menu working * Fixing overlay visibility on app card * Fixing settings page content width. * Fixing workspace icon * Changing app card colors. * Removing debugger * Adding app icon. * Fixing the spaces in application card * Adding storybook-static folder to gitignore. * Adding other storybook files. * Adding menu items for app * Removing cypress selector from text. * Menu width issue fixed * Default app icon color added * Removing hardcoded colors * Removing hardcoded colors. * Light Mode on! * Showing correct icon and color in menu * Update color working properly. * Updating appIcon * Editable text working. * Adding validator * Adding edit permissions to menu * Removing box shadow on app card. * Fixing context menu fill color * Fixing Menu hover issues. * Fixing menu open close hover issues. * Fixing settings pages * Changed Workspace to org. * Fix: State management in EditableText Component (#540) * Error state height is fixed as per design * savingState prop condition fixed * Fixing createnew. * Fixing saving state for application card. * Fixed application card editable text error. * Fixing issue caused during merge. * Fixing tests in create org. * Removing commented code. * Removing unwanted vars. * Fixing delete duplicate tests. * Latest color palette. * Fixing form and table widget. * Removing switcher from header * Removing unused files * Fixing app card context dropdown * Show overlay fix * Adding localStorage support to theme. * Making dark mode the default. Co-authored-by: Rohit Kumawat <rohit.kumawat@primathon.in>
2020-09-16 11:50:47 +00:00
export type UpdateApplicationPayload = {
icon?: string;
color?: string;
name?: string;
};
export type UpdateApplicationRequest = UpdateApplicationPayload & {
id: string;
};
export interface ApplicationObject {
id: string;
name: string;
Homepage redesign with themes (#482) * Updating homepage body color * WIP: Fixing scrolls and adding anchors * Removing divider from bottom of the page. * Adding hover background color to app card * Changing edit and launch icons. * Fixing app name paddding in card. * Fixing workspaces overflow * Adding right padding to applications view * Adding share icon to share btn * Fixing Application card styles. * Fixing text decoration in button. * Adding new workspace button * Fixing new workspace and new app styles. * Adding icon sizes. * Fixing Org Name and Org settings menu. * Application menu working * Fixing overlay visibility on app card * Fixing settings page content width. * Fixing workspace icon * Changing app card colors. * Removing debugger * Adding app icon. * Fixing the spaces in application card * Adding storybook-static folder to gitignore. * Adding other storybook files. * Adding menu items for app * Removing cypress selector from text. * Menu width issue fixed * Default app icon color added * Removing hardcoded colors * Removing hardcoded colors. * Light Mode on! * Showing correct icon and color in menu * Update color working properly. * Updating appIcon * Editable text working. * Adding validator * Adding edit permissions to menu * Removing box shadow on app card. * Fixing context menu fill color * Fixing Menu hover issues. * Fixing menu open close hover issues. * Fixing settings pages * Changed Workspace to org. * Fix: State management in EditableText Component (#540) * Error state height is fixed as per design * savingState prop condition fixed * Fixing createnew. * Fixing saving state for application card. * Fixed application card editable text error. * Fixing issue caused during merge. * Fixing tests in create org. * Removing commented code. * Removing unwanted vars. * Fixing delete duplicate tests. * Latest color palette. * Fixing form and table widget. * Removing switcher from header * Removing unused files * Fixing app card context dropdown * Show overlay fix * Adding localStorage support to theme. * Making dark mode the default. Co-authored-by: Rohit Kumawat <rohit.kumawat@primathon.in>
2020-09-16 11:50:47 +00:00
icon?: string;
color?: string;
organizationId: string;
pages: ApplicationPagePayload[];
userPermissions: string[];
}
export interface OrganizationApplicationObject {
applications: Array<ApplicationObject>;
organization: {
id: string;
name: string;
};
}
export interface FetchUsersApplicationsOrgsResponse extends ApiResponse {
data: {
organizationApplications: Array<OrganizationApplicationObject>;
user: string;
};
}
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`;
2020-01-27 08:24:58 +00:00
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");
}
2020-03-06 04:59:24 +00:00
static fetchApplication(
applicationId: string,
): AxiosPromise<FetchApplicationsResponse> {
return Api.get(ApplicationApi.baseURL + applicationId);
}
static createApplication(
request: CreateApplicationRequest,
): AxiosPromise<PublishApplicationResponse> {
return Api.post(
ApplicationApi.baseURL +
ApplicationApi.createApplicationPath(request.orgId),
{ name: request.name },
);
}
2020-01-27 08:24:58 +00:00
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 },
);
}
Homepage redesign with themes (#482) * Updating homepage body color * WIP: Fixing scrolls and adding anchors * Removing divider from bottom of the page. * Adding hover background color to app card * Changing edit and launch icons. * Fixing app name paddding in card. * Fixing workspaces overflow * Adding right padding to applications view * Adding share icon to share btn * Fixing Application card styles. * Fixing text decoration in button. * Adding new workspace button * Fixing new workspace and new app styles. * Adding icon sizes. * Fixing Org Name and Org settings menu. * Application menu working * Fixing overlay visibility on app card * Fixing settings page content width. * Fixing workspace icon * Changing app card colors. * Removing debugger * Adding app icon. * Fixing the spaces in application card * Adding storybook-static folder to gitignore. * Adding other storybook files. * Adding menu items for app * Removing cypress selector from text. * Menu width issue fixed * Default app icon color added * Removing hardcoded colors * Removing hardcoded colors. * Light Mode on! * Showing correct icon and color in menu * Update color working properly. * Updating appIcon * Editable text working. * Adding validator * Adding edit permissions to menu * Removing box shadow on app card. * Fixing context menu fill color * Fixing Menu hover issues. * Fixing menu open close hover issues. * Fixing settings pages * Changed Workspace to org. * Fix: State management in EditableText Component (#540) * Error state height is fixed as per design * savingState prop condition fixed * Fixing createnew. * Fixing saving state for application card. * Fixed application card editable text error. * Fixing issue caused during merge. * Fixing tests in create org. * Removing commented code. * Removing unwanted vars. * Fixing delete duplicate tests. * Latest color palette. * Fixing form and table widget. * Removing switcher from header * Removing unused files * Fixing app card context dropdown * Show overlay fix * Adding localStorage support to theme. * Making dark mode the default. Co-authored-by: Rohit Kumawat <rohit.kumawat@primathon.in>
2020-09-16 11:50:47 +00:00
static updateApplication(
request: UpdateApplicationRequest,
): AxiosPromise<ApiResponse> {
const { id, ...rest } = request;
return Api.put(ApplicationApi.baseURL + id, rest);
}
2020-01-27 08:24:58 +00:00
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);
}
}
export default ApplicationApi;