From 8a79d184aa46cbb6533f178fa7ef95f1f9be8d4d Mon Sep 17 00:00:00 2001 From: Bogdan Artemenko Date: Tue, 18 Dec 2018 16:43:23 +0200 Subject: [PATCH] [V3-965] Satellite account. Fixed Vue lint errors (#890) * [V3-965] Satellite account. Fixed Vue lint errors --- web/satellite/package.json | 1 + web/satellite/src/App.vue | 77 ++--- web/satellite/src/api/projectMembers.ts | 34 +- web/satellite/src/api/projects.ts | 113 ++++--- web/satellite/src/api/users.ts | 134 ++++---- .../src/components/common/Button.vue | 21 +- .../src/components/common/Checkbox.vue | 48 +-- .../src/components/common/EmptyStateArea.vue | 41 +-- .../src/components/common/HeaderedInput.vue | 129 ++++---- .../src/components/common/HeaderlessInput.vue | 91 +++--- .../src/components/common/IEditable.ts | 5 +- .../components/dashboard/DashboardHeader.vue | 13 +- .../dashboard/account/AccountArea.vue | 172 +++++------ .../dashboard/account/AccountButton.vue | 27 +- .../dashboard/account/AccountDropdown.vue | 29 +- .../dashboard/account/DeleteAccontPopup.vue | 15 +- .../dashboard/newProject/NewProjectArea.vue | 16 +- .../dashboard/newProject/NewProjectPopup.vue | 62 ++-- .../projectSelection/ProjectSelectionArea.vue | 42 +-- .../ProjectSelectionDropdown.vue | 27 +- .../src/components/errors/Page404.vue | 3 +- .../src/components/errors/Page50X.vue | 3 +- .../components/navigation/NavigationArea.vue | 11 +- .../components/notifications/Notification.vue | 24 +- .../notifications/NotificationArea.vue | 6 +- .../projectDetails/ProjectDetailsArea.vue | 51 +-- .../src/components/team/TeamArea.vue | 25 +- .../src/components/team/TeamMemberItem.vue | 5 +- .../team/addUserPopup/AddUserPopupArea.vue | 46 +-- .../team/footerArea/ApproveDeleteUserArea.vue | 3 +- .../team/footerArea/DeleteUserArea.vue | 27 +- .../src/components/team/footerArea/Footer.vue | 5 +- .../components/team/headerArea/HeaderArea.vue | 3 +- .../components/team/headerArea/SearchArea.vue | 5 +- .../team/headerArea/SortDropdown.vue | 34 +- .../team/headerArea/SortUsersDropdown.vue | 15 +- web/satellite/src/main.ts | 6 +- web/satellite/src/router/index.ts | 8 +- web/satellite/src/store/index.ts | 2 +- .../src/store/modules/notifications.ts | 144 ++++----- .../src/store/modules/projectMembers.ts | 3 + web/satellite/src/store/modules/projects.ts | 224 +++++++------- web/satellite/src/store/modules/users.ts | 241 ++++++++------- web/satellite/src/store/mutationConstants.ts | 36 +-- web/satellite/src/types/fetch.d.ts | 12 +- web/satellite/src/types/projects.d.ts | 26 +- web/satellite/src/types/register.d.ts | 2 +- web/satellite/src/types/tsx.d.ts | 24 +- web/satellite/src/types/users.d.ts | 22 +- web/satellite/src/types/vue.d.ts | 6 +- web/satellite/src/utils/apolloManager.ts | 41 +-- .../src/utils/constants/emptyStatesImages.ts | 8 +- .../src/utils/constants/navigationLinks.ts | 52 ++-- .../src/utils/constants/notification.ts | 16 +- .../src/utils/constants/routerConstants.ts | 26 +- web/satellite/src/utils/dataservice.ts | 146 --------- .../src/utils/entities/DelayedNotification.ts | 46 +-- web/satellite/src/utils/idGenerator.ts | 2 +- .../src/utils/qraphql/createProjectsQuery.ts | 29 +- web/satellite/src/utils/tokenManager.ts | 16 +- web/satellite/src/utils/validation.ts | 8 +- web/satellite/src/views/Dashboard.vue | 14 +- web/satellite/src/views/Login.vue | 156 +++++----- web/satellite/src/views/Register.vue | 290 +++++++++--------- .../tests/unit/common/Button.spec.ts | 30 +- .../tests/unit/common/Checkbox.spec.ts | 38 +-- .../tests/unit/common/HeaderedInput.spec.ts | 66 ++-- .../tests/unit/common/HeaderlessInput.spec.ts | 56 ++-- .../dashboard/account/AccountDropdown.spec.ts | 16 +- .../unit/notifications/Notification.spec.ts | 48 +-- .../notifications/NotificationArea.spec.ts | 44 +-- web/satellite/tsconfig.json | 1 + web/satellite/tslint.json | 16 +- web/satellite/webpack.config.dev.js | 1 + 74 files changed, 1591 insertions(+), 1694 deletions(-) delete mode 100644 web/satellite/src/utils/dataservice.ts diff --git a/web/satellite/package.json b/web/satellite/package.json index 304517b37c36..3946ac25d6c3 100644 --- a/web/satellite/package.json +++ b/web/satellite/package.json @@ -51,6 +51,7 @@ "vue-loader": "^15.4.2", "vue-style-loader": "^4.1.2", "vue-template-compiler": "^2.5.17", + "vue-tslint": "^0.3.2", "vue-tslint-loader": "^3.5.6", "webpack": "^4.21.0", "webpack-cli": "^3.1.2", diff --git a/web/satellite/src/App.vue b/web/satellite/src/App.vue index a7ebc016680a..ce786ac96e0f 100644 --- a/web/satellite/src/App.vue +++ b/web/satellite/src/App.vue @@ -2,11 +2,11 @@ // See LICENSE for copying information. diff --git a/web/satellite/src/api/projectMembers.ts b/web/satellite/src/api/projectMembers.ts index b86c79b6871a..769d18fc8ec4 100644 --- a/web/satellite/src/api/projectMembers.ts +++ b/web/satellite/src/api/projectMembers.ts @@ -2,13 +2,13 @@ // See LICENSE for copying information. import apollo from '@/utils/apolloManager'; -import gql from "graphql-tag"; +import gql from 'graphql-tag'; // Performs graqhQL request. // Throws an exception if error occurs export async function addProjectMember(userID: string, projectID: string): Promise { - let response = null; - try{ + let response: any = null; + try { response = await apollo.mutate( { mutation: gql(` @@ -19,23 +19,23 @@ export async function addProjectMember(userID: string, projectID: string): Promi ) {id} }` ), - fetchPolicy: "no-cache", + fetchPolicy: 'no-cache', } ); - }catch (e) { + } catch (e) { // TODO: replace with popup in future - console.error(e); + console.error(e); } - return response; + return response; } // Performs graqhQL request. // Throws an exception if error occurs export async function deleteProjectMember(userID: string, projectID: string): Promise { - let response = null; - try { - response = await apollo.mutate( + let response: any = null; + try { + response = await apollo.mutate( { mutation: gql(` mutation { @@ -45,7 +45,7 @@ export async function deleteProjectMember(userID: string, projectID: string): Pr ) {id} }` ), - fetchPolicy: "no-cache", + fetchPolicy: 'no-cache', } ); } catch (e) { @@ -53,15 +53,15 @@ export async function deleteProjectMember(userID: string, projectID: string): Pr console.error(e); } - return response; + return response; } // Performs graqhQL request. // Throws an exception if error occurs export async function fetchProjectMembers(projectID: string): Promise { - let response = null; - try { - response = await apollo.query( + let response: any = null; + try { + response = await apollo.query( { query: gql(` query { @@ -83,7 +83,7 @@ export async function fetchProjectMembers(projectID: string): Promise { } }` ), - fetchPolicy: "no-cache", + fetchPolicy: 'no-cache', } ); } catch (e) { @@ -91,5 +91,5 @@ export async function fetchProjectMembers(projectID: string): Promise { console.error(e); } - return response; + return response; } diff --git a/web/satellite/src/api/projects.ts b/web/satellite/src/api/projects.ts index cfa059de437c..a9322a1184aa 100644 --- a/web/satellite/src/api/projects.ts +++ b/web/satellite/src/api/projects.ts @@ -2,16 +2,14 @@ // See LICENSE for copying information. import apollo from '@/utils/apolloManager'; -import gql from "graphql-tag"; +import gql from 'graphql-tag'; // Performs graqhQL request. // Throws an exception if error occurs export async function createProject(project: Project): Promise { - console.log("in api", project); - - let response = await apollo.mutate( - { - mutation: gql(` + let response = await apollo.mutate( + { + mutation: gql(` mutation { createProject( input: { @@ -22,26 +20,26 @@ export async function createProject(project: Project): Promise { } ) {id} }` - ), - fetchPolicy: "no-cache", - } - ); + ), + fetchPolicy: 'no-cache', + } + ); - if(!response){ - // TODO: replace with popup in future - console.log("cannot create project"); + if (!response) { + // TODO: replace with popup in future + console.error('cannot create project'); - return null; - } + return null; + } - return response; + return response; } // Performs graqhQL request for fetching all projects of current user. export async function fetchProjects(): Promise { - let response = await apollo.query( - { - query: gql(` + let response = await apollo.query( + { + query: gql(` query { myProjects{ name @@ -53,67 +51,68 @@ export async function fetchProjects(): Promise { isTermsAccepted } }` - ), - fetchPolicy: "no-cache", - } - ); + ), + fetchPolicy: 'no-cache', + } + ); - if(!response){ - // TODO: replace with popup in future - console.log("cannot fetch projects"); + if (!response) { + // TODO: replace with popup in future + console.error('cannot fetch projects'); - return null; - } + return null; + } - return response; + return response; } // Performs graqhQL request for updating selected project description export async function updateProject(projectID: string, description: string): Promise { - let response = await apollo.mutate( - { - mutation: gql(` + let response = await apollo.mutate( + { + mutation: gql(` mutation { updateProjectDescription( id: "${projectID}", description: "${description}" ) }` - ), - fetchPolicy: "no-cache", - } - ); + ), + fetchPolicy: 'no-cache', + } + ); - if(!response){ - // TODO: replace with popup in future - console.log("cannot update project"); + if (!response) { + // TODO: replace with popup in future + console.error('cannot update project'); - return null; - } + return null; + } - return response; + return response; } // Performs graqhQL request for deleting selected project export async function deleteProject(projectID: string): Promise { - let response = await apollo.mutate( - { - mutation: gql(` + let response = await apollo.mutate( + { + mutation: gql(` mutation { deleteProject( id: "${projectID}" ) }` - ), - fetchPolicy: "no-cache", - } - ); - - if(!response){ - // TODO: replace with popup in future - console.log("cannot delete project"); - return null; - } - - return response; + ), + fetchPolicy: 'no-cache', + } + ); + + if (!response) { + // TODO: replace with popup in future + console.error('cannot delete project'); + + return null; + } + + return response; } diff --git a/web/satellite/src/api/users.ts b/web/satellite/src/api/users.ts index 70901f46034b..6c67ab43d602 100644 --- a/web/satellite/src/api/users.ts +++ b/web/satellite/src/api/users.ts @@ -1,15 +1,15 @@ // Copyright (C) 2018 Storj Labs, Inc. // See LICENSE for copying information. -import apolloManager from "../utils/apolloManager"; -import gql from "graphql-tag"; +import apolloManager from '../utils/apolloManager'; +import gql from 'graphql-tag'; // Performs update user info graphQL mutation request. // Returns User object if succeed, null otherwise -export async function updateBasicUserInfo(user: User) { - let response = await apolloManager.mutate( - { - mutation: gql(` +export async function updateBasicUserInfoRequest(user: User) { + let response = await apolloManager.mutate( + { + mutation: gql(` mutation { updateUser ( id: "${user.id}", @@ -25,23 +25,23 @@ export async function updateBasicUserInfo(user: User) { } } `), - fetchPolicy: "no-cache", - } - ); + fetchPolicy: 'no-cache', + } + ); - if (!response) { - return null; - } + if (!response) { + return null; + } - return response; + return response; } // Performs update company info graphQL mutation request. // Returns Company object if succeed, null otherwise -export async function updateCompanyInfo(userId: string, company: Company) { - let response = await apolloManager.mutate( - { - mutation:gql(` +export async function updateCompanyInfoRequest(userId: string, company: Company) { + let response = await apolloManager.mutate( + { + mutation: gql(` mutation { updateCompany( userID:"${userId}", @@ -63,22 +63,22 @@ export async function updateCompanyInfo(userId: string, company: Company) { } } `) - } - ); + } + ); - if (!response) { - return null; - } + if (!response) { + return null; + } - return response; + return response; } // Performs change password graphQL mutation // Returns base user fields -export async function updatePassword(userId: string, password: string) { - let response = await apolloManager.mutate( - { - mutation: gql(` +export async function updatePasswordRequest(userId: string, password: string) { + let response = await apolloManager.mutate( + { + mutation: gql(` mutation { updateUser ( id: "${userId}", @@ -92,24 +92,24 @@ export async function updatePassword(userId: string, password: string) { } } `), - fetchPolicy: "no-cache", - } - ); + fetchPolicy: 'no-cache', + } + ); - if (!response) { - return null; - } + if (!response) { + return null; + } - return response; + return response; } // Performs Create user graqhQL request. // Throws an exception if error occurs // Returns object with newly created user -export async function createUser(user: User, password: string): Promise { - let response = await apolloManager.mutate( - { - mutation: gql(` +export async function createUserRequest(user: User, password: string): Promise { + let response = await apolloManager.mutate( + { + mutation: gql(` mutation { createUser( input:{ @@ -129,25 +129,25 @@ export async function createUser(user: User, password: string): Promise { ) } `), - fetchPolicy: "no-cache", - } - ); + fetchPolicy: 'no-cache', + } + ); - if (!response) { - return null; - } + if (!response) { + return null; + } - return response; + return response; } // Performs graqhQL request. // Returns Token, User objects. // Throws an exception if error occurs -export async function login(email: string, password: string): Promise { - let response = await apolloManager.query( - { - query: gql(` +export async function getTokenRequest(email: string, password: string): Promise { + let response = await apolloManager.query( + { + query: gql(` query { token(email: "${email}", password: "${password}") { @@ -168,37 +168,37 @@ export async function login(email: string, password: string): Promise { } } }`), - fetchPolicy: "no-cache", - } - ); + fetchPolicy: 'no-cache', + } + ); - if (!response) { - return null; - } + if (!response) { + return null; + } - return response; + return response; } // Performs graqhQL request. // User object. // Throws an exception if error occurs -export async function deleteUserAccount(userId: string): Promise { - let response = await apolloManager.mutate( - { - mutation: gql(` +export async function deleteUserAccountRequest(userId: string): Promise { + let response = await apolloManager.mutate( + { + mutation: gql(` mutation { deleteUser(id: "${userId}") { id } } `), - fetchPolicy: "no-cache" - } - ); + fetchPolicy: 'no-cache' + } + ); - if(!response) { - return null; - } + if (!response) { + return null; + } - return response; + return response; } diff --git a/web/satellite/src/components/common/Button.vue b/web/satellite/src/components/common/Button.vue index 29b1b38553e0..d4337c7ad464 100644 --- a/web/satellite/src/components/common/Button.vue +++ b/web/satellite/src/components/common/Button.vue @@ -3,10 +3,10 @@ @@ -16,8 +16,8 @@ import { Component, Vue } from 'vue-property-decorator'; // Custom button component with label @Component( - { - props: { + { + props: { label: { type: String, default: 'Default' @@ -40,12 +40,14 @@ import { Component, Vue } from 'vue-property-decorator'; }, onPress: { type: Function, - default: () => {} + default: () => { + console.error('onPress is not reinitialized'); + } } }, computed: { style: function () { - return { width: this.$props.width, height: this.$props.height } + return {width: this.$props.width, height: this.$props.height}; }, containerClassName: function () { if (this.$props.isDisabled) { @@ -58,7 +60,8 @@ import { Component, Vue } from 'vue-property-decorator'; } ) -export default class Button extends Vue {} +export default class Button extends Vue { +}