From 825c4a3609b16cd1550a47ffb3538682477653d1 Mon Sep 17 00:00:00 2001 From: Max Kovalenko Date: Tue, 24 Dec 2019 15:57:56 -0500 Subject: [PATCH 01/11] upcoming 0.10.0 release - dev branch --- .circleci/config.yml | 39 ++ .env.example | 1 + README.md | 45 +- package.json | 2 +- src/Routes.tsx | 5 +- src/app.css | 4 + src/classes/dataStore/app.tsx | 2 +- .../notification/errorHandler/errorHandler.ts | 8 + src/classes/utils/http/retryRequest.ts | 18 + src/client/bindings.ts | 19 +- src/client/models/index.ts | 239 ++++++++++- src/client/models/mappers.ts | 261 ++++++++++++ src/client/models/parameters.ts | 58 ++- src/client/supportHubApi.ts | 286 +++++++++++-- src/client/supportHubApiContext.ts | 12 +- src/components/check/auth_check/AuthCheck.tsx | 21 + .../single/PermissionCheck.tsx | 79 ++++ .../budget/entity/EntityBudgetContent.tsx | 3 +- .../entity/card/action/create/CreateCard.tsx | 107 +++++ .../entity/card/action/edit/EditCard.tsx | 96 +++++ .../entity/card/action/move/MoveCard.tsx | 134 ++++++ .../entity/card/single/card/CardCard.tsx | 51 ++- .../entity/column/single/card/ColumnCard.tsx | 23 +- .../invoice/single/create/NewInvoice.tsx | 67 ++- .../single/view/content/InvoiceContent.tsx | 6 + .../entity/my_library/many/MyLibraryItems.tsx | 2 +- .../my_library/single/action/AddToLibrary.tsx | 70 ++++ .../my_library/single/card/ItemCard.tsx | 5 +- .../pricing_block/single/PricingBlock.tsx | 52 +++ .../many/cards_list/ProjectCardList.tsx | 24 +- .../project/single/card/ProjectCard.tsx | 4 - .../project/single/info/ProjectInfo.tsx | 16 +- .../repository/card/ProjectRepoCard.tsx | 20 + .../facebookButton/FacebookLoginButton.tsx | 35 +- .../link/withChecks/PermissionCheckLink.tsx | 8 +- .../project/view/ProjectViewSidebar.tsx | 30 +- src/layouts/auth/login/LoginLayout.tsx | 5 - src/layouts/entity/board/page/BoardPage.tsx | 2 +- .../project/pricing/ProjectPricingLayout.tsx | 108 +++++ .../entity/project/view/ProjectPage.tsx | 149 +++++++ .../import/project/ProjectImportLayout.tsx | 2 +- swagger.json | 388 ++++++++++++++++-- 42 files changed, 2291 insertions(+), 215 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .env.example create mode 100644 src/classes/utils/http/retryRequest.ts create mode 100644 src/components/check/auth_check/AuthCheck.tsx create mode 100644 src/components/check/permission_check/single/PermissionCheck.tsx create mode 100644 src/components/entity/card/action/create/CreateCard.tsx create mode 100644 src/components/entity/card/action/edit/EditCard.tsx create mode 100644 src/components/entity/card/action/move/MoveCard.tsx create mode 100644 src/components/entity/my_library/single/action/AddToLibrary.tsx create mode 100644 src/components/entity/product/pricing_block/single/PricingBlock.tsx create mode 100644 src/components/entity/repository/card/ProjectRepoCard.tsx create mode 100644 src/layouts/entity/project/pricing/ProjectPricingLayout.tsx create mode 100644 src/layouts/entity/project/view/ProjectPage.tsx diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..261a516 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,39 @@ +version: 2 +jobs: + build: + docker: + - image: node:12-alpine + steps: + - checkout + - run: pwd && ls -la + - run: node -v + - run: apk add tar ca-certificates + - run: + name: copy config + command: cp src/config/config.example.js src/config/config.js + - restore_cache: + name: Restore Yarn Package Cache + keys: + - yarn-packages-{{ checksum "yarn.lock" }} + - run: + name: Install Dependencies + command: yarn install --frozen-lockfile + - save_cache: + name: Save Yarn Package Cache + key: yarn-packages-{{ checksum "yarn.lock" }} + paths: + - ~/.cache/yarn + - run: + name: Production build + command: CI=false yarn build + - run: + name: create tar from build + command: tar cvf build.tar build + - store_artifacts: + path: build.tar + +workflows: + version: 2 + build_and_test: + jobs: + - build diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cea9a39 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +REACT_APP_API_URL=http://localhost:8000 \ No newline at end of file diff --git a/README.md b/README.md index 897dc83..1bbb36e 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,3 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +# Gitcom frontend -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.
-You will also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). +Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. diff --git a/package.json b/package.json index ee26183..bca5afe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitcom-front", - "version": "0.9.0", + "version": "0.10.0", "private": true, "dependencies": { "@azure/ms-rest-js": "^2.0.1", diff --git a/src/Routes.tsx b/src/Routes.tsx index 7c91028..8737233 100644 --- a/src/Routes.tsx +++ b/src/Routes.tsx @@ -11,11 +11,12 @@ import LoginWithGitLabLayout from "./layouts/auth/external/gitlab/logInWith/Logi import LoginWithGitHubLayout from "./layouts/auth/external/github/loginWith/LoginWithGitHubLayout"; import ExternalRepoLayout from "./layouts/repos/external/default/ExternalRepoLayout"; import ProjectImportLayout from "./layouts/import/project/ProjectImportLayout"; -import ProjectPage from "./layouts/entity/project/page/ProjectPage"; +import ProjectPage from "./layouts/entity/project/view/ProjectPage"; import BoardPage from "./layouts/entity/board/page/BoardPage"; import SubscriptionLayout from "./layouts/account/subscription/SubscriptionLayout"; import LibraryLayout from "./layouts/account/library/LibraryLayout"; import EditProjectLayout from "./layouts/entity/project/edit/EditProjectLayout"; +import ProjectPricingLayout from "./layouts/entity/project/pricing/ProjectPricingLayout"; class Routes extends React.Component { render() { @@ -49,6 +50,8 @@ class Routes extends React.Component { + + diff --git a/src/app.css b/src/app.css index 6cba1c1..75d96b9 100644 --- a/src/app.css +++ b/src/app.css @@ -126,6 +126,10 @@ p, b { cursor: pointer; } +.select-padding > div { + padding: 0 25px; +} + @media only screen and (min-width: 767px) { .desktop-zero-height { height: 0; diff --git a/src/classes/dataStore/app.tsx b/src/classes/dataStore/app.tsx index a63732a..cc9e82a 100644 --- a/src/classes/dataStore/app.tsx +++ b/src/classes/dataStore/app.tsx @@ -10,7 +10,7 @@ class App { authorizedUser: UserModel|null = null; constructor(props: any) { - this.apiClient = new SupportHubApi({ + this.apiClient = new SupportHubApi('Card', { baseUri: window.AppConfig.api_url }); diff --git a/src/classes/notification/errorHandler/errorHandler.ts b/src/classes/notification/errorHandler/errorHandler.ts index e93382c..e6d9c9e 100644 --- a/src/classes/notification/errorHandler/errorHandler.ts +++ b/src/classes/notification/errorHandler/errorHandler.ts @@ -10,6 +10,14 @@ export function handleApiError(response: any): void { } let json: any; try { + if (response.status === 401) { + notification['error']({ + message: 'Unauthorized, please log in again', + description: '' + }); + window.App.logout(); + return; + } if (response.status === 404) { notification['error']({ message: 'Not found', diff --git a/src/classes/utils/http/retryRequest.ts b/src/classes/utils/http/retryRequest.ts new file mode 100644 index 0000000..9d261af --- /dev/null +++ b/src/classes/utils/http/retryRequest.ts @@ -0,0 +1,18 @@ +export function retryRequest(funcToExec: any, getTargetRef: any, targetValue: any, retryCount: number = 7) { + let execCount = 0; + executeFunc(funcToExec, execCount, getTargetRef, targetValue, retryCount); +} + +function executeFunc(funcToExec: any, execCount: number, getTargetRef: any, targetValue: any, retryCount: number) { + try { + if (execCount < retryCount && getTargetRef() != targetValue) { + setTimeout(() => { + funcToExec(); + executeFunc(funcToExec, execCount, getTargetRef, targetValue, retryCount); + }, 500 + (500 * execCount)); + execCount++; + } + } catch (e) { + // ignored + } +} diff --git a/src/client/bindings.ts b/src/client/bindings.ts index 9325ed8..5d18744 100644 --- a/src/client/bindings.ts +++ b/src/client/bindings.ts @@ -1,4 +1,4 @@ -import {CurrencyType, CurrencyType1, CurrencyType3, EntityType, EntityType1, UserBalance} from "./models"; +import {CurrencyType, CurrencyType1, CurrencyType3, EntityType} from "./models"; export class ProjectModel { guid?: string; @@ -7,6 +7,7 @@ export class ProjectModel { repository_guid?: string; creator_guid?: string; base_uri?: string; + stars_count?: number; created_at?: string; updated_at?: string; } @@ -82,7 +83,7 @@ export class InvoiceModel { * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', * 'UserBalance' */ - entity_type?: EntityType1; + entity_type?: EntityType; amount?: number; status?: string; /** @@ -131,3 +132,17 @@ export class LibraryItem { created_at?: string; } +export class ProjectProduct { + guid?: string; + name?: string; + description?: string; + /** + * url to view product info (optional) + */ + url?: string; + project_guid?: string; + usd_price?: number; + duration_hours?: number; + created_at?: string; + updated_at?: string; +} diff --git a/src/client/models/index.ts b/src/client/models/index.ts index db996d3..4c69e0a 100644 --- a/src/client/models/index.ts +++ b/src/client/models/index.ts @@ -47,6 +47,7 @@ export interface Project { repositoryGuid?: string; creatorGuid?: string; baseUri?: string; + starsCount?: number; createdAt?: string; updatedAt?: string; } @@ -133,7 +134,7 @@ export interface FundingBalance { entityGuid?: string; /** * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', - * 'UserBalance', 'User' + * 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' */ entityType?: EntityType; amount?: number; @@ -166,7 +167,7 @@ export interface Invoice { entityGuid?: string; /** * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', - * 'UserBalance', 'User' + * 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' */ entityType?: EntityType1; amount?: number; @@ -216,6 +217,24 @@ export interface LibraryItem { createdAt?: string; } +/** + * An interface representing ProjectProduct. + */ +export interface ProjectProduct { + guid?: string; + name?: string; + description?: string; + /** + * url to view product info (optional) + */ + url?: string; + projectGuid?: string; + usdPrice?: number; + durationHours?: number; + createdAt?: string; + updatedAt?: string; +} + /** * An interface representing GetLoginOKResponseData. */ @@ -369,6 +388,20 @@ export interface PostImportRepositoryOKResponse { data?: PostImportRepositoryOKResponseData; } +/** + * An interface representing GetRepoOKResponseData. + */ +export interface GetRepoOKResponseData { + repository?: Repository; +} + +/** + * An interface representing GetRepoOKResponse. + */ +export interface GetRepoOKResponse { + data?: GetRepoOKResponseData; +} + /** * An interface representing GetProjectOKResponseData. */ @@ -467,6 +500,34 @@ export interface GetProjectByAliasOKResponse { data?: GetProjectByAliasOKResponseData; } +/** + * An interface representing CreateCardCreatedResponseData. + */ +export interface CreateCardCreatedResponseData { + card?: Card; +} + +/** + * An interface representing CreateCardCreatedResponse. + */ +export interface CreateCardCreatedResponse { + data?: CreateCardCreatedResponseData; +} + +/** + * An interface representing EditCardOKResponseData. + */ +export interface EditCardOKResponseData { + card?: Card; +} + +/** + * An interface representing EditCardOKResponse. + */ +export interface EditCardOKResponse { + data?: EditCardOKResponseData; +} + /** * An interface representing GetCardWorkOKResponseData. */ @@ -691,6 +752,27 @@ export interface RemoveProjectFromMyLibraryOKResponse { data?: RemoveProjectFromMyLibraryOKResponseData; } +/** + * An interface representing GetMyLibraryProjectStatusOKResponseDataStatus. + */ +export interface GetMyLibraryProjectStatusOKResponseDataStatus { + inLibrary?: boolean; +} + +/** + * An interface representing GetMyLibraryProjectStatusOKResponseData. + */ +export interface GetMyLibraryProjectStatusOKResponseData { + status?: GetMyLibraryProjectStatusOKResponseDataStatus; +} + +/** + * An interface representing GetMyLibraryProjectStatusOKResponse. + */ +export interface GetMyLibraryProjectStatusOKResponse { + data?: GetMyLibraryProjectStatusOKResponseData; +} + /** * An interface representing GetMeOKResponseData. */ @@ -789,6 +871,20 @@ export interface GetRandomProjectsOKResponse { data?: GetRandomProjectsOKResponseData; } +/** + * An interface representing GetProjectProductsOKResponseData. + */ +export interface GetProjectProductsOKResponseData { + products?: ProjectProduct[]; +} + +/** + * An interface representing GetProjectProductsOKResponse. + */ +export interface GetProjectProductsOKResponse { + data?: GetProjectProductsOKResponseData; +} + /** * An interface representing SupportHubApiOptions. */ @@ -834,6 +930,24 @@ export interface SupportHubApiEditProjectOptionalParams extends msRest.RequestOp description?: string; } +/** + * Optional Parameters. + */ +export interface SupportHubApiCreateCardOptionalParams extends msRest.RequestOptionsBase { + description?: string; + columnOrder?: number; +} + +/** + * Optional Parameters. + */ +export interface SupportHubApiEditCardOptionalParams extends msRest.RequestOptionsBase { + name?: string; + description?: string; + columnOrder?: number; + columnGuid?: string; +} + /** * Defines values for ServiceType. * Possible values include: 'GitHub', 'GitLab' @@ -845,11 +959,11 @@ export type ServiceType = 'GitHub' | 'GitLab'; /** * Defines values for EntityType. * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', - * 'UserBalance', 'User' + * 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' * @readonly * @enum {string} */ -export type EntityType = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User'; +export type EntityType = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User' | 'ProjectProductPurchase' | 'BoardColumn'; /** * Defines values for CurrencyType. @@ -872,11 +986,11 @@ export type CurrencyType1 = 'Usd' | 'BitCoin' | 'Ethereum' | 'Erc20Token' | 'Wav /** * Defines values for EntityType1. * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', - * 'UserBalance', 'User' + * 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' * @readonly * @enum {string} */ -export type EntityType1 = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User'; +export type EntityType1 = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User' | 'ProjectProductPurchase' | 'BoardColumn'; /** * Defines values for CurrencyType2. @@ -907,20 +1021,20 @@ export type ServiceType1 = 'GitHub' | 'GitLab'; /** * Defines values for EntityType2. * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', - * 'UserBalance', 'User' + * 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' * @readonly * @enum {string} */ -export type EntityType2 = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User'; +export type EntityType2 = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User' | 'ProjectProductPurchase' | 'BoardColumn'; /** * Defines values for EntityType3. * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', - * 'UserBalance', 'User' + * 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' * @readonly * @enum {string} */ -export type EntityType3 = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User'; +export type EntityType3 = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User' | 'ProjectProductPurchase' | 'BoardColumn'; /** * Defines values for CurrencyType4. @@ -933,11 +1047,12 @@ export type CurrencyType4 = 'Usd' | 'BitCoin' | 'Ethereum' | 'Erc20Token' | 'Wav /** * Defines values for EntityType4. - * Possible values include: 'Project', 'Board', 'BoardColumn', 'Card' + * Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', 'BacklogItem', + * 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' * @readonly * @enum {string} */ -export type EntityType4 = 'Project' | 'Board' | 'BoardColumn' | 'Card'; +export type EntityType4 = 'ProjectCategory' | 'Project' | 'Board' | 'Card' | 'BacklogItem' | 'UserBalance' | 'User' | 'ProjectProductPurchase' | 'BoardColumn'; /** * Contains response data for the getLogin operation. @@ -1099,6 +1214,26 @@ export type PostImportRepositoryResponse = PostImportRepositoryOKResponse & { }; }; +/** + * Contains response data for the getRepo operation. + */ +export type GetRepoResponse = GetRepoOKResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: GetRepoOKResponse; + }; +}; + /** * Contains response data for the getProject operation. */ @@ -1239,6 +1374,46 @@ export type GetProjectByAliasResponse = GetProjectByAliasOKResponse & { }; }; +/** + * Contains response data for the createCard operation. + */ +export type CreateCardResponse = CreateCardCreatedResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: CreateCardCreatedResponse; + }; +}; + +/** + * Contains response data for the editCard operation. + */ +export type EditCardResponse = EditCardOKResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: EditCardOKResponse; + }; +}; + /** * Contains response data for the getCardWork operation. */ @@ -1559,6 +1734,26 @@ export type RemoveProjectFromMyLibraryResponse = RemoveProjectFromMyLibraryOKRes }; }; +/** + * Contains response data for the getMyLibraryProjectStatus operation. + */ +export type GetMyLibraryProjectStatusResponse = GetMyLibraryProjectStatusOKResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: GetMyLibraryProjectStatusOKResponse; + }; +}; + /** * Contains response data for the getMe operation. */ @@ -1698,3 +1893,23 @@ export type GetRandomProjectsResponse = GetRandomProjectsOKResponse & { parsedBody: GetRandomProjectsOKResponse; }; }; + +/** + * Contains response data for the getProjectProducts operation. + */ +export type GetProjectProductsResponse = GetProjectProductsOKResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: GetProjectProductsOKResponse; + }; +}; diff --git a/src/client/models/mappers.ts b/src/client/models/mappers.ts index cf2cfd0..038c624 100644 --- a/src/client/models/mappers.ts +++ b/src/client/models/mappers.ts @@ -139,6 +139,12 @@ export const Project: msRest.CompositeMapper = { name: "String" } }, + starsCount: { + serializedName: "stars_count", + type: { + name: "Number" + } + }, createdAt: { serializedName: "created_at", type: { @@ -692,6 +698,70 @@ export const LibraryItem: msRest.CompositeMapper = { } }; +export const ProjectProduct: msRest.CompositeMapper = { + serializedName: "ProjectProduct", + type: { + name: "Composite", + className: "ProjectProduct", + modelProperties: { + guid: { + serializedName: "guid", + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + description: { + serializedName: "description", + type: { + name: "String" + } + }, + url: { + serializedName: "url", + type: { + name: "String" + } + }, + projectGuid: { + serializedName: "project_guid", + type: { + name: "String" + } + }, + usdPrice: { + serializedName: "usd_price", + type: { + name: "Number" + } + }, + durationHours: { + serializedName: "duration_hours", + type: { + name: "Number" + } + }, + createdAt: { + serializedName: "created_at", + type: { + name: "String" + } + }, + updatedAt: { + serializedName: "updated_at", + type: { + name: "String" + } + } + } + } +}; + export const GetLoginOKResponseData: msRest.CompositeMapper = { serializedName: "GetLoginOKResponse_data", type: { @@ -1085,6 +1155,40 @@ export const PostImportRepositoryOKResponse: msRest.CompositeMapper = { } }; +export const GetRepoOKResponseData: msRest.CompositeMapper = { + serializedName: "GetRepoOKResponse_data", + type: { + name: "Composite", + className: "GetRepoOKResponseData", + modelProperties: { + repository: { + serializedName: "repository", + type: { + name: "Composite", + className: "Repository" + } + } + } + } +}; + +export const GetRepoOKResponse: msRest.CompositeMapper = { + serializedName: "GetRepoOKResponse", + type: { + name: "Composite", + className: "GetRepoOKResponse", + modelProperties: { + data: { + serializedName: "data", + type: { + name: "Composite", + className: "GetRepoOKResponseData" + } + } + } + } +}; + export const GetProjectOKResponseData: msRest.CompositeMapper = { serializedName: "GetProjectOKResponse_data", type: { @@ -1338,6 +1442,74 @@ export const GetProjectByAliasOKResponse: msRest.CompositeMapper = { } }; +export const CreateCardCreatedResponseData: msRest.CompositeMapper = { + serializedName: "CreateCardCreatedResponse_data", + type: { + name: "Composite", + className: "CreateCardCreatedResponseData", + modelProperties: { + card: { + serializedName: "card", + type: { + name: "Composite", + className: "Card" + } + } + } + } +}; + +export const CreateCardCreatedResponse: msRest.CompositeMapper = { + serializedName: "CreateCardCreatedResponse", + type: { + name: "Composite", + className: "CreateCardCreatedResponse", + modelProperties: { + data: { + serializedName: "data", + type: { + name: "Composite", + className: "CreateCardCreatedResponseData" + } + } + } + } +}; + +export const EditCardOKResponseData: msRest.CompositeMapper = { + serializedName: "EditCardOKResponse_data", + type: { + name: "Composite", + className: "EditCardOKResponseData", + modelProperties: { + card: { + serializedName: "card", + type: { + name: "Composite", + className: "Card" + } + } + } + } +}; + +export const EditCardOKResponse: msRest.CompositeMapper = { + serializedName: "EditCardOKResponse", + type: { + name: "Composite", + className: "EditCardOKResponse", + modelProperties: { + data: { + serializedName: "data", + type: { + name: "Composite", + className: "EditCardOKResponseData" + } + } + } + } +}; + export const GetCardWorkOKResponseData: msRest.CompositeMapper = { serializedName: "GetCardWorkOKResponse_data", type: { @@ -1912,6 +2084,56 @@ export const RemoveProjectFromMyLibraryOKResponse: msRest.CompositeMapper = { } }; +export const GetMyLibraryProjectStatusOKResponseDataStatus: msRest.CompositeMapper = { + serializedName: "GetMyLibraryProjectStatusOKResponse_data_status", + type: { + name: "Composite", + className: "GetMyLibraryProjectStatusOKResponseDataStatus", + modelProperties: { + inLibrary: { + serializedName: "in_library", + type: { + name: "Boolean" + } + } + } + } +}; + +export const GetMyLibraryProjectStatusOKResponseData: msRest.CompositeMapper = { + serializedName: "GetMyLibraryProjectStatusOKResponse_data", + type: { + name: "Composite", + className: "GetMyLibraryProjectStatusOKResponseData", + modelProperties: { + status: { + serializedName: "status", + type: { + name: "Composite", + className: "GetMyLibraryProjectStatusOKResponseDataStatus" + } + } + } + } +}; + +export const GetMyLibraryProjectStatusOKResponse: msRest.CompositeMapper = { + serializedName: "GetMyLibraryProjectStatusOKResponse", + type: { + name: "Composite", + className: "GetMyLibraryProjectStatusOKResponse", + modelProperties: { + data: { + serializedName: "data", + type: { + name: "Composite", + className: "GetMyLibraryProjectStatusOKResponseData" + } + } + } + } +}; + export const GetMeOKResponseData: msRest.CompositeMapper = { serializedName: "GetMeOKResponse_data", type: { @@ -2171,3 +2393,42 @@ export const GetRandomProjectsOKResponse: msRest.CompositeMapper = { } } }; + +export const GetProjectProductsOKResponseData: msRest.CompositeMapper = { + serializedName: "GetProjectProductsOKResponse_data", + type: { + name: "Composite", + className: "GetProjectProductsOKResponseData", + modelProperties: { + products: { + serializedName: "products", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ProjectProduct" + } + } + } + } + } + } +}; + +export const GetProjectProductsOKResponse: msRest.CompositeMapper = { + serializedName: "GetProjectProductsOKResponse", + type: { + name: "Composite", + className: "GetProjectProductsOKResponse", + modelProperties: { + data: { + serializedName: "data", + type: { + name: "Composite", + className: "GetProjectProductsOKResponseData" + } + } + } + } +}; diff --git a/src/client/models/parameters.ts b/src/client/models/parameters.ts index fc0f609..8f820cf 100644 --- a/src/client/models/parameters.ts +++ b/src/client/models/parameters.ts @@ -80,7 +80,7 @@ export const code: msRest.OperationQueryParameter = { } } }; -export const columnGuid: msRest.OperationQueryParameter = { +export const columnGuid0: msRest.OperationQueryParameter = { parameterPath: "columnGuid", mapper: { required: true, @@ -90,6 +90,30 @@ export const columnGuid: msRest.OperationQueryParameter = { } } }; +export const columnGuid1: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "columnGuid" + ], + mapper: { + serializedName: "column_guid", + type: { + name: "String" + } + } +}; +export const columnOrder: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "columnOrder" + ], + mapper: { + serializedName: "column_order", + type: { + name: "Number" + } + } +}; export const currencyType: msRest.OperationQueryParameter = { parameterPath: "currencyType", mapper: { @@ -184,6 +208,28 @@ export const key: msRest.OperationQueryParameter = { } } }; +export const name0: msRest.OperationQueryParameter = { + parameterPath: "name", + mapper: { + required: true, + serializedName: "name", + type: { + name: "String" + } + } +}; +export const name1: msRest.OperationQueryParameter = { + parameterPath: [ + "options", + "name" + ], + mapper: { + serializedName: "name", + type: { + name: "String" + } + } +}; export const originId: msRest.OperationQueryParameter = { parameterPath: "originId", mapper: { @@ -236,6 +282,16 @@ export const proof: msRest.OperationQueryParameter = { } } }; +export const repoGuid: msRest.OperationQueryParameter = { + parameterPath: "repoGuid", + mapper: { + required: true, + serializedName: "repo_guid", + type: { + name: "String" + } + } +}; export const serviceType: msRest.OperationQueryParameter = { parameterPath: "serviceType", mapper: { diff --git a/src/client/supportHubApi.ts b/src/client/supportHubApi.ts index ec5c3c5..1fe5a89 100644 --- a/src/client/supportHubApi.ts +++ b/src/client/supportHubApi.ts @@ -13,10 +13,12 @@ import { SupportHubApiContext } from "./supportHubApiContext"; class SupportHubApi extends SupportHubApiContext { /** * Initializes a new instance of the SupportHubApi class. + * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', + * 'BacklogItem', 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' * @param [options] The parameter options */ - constructor(options?: Models.SupportHubApiOptions) { - super(options); + constructor(entityType: string, options?: Models.SupportHubApiOptions) { + super(entityType, options); } /** @@ -227,6 +229,33 @@ class SupportHubApi extends SupportHubApiContext { callback) as Promise; } + /** + * @param repoGuid Repository Guid + * @param [options] The optional parameters + * @returns Promise + */ + getRepo(repoGuid: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param repoGuid Repository Guid + * @param callback The callback + */ + getRepo(repoGuid: string, callback: msRest.ServiceCallback): void; + /** + * @param repoGuid Repository Guid + * @param options The optional parameters + * @param callback The callback + */ + getRepo(repoGuid: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getRepo(repoGuid: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + repoGuid, + options + }, + getRepoOperationSpec, + callback) as Promise; + } + /** * @param projectGuid Project Guid * @param [options] The optional parameters @@ -424,6 +453,72 @@ class SupportHubApi extends SupportHubApiContext { callback) as Promise; } + /** + * @param apiToken + * @param columnGuid + * @param name + * @param [options] The optional parameters + * @returns Promise + */ + createCard(apiToken: string, columnGuid: string, name: string, options?: Models.SupportHubApiCreateCardOptionalParams): Promise; + /** + * @param apiToken + * @param columnGuid + * @param name + * @param callback The callback + */ + createCard(apiToken: string, columnGuid: string, name: string, callback: msRest.ServiceCallback): void; + /** + * @param apiToken + * @param columnGuid + * @param name + * @param options The optional parameters + * @param callback The callback + */ + createCard(apiToken: string, columnGuid: string, name: string, options: Models.SupportHubApiCreateCardOptionalParams, callback: msRest.ServiceCallback): void; + createCard(apiToken: string, columnGuid: string, name: string, options?: Models.SupportHubApiCreateCardOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + apiToken, + columnGuid, + name, + options + }, + createCardOperationSpec, + callback) as Promise; + } + + /** + * @param apiToken + * @param cardGuid + * @param [options] The optional parameters + * @returns Promise + */ + editCard(apiToken: string, cardGuid: string, options?: Models.SupportHubApiEditCardOptionalParams): Promise; + /** + * @param apiToken + * @param cardGuid + * @param callback The callback + */ + editCard(apiToken: string, cardGuid: string, callback: msRest.ServiceCallback): void; + /** + * @param apiToken + * @param cardGuid + * @param options The optional parameters + * @param callback The callback + */ + editCard(apiToken: string, cardGuid: string, options: Models.SupportHubApiEditCardOptionalParams, callback: msRest.ServiceCallback): void; + editCard(apiToken: string, cardGuid: string, options?: Models.SupportHubApiEditCardOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + apiToken, + cardGuid, + options + }, + editCardOperationSpec, + callback) as Promise; + } + /** * @param cardGuid * @param [options] The optional parameters @@ -453,32 +548,25 @@ class SupportHubApi extends SupportHubApiContext { /** * @param entityGuid - * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', - * 'BacklogItem', 'UserBalance', 'User' * @param [options] The optional parameters * @returns Promise */ - getEntityFundingBalances(entityGuid: string, entityType: Models.EntityType2, options?: msRest.RequestOptionsBase): Promise; + getEntityFundingBalances(entityGuid: string, options?: msRest.RequestOptionsBase): Promise; /** * @param entityGuid - * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', - * 'BacklogItem', 'UserBalance', 'User' * @param callback The callback */ - getEntityFundingBalances(entityGuid: string, entityType: Models.EntityType2, callback: msRest.ServiceCallback): void; + getEntityFundingBalances(entityGuid: string, callback: msRest.ServiceCallback): void; /** * @param entityGuid - * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', - * 'BacklogItem', 'UserBalance', 'User' * @param options The optional parameters * @param callback The callback */ - getEntityFundingBalances(entityGuid: string, entityType: Models.EntityType2, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getEntityFundingBalances(entityGuid: string, entityType: Models.EntityType2, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getEntityFundingBalances(entityGuid: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getEntityFundingBalances(entityGuid: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.sendOperationRequest( { entityGuid, - entityType, options }, getEntityFundingBalancesOperationSpec, @@ -581,44 +669,37 @@ class SupportHubApi extends SupportHubApiContext { /** * @param apiToken JWT token * @param entityGuid - * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', - * 'BacklogItem', 'UserBalance', 'User' * @param amount * @param currencyType Possible values include: 'Usd', 'BitCoin', 'Ethereum', 'Erc20Token', * 'Waves', 'WavesToken', 'LiteCoin' * @param [options] The optional parameters * @returns Promise */ - postInvoice(apiToken: string, entityGuid: string, entityType: Models.EntityType3, amount: number, currencyType: Models.CurrencyType4, options?: msRest.RequestOptionsBase): Promise; + postInvoice(apiToken: string, entityGuid: string, amount: number, currencyType: Models.CurrencyType4, options?: msRest.RequestOptionsBase): Promise; /** * @param apiToken JWT token * @param entityGuid - * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', - * 'BacklogItem', 'UserBalance', 'User' * @param amount * @param currencyType Possible values include: 'Usd', 'BitCoin', 'Ethereum', 'Erc20Token', * 'Waves', 'WavesToken', 'LiteCoin' * @param callback The callback */ - postInvoice(apiToken: string, entityGuid: string, entityType: Models.EntityType3, amount: number, currencyType: Models.CurrencyType4, callback: msRest.ServiceCallback): void; + postInvoice(apiToken: string, entityGuid: string, amount: number, currencyType: Models.CurrencyType4, callback: msRest.ServiceCallback): void; /** * @param apiToken JWT token * @param entityGuid - * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', - * 'BacklogItem', 'UserBalance', 'User' * @param amount * @param currencyType Possible values include: 'Usd', 'BitCoin', 'Ethereum', 'Erc20Token', * 'Waves', 'WavesToken', 'LiteCoin' * @param options The optional parameters * @param callback The callback */ - postInvoice(apiToken: string, entityGuid: string, entityType: Models.EntityType3, amount: number, currencyType: Models.CurrencyType4, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - postInvoice(apiToken: string, entityGuid: string, entityType: Models.EntityType3, amount: number, currencyType: Models.CurrencyType4, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + postInvoice(apiToken: string, entityGuid: string, amount: number, currencyType: Models.CurrencyType4, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + postInvoice(apiToken: string, entityGuid: string, amount: number, currencyType: Models.CurrencyType4, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.sendOperationRequest( { apiToken, entityGuid, - entityType, amount, currencyType, options @@ -929,6 +1010,37 @@ class SupportHubApi extends SupportHubApiContext { callback) as Promise; } + /** + * @param apiToken + * @param projectGuid + * @param [options] The optional parameters + * @returns Promise + */ + getMyLibraryProjectStatus(apiToken: string, projectGuid: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param apiToken + * @param projectGuid + * @param callback The callback + */ + getMyLibraryProjectStatus(apiToken: string, projectGuid: string, callback: msRest.ServiceCallback): void; + /** + * @param apiToken + * @param projectGuid + * @param options The optional parameters + * @param callback The callback + */ + getMyLibraryProjectStatus(apiToken: string, projectGuid: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getMyLibraryProjectStatus(apiToken: string, projectGuid: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + apiToken, + projectGuid, + options + }, + getMyLibraryProjectStatusOperationSpec, + callback) as Promise; + } + /** * @param apiToken JWT token * @param [options] The optional parameters @@ -1036,32 +1148,28 @@ class SupportHubApi extends SupportHubApiContext { /** * @param apiToken JWT token * @param entityGuid - * @param entityType Possible values include: 'Project', 'Board', 'BoardColumn', 'Card' * @param [options] The optional parameters * @returns Promise */ - getMyEntityPermissions(apiToken: string, entityGuid: string, entityType: Models.EntityType4, options?: msRest.RequestOptionsBase): Promise; + getMyEntityPermissions(apiToken: string, entityGuid: string, options?: msRest.RequestOptionsBase): Promise; /** * @param apiToken JWT token * @param entityGuid - * @param entityType Possible values include: 'Project', 'Board', 'BoardColumn', 'Card' * @param callback The callback */ - getMyEntityPermissions(apiToken: string, entityGuid: string, entityType: Models.EntityType4, callback: msRest.ServiceCallback): void; + getMyEntityPermissions(apiToken: string, entityGuid: string, callback: msRest.ServiceCallback): void; /** * @param apiToken JWT token * @param entityGuid - * @param entityType Possible values include: 'Project', 'Board', 'BoardColumn', 'Card' * @param options The optional parameters * @param callback The callback */ - getMyEntityPermissions(apiToken: string, entityGuid: string, entityType: Models.EntityType4, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - getMyEntityPermissions(apiToken: string, entityGuid: string, entityType: Models.EntityType4, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + getMyEntityPermissions(apiToken: string, entityGuid: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getMyEntityPermissions(apiToken: string, entityGuid: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.sendOperationRequest( { apiToken, entityGuid, - entityType, options }, getMyEntityPermissionsOperationSpec, @@ -1113,6 +1221,33 @@ class SupportHubApi extends SupportHubApiContext { getRandomProjectsOperationSpec, callback) as Promise; } + + /** + * @param projectGuid + * @param [options] The optional parameters + * @returns Promise + */ + getProjectProducts(projectGuid: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param projectGuid + * @param callback The callback + */ + getProjectProducts(projectGuid: string, callback: msRest.ServiceCallback): void; + /** + * @param projectGuid + * @param options The optional parameters + * @param callback The callback + */ + getProjectProducts(projectGuid: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getProjectProducts(projectGuid: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + projectGuid, + options + }, + getProjectProductsOperationSpec, + callback) as Promise; + } } // Operation Specifications @@ -1234,6 +1369,21 @@ const postImportRepositoryOperationSpec: msRest.OperationSpec = { serializer }; +const getRepoOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "api/v1/repository/get", + queryParameters: [ + Parameters.repoGuid + ], + responses: { + 200: { + bodyMapper: Mappers.GetRepoOKResponse + }, + default: {} + }, + serializer +}; + const getProjectOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "api/v1/project/get", @@ -1315,7 +1465,7 @@ const getColumnCardsOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "api/v1/board_column/cards/get", queryParameters: [ - Parameters.columnGuid + Parameters.columnGuid0 ], responses: { 200: { @@ -1342,6 +1492,45 @@ const getProjectByAliasOperationSpec: msRest.OperationSpec = { serializer }; +const createCardOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "api/v1/card/create", + queryParameters: [ + Parameters.apiToken, + Parameters.columnGuid0, + Parameters.name0, + Parameters.description, + Parameters.columnOrder + ], + responses: { + 201: { + bodyMapper: Mappers.CreateCardCreatedResponse + }, + default: {} + }, + serializer +}; + +const editCardOperationSpec: msRest.OperationSpec = { + httpMethod: "PATCH", + path: "api/v1/card/edit", + queryParameters: [ + Parameters.apiToken, + Parameters.cardGuid, + Parameters.name1, + Parameters.description, + Parameters.columnOrder, + Parameters.columnGuid1 + ], + responses: { + 200: { + bodyMapper: Mappers.EditCardOKResponse + }, + default: {} + }, + serializer +}; + const getCardWorkOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "api/v1/card/work/get", @@ -1598,6 +1787,22 @@ const removeProjectFromMyLibraryOperationSpec: msRest.OperationSpec = { serializer }; +const getMyLibraryProjectStatusOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "api/v1/me/library/project/status/get", + queryParameters: [ + Parameters.apiToken, + Parameters.projectGuid + ], + responses: { + 200: { + bodyMapper: Mappers.GetMyLibraryProjectStatusOKResponse + }, + default: {} + }, + serializer +}; + const getMeOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "api/v1/me/get", @@ -1696,6 +1901,21 @@ const getRandomProjectsOperationSpec: msRest.OperationSpec = { serializer }; +const getProjectProductsOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "api/v1/project/products/get", + queryParameters: [ + Parameters.projectGuid + ], + responses: { + 200: { + bodyMapper: Mappers.GetProjectProductsOKResponse + }, + default: {} + }, + serializer +}; + export { SupportHubApi, SupportHubApiContext, diff --git a/src/client/supportHubApiContext.ts b/src/client/supportHubApiContext.ts index 6de629e..8f7cb18 100644 --- a/src/client/supportHubApiContext.ts +++ b/src/client/supportHubApiContext.ts @@ -11,12 +11,19 @@ const packageName = ""; const packageVersion = ""; export class SupportHubApiContext extends msRest.ServiceClient { + entityType: string; /** * Initializes a new instance of the SupportHubApiContext class. + * @param entityType Possible values include: 'ProjectCategory', 'Project', 'Board', 'Card', + * 'BacklogItem', 'UserBalance', 'User', 'ProjectProductPurchase', 'BoardColumn' * @param [options] The parameter options */ - constructor(options?: Models.SupportHubApiOptions) { + constructor(entityType: string, options?: Models.SupportHubApiOptions) { + if (entityType == undefined) { + throw new Error("'entityType' cannot be null."); + } + if (!options) { options = {}; } @@ -28,7 +35,8 @@ export class SupportHubApiContext extends msRest.ServiceClient { super(undefined, options); - this.baseUri = options.baseUri || this.baseUri || "http://api.supporthub.com/api/v1"; + this.baseUri = options.baseUri || this.baseUri || "http://api.gitcom.com/api/v1"; this.requestContentType = "application/json; charset=utf-8"; + this.entityType = entityType; } } diff --git a/src/components/check/auth_check/AuthCheck.tsx b/src/components/check/auth_check/AuthCheck.tsx new file mode 100644 index 0000000..602beb2 --- /dev/null +++ b/src/components/check/auth_check/AuthCheck.tsx @@ -0,0 +1,21 @@ +import React from "react"; + +interface IProps { +} + +interface IState { +} + +class AuthCheck extends React.Component { + isAuthorized() { + return window.App.isAuthorized(); + } + + render() { + return
+ {this.isAuthorized() ? this.props.children : null} +
; + } +} + +export default AuthCheck; diff --git a/src/components/check/permission_check/single/PermissionCheck.tsx b/src/components/check/permission_check/single/PermissionCheck.tsx new file mode 100644 index 0000000..15c9e7f --- /dev/null +++ b/src/components/check/permission_check/single/PermissionCheck.tsx @@ -0,0 +1,79 @@ +import React from "react"; +import {EntityType} from "../../../../client/models"; +import {Icon} from "antd"; +import {retryRequest} from "../../../../classes/utils/http/retryRequest"; + +interface IProps { + entityGuid: string, + entityType: EntityType, + requiredPermissions: string[], +} + +interface IState { + isLoading: boolean, + gotPermissions: boolean +} + +class PermissionCheck extends React.Component { + constructor(props: IProps) { + super(props); + this.state = { + isLoading: true, + gotPermissions: false + } + } + + componentDidMount(): void { + setTimeout(() => { + retryRequest(() => { + this.getPermissions(); + }, () => this.state.isLoading, false); + }, Math.floor(Math.random() * 1000)); + } + + getPermissions() { + window.App.apiClient.entityType = this.props.entityType; + window.App.apiClient.getMyEntityPermissions(window.App.apiToken, this.props.entityGuid) + .then((result) => + this.processGotPermissions(result._response)) + .catch(() => this.processApiError()); + } + + processApiError() { + this.setState({ + isLoading: false, + gotPermissions: false + }); + } + + processGotPermissions(response: any) { + let data = JSON.parse(response.bodyAsText).data; + + let gotPermissions = true; + + this.props.requiredPermissions.forEach((permission: string) => { + if (!data.permissions.includes(permission)) { + gotPermissions = false; + } + }); + + this.setState({ + isLoading: false, + gotPermissions: gotPermissions + }); + } + + render() { + if (this.state.isLoading) { + return ; + } + if (!this.state.gotPermissions) { + return
; + } + return
+ {this.props.children} +
; + } +} + +export default PermissionCheck; diff --git a/src/components/entity/budget/entity/EntityBudgetContent.tsx b/src/components/entity/budget/entity/EntityBudgetContent.tsx index 25a240a..1f0431f 100644 --- a/src/components/entity/budget/entity/EntityBudgetContent.tsx +++ b/src/components/entity/budget/entity/EntityBudgetContent.tsx @@ -31,7 +31,8 @@ class EntityBudgetContent extends React.Component { } getData(): void { - window.App.apiClient.getEntityFundingBalances(this.props.entityGuid, this.props.entityType) + window.App.apiClient.entityType = this.props.entityType; + window.App.apiClient.getEntityFundingBalances(this.props.entityGuid) .then((result) => this.processResponse(result._response)) .catch((error) => handleApiError(error.response)); diff --git a/src/components/entity/card/action/create/CreateCard.tsx b/src/components/entity/card/action/create/CreateCard.tsx new file mode 100644 index 0000000..c9c019d --- /dev/null +++ b/src/components/entity/card/action/create/CreateCard.tsx @@ -0,0 +1,107 @@ +import React from "react"; +import {Button, Input, Modal, notification, Row} from "antd"; +import {CardModel, ColumnModel} from "../../../../../client/bindings"; +import {handleApiError} from "../../../../../classes/notification/errorHandler/errorHandler"; + +const { TextArea } = Input; + +interface IProps { + column: ColumnModel +} + +interface IState { + showModal: boolean, + newCard: CardModel, + + requestSent: boolean +} + +class CreateCard extends React.Component { + constructor(props: IProps) { + super(props); + this.state = { + showModal: false, + newCard: new CardModel(), + + requestSent: false + } + } + + openModal() { + this.setState({ + showModal: true + }); + } + + updateCard(field: string, value: any) { + let updatedCard: any = this.state.newCard; + updatedCard[field] = value; + this.setState({ + newCard: updatedCard + }); + } + + createCard() { + window.App.apiClient.createCard(window.App.apiToken, this.props.column.guid!, this.state.newCard.name!, { + description: this.state.newCard.description! + }) + .then((result) => + this.processCardCreated(result._response)) + .catch((error) => handleApiError(error.response)); + } + + processCardCreated(response: any) { + notification['success']({ + message: 'Card was created!', + description: '' + }); + + setTimeout(() => { + window.location.reload(); + }, 1000); + } + + render() { + return
+ Create new card} + visible={this.state.showModal} + width={window.innerWidth < 1000 ? "90%" : "30%"} + onCancel={() => { + this.setState({showModal: false}) + }} + footer={null} + > + + Name: + { + this.updateCard("name", e.target.value); + }} placeholder="Add new amazing feature" /> + + Description: +