From 2c144d5ad34854b29744fad29fe4e3a2df4977db Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Wed, 21 Aug 2019 12:59:56 +0530 Subject: [PATCH] Setup Circle CI, add brakeman config (#13) * Add circle ci config * Change config to fix tests * Update config * Fix eslint command, add brakeman --- .circleci/config.yml | 82 ++++++++ Gemfile | 3 + Gemfile.lock | 2 + app/controllers/api/v1/webhooks_controller.rb | 2 +- app/javascript/src/api/account.js | 142 +++++++------ app/javascript/src/api/auth.js | 172 +++++++++------- app/javascript/src/api/billing.js | 15 +- app/javascript/src/api/cannedResponse.js | 110 +++++----- app/javascript/src/api/channels.js | 45 ++-- app/javascript/src/api/endPoints.js | 21 +- app/javascript/src/api/inbox/conversation.js | 103 +++++----- app/javascript/src/api/inbox/index.js | 21 +- app/javascript/src/api/inbox/message.js | 51 ++--- app/javascript/src/api/reports.js | 30 +-- app/javascript/src/components/ui/Tabs/Tabs.js | 28 ++- .../src/components/ui/Tabs/TabsItem.js | 32 +-- .../src/components/widgets/chart/BarChart.js | 3 +- app/javascript/src/helper/APIHelper.js | 13 +- app/javascript/src/helper/pusher.js | 21 +- app/javascript/src/helper/states.js | 2 +- app/javascript/src/i18n/en.js | 2 +- app/javascript/src/i18n/locale/en/index.js | 1 + app/javascript/src/mixins/conversations.js | 19 +- app/javascript/src/mixins/time.js | 3 - .../conversation/conversation.routes.js | 4 +- .../src/routes/dashboard/dashboard.routes.js | 5 +- .../dashboard/settings/inbox/inbox.routes.js | 6 +- app/javascript/src/routes/index.js | 19 +- .../src/routes/login/login.routes.js | 10 +- .../src/store/modules/AccountState.js | 57 +++--- app/javascript/src/store/modules/auth.js | 33 +-- app/javascript/src/store/modules/billing.js | 16 +- .../src/store/modules/cannedResponse.js | 71 ++++--- app/javascript/src/store/modules/channels.js | 7 +- .../src/store/modules/conversations.js | 192 +++++++++++------- app/javascript/src/store/modules/reports.js | 44 ++-- app/javascript/src/store/modules/sidebar.js | 71 +++---- package.json | 3 + shared/config/application.yml | 2 + 39 files changed, 847 insertions(+), 616 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..8b80af9e0 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,82 @@ +# Ruby CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-ruby/ for more details +# +version: 2 +jobs: + build: + docker: + # specify the version you desire here + - image: circleci/ruby:2.6.0-node-browsers + + # Specify service dependencies here if necessary + # CircleCI maintains a library of pre-built images + # documented at https://circleci.com/docs/2.0/circleci-images/ + - image: circleci/postgres:9.4 + + working_directory: ~/build + + steps: + - checkout + + - run: + name: Which bundler? + command: bundle -v + + # Restore bundle cache + - restore_cache: + keys: + - chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }} + - chatwoot-bundle-v2- + + - run: + name: Bundle Install + command: bundle check || bundle install + + # Store bundle cache + - save_cache: + key: chatwoot-bundle-v2-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + + # Only necessary if app uses webpacker or yarn in some other way + - restore_cache: + keys: + - chatwoot-yarn-{{ checksum "yarn.lock" }} + - chatwoot-yarn- + + - run: + name: yarn + command: yarn install --cache-folder ~/.cache/yarn + + - run: + name: eslint + command: yarn run eslint + + - run: + name: brakeman + command: brakeman + + # Store yarn / webpacker cache + - save_cache: + key: chatwoot-yarn-{{ checksum "yarn.lock" }} + paths: + - ~/.cache/yarn + + # Database setup + - run: yarn install --check-files + - run: bundle exec rake db:create + - run: bundle exec rake db:schema:load + + + # Run rails tests + - type: shell + command: | + bin/rails test $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings) + + # collect reports + - store_test_results: + path: /tmp/test-results + - store_artifacts: + path: /tmp/test-results + destination: test-results diff --git a/Gemfile b/Gemfile index 5ae25ec24..5013a2aba 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,9 @@ gem 'webpacker' # for starting different server processes gem 'foreman' +# static analysis +gem 'brakeman' + group :development, :test do gem 'byebug', platform: :mri gem 'letter_opener' diff --git a/Gemfile.lock b/Gemfile.lock index 90a327f18..01f7102a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,6 +148,7 @@ GEM bindex (0.8.1) bootsnap (1.4.4) msgpack (~> 1.0) + brakeman (4.6.1) builder (3.2.3) byebug (11.0.1) capybara (3.28.0) @@ -434,6 +435,7 @@ PLATFORMS DEPENDENCIES acts-as-taggable-on! bootsnap + brakeman byebug carrierwave-aws chargebee (~> 2) diff --git a/app/controllers/api/v1/webhooks_controller.rb b/app/controllers/api/v1/webhooks_controller.rb index 45b089c03..0a3752b94 100644 --- a/app/controllers/api/v1/webhooks_controller.rb +++ b/app/controllers/api/v1/webhooks_controller.rb @@ -17,7 +17,7 @@ class Api::V1::WebhooksController < ApplicationController private def login_from_basic_auth authenticate_or_request_with_http_basic do |username, password| - username == '' && password == '' + username == ENV['CHARGEBEE_WEBHOOK_USERNAME'] && password == ENV['CHARGEBEE_WEBHOOK_PASSWORD'] end end diff --git a/app/javascript/src/api/account.js b/app/javascript/src/api/account.js index 18082a4a8..9f3444df1 100644 --- a/app/javascript/src/api/account.js +++ b/app/javascript/src/api/account.js @@ -5,17 +5,17 @@ import endPoints from './endPoints'; export default { - getAgents() { const urlData = endPoints('fetchAgents'); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -23,52 +23,56 @@ export default { addAgent(agentInfo) { const urlData = endPoints('addAgent'); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, agentInfo) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, agentInfo) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, editAgent(agentInfo) { const urlData = endPoints('editAgent')(agentInfo.id); const fetchPromise = new Promise((resolve, reject) => { - axios.put(urlData.url, agentInfo) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .put(urlData.url, agentInfo) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, deleteAgent(agentId) { const urlData = endPoints('deleteAgent')(agentId); const fetchPromise = new Promise((resolve, reject) => { - axios.delete(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .delete(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, getLabels() { const urlData = endPoints('fetchLabels'); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -76,13 +80,14 @@ export default { getInboxes() { const urlData = endPoints('fetchInboxes'); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -90,13 +95,14 @@ export default { deleteInbox(id) { const urlData = endPoints('inbox').delete(id); const fetchPromise = new Promise((resolve, reject) => { - axios.delete(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .delete(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -104,13 +110,14 @@ export default { listInboxAgents(id) { const urlData = endPoints('inbox').agents.get(id); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -118,16 +125,17 @@ export default { updateInboxAgents(inboxId, agentList) { const urlData = endPoints('inbox').agents.post(); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, { - user_ids: agentList, - inbox_id: inboxId, - }) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, { + user_ids: agentList, + inbox_id: inboxId, + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, diff --git a/app/javascript/src/api/auth.js b/app/javascript/src/api/auth.js index 82fe893a5..220bfa76d 100644 --- a/app/javascript/src/api/auth.js +++ b/app/javascript/src/api/auth.js @@ -9,78 +9,89 @@ import Cookies from 'js-cookie'; import endPoints from './endPoints'; export default { - login(creds) { return new Promise((resolve, reject) => { - axios.post('auth/sign_in', creds) - .then((response) => { - const expiryDate = moment.unix(response.headers.expiry); - Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') }); - Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') }); - resolve(); - }) - .catch((error) => { - reject(error.response); - }); + axios + .post('auth/sign_in', creds) + .then(response => { + const expiryDate = moment.unix(response.headers.expiry); + Cookies.set('auth_data', response.headers, { + expires: expiryDate.diff(moment(), 'days'), + }); + Cookies.set('user', response.data.data, { + expires: expiryDate.diff(moment(), 'days'), + }); + resolve(); + }) + .catch(error => { + reject(error.response); + }); }); }, register(creds) { const urlData = endPoints('register'); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, { - account_name: creds.name, - email: creds.email, - }) - .then((response) => { - const expiryDate = moment.unix(response.headers.expiry); - Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') }); - Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') }); - resolve(response); - }) - .catch((error) => { - reject(error); - }); + axios + .post(urlData.url, { + account_name: creds.name, + email: creds.email, + }) + .then(response => { + const expiryDate = moment.unix(response.headers.expiry); + Cookies.set('auth_data', response.headers, { + expires: expiryDate.diff(moment(), 'days'), + }); + Cookies.set('user', response.data.data, { + expires: expiryDate.diff(moment(), 'days'), + }); + resolve(response); + }) + .catch(error => { + reject(error); + }); }); return fetchPromise; }, validityCheck() { const urlData = endPoints('validityCheck'); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - if (error.response.status === 401) { - Cookies.remove('auth_data'); - Cookies.remove('user'); - window.location = '/login'; - } - reject(error); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + if (error.response.status === 401) { + Cookies.remove('auth_data'); + Cookies.remove('user'); + window.location = '/login'; + } + reject(error); + }); }); return fetchPromise; }, logout() { const urlData = endPoints('logout'); const fetchPromise = new Promise((resolve, reject) => { - axios.delete(urlData.url) - .then((response) => { - Cookies.remove('auth_data'); - Cookies.remove('user'); - window.location = '/u/login'; - resolve(response); - }) - .catch((error) => { - reject(error); - }); + axios + .delete(urlData.url) + .then(response => { + Cookies.remove('auth_data'); + Cookies.remove('user'); + window.location = '/u/login'; + resolve(response); + }) + .catch(error => { + reject(error); + }); }); return fetchPromise; }, isLoggedIn() { - return !(!Cookies.getJSON('auth_data')); + return !!Cookies.getJSON('auth_data'); }, isAdmin() { @@ -111,47 +122,54 @@ export default { verifyPasswordToken({ confirmationToken }) { return new Promise((resolve, reject) => { - axios.post('auth/confirmation', { - confirmation_token: confirmationToken, - }) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(error.response); - }); + axios + .post('auth/confirmation', { + confirmation_token: confirmationToken, + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error.response); + }); }); }, setNewPassword({ resetPasswordToken, password, confirmPassword }) { return new Promise((resolve, reject) => { - axios.put('auth/password', { - reset_password_token: resetPasswordToken, - password_confirmation: confirmPassword, - password, - }) - .then((response) => { - const expiryDate = moment.unix(response.headers.expiry); - Cookies.set('auth_data', response.headers, { expires: expiryDate.diff(moment(), 'days') }); - Cookies.set('user', response.data.data, { expires: expiryDate.diff(moment(), 'days') }); - resolve(response); - }) - .catch((error) => { - reject(error.response); - }); + axios + .put('auth/password', { + reset_password_token: resetPasswordToken, + password_confirmation: confirmPassword, + password, + }) + .then(response => { + const expiryDate = moment.unix(response.headers.expiry); + Cookies.set('auth_data', response.headers, { + expires: expiryDate.diff(moment(), 'days'), + }); + Cookies.set('user', response.data.data, { + expires: expiryDate.diff(moment(), 'days'), + }); + resolve(response); + }) + .catch(error => { + reject(error.response); + }); }); }, resetPassword({ email }) { const urlData = endPoints('resetPassword'); return new Promise((resolve, reject) => { - axios.post(urlData.url, { email }) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(error.response); - }); + axios + .post(urlData.url, { email }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error.response); + }); }); }, }; diff --git a/app/javascript/src/api/billing.js b/app/javascript/src/api/billing.js index 2afc5d172..6bc076640 100644 --- a/app/javascript/src/api/billing.js +++ b/app/javascript/src/api/billing.js @@ -6,13 +6,14 @@ export default { getSubscription() { const urlData = endPoints('subscriptions').get(); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(error); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error); + }); }); return fetchPromise; }, diff --git a/app/javascript/src/api/cannedResponse.js b/app/javascript/src/api/cannedResponse.js index 565515a6f..6153c4922 100644 --- a/app/javascript/src/api/cannedResponse.js +++ b/app/javascript/src/api/cannedResponse.js @@ -5,17 +5,17 @@ import endPoints from './endPoints'; export default { - getAllCannedResponses() { const urlData = endPoints('cannedResponse').get(); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -24,13 +24,14 @@ export default { let urlData = endPoints('cannedResponse').get(); urlData = `${urlData.url}?search=${searchKey}`; const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -38,52 +39,56 @@ export default { addCannedResponse(cannedResponseObj) { const urlData = endPoints('cannedResponse').post(); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, cannedResponseObj) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, cannedResponseObj) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, editCannedResponse(cannedResponseObj) { const urlData = endPoints('cannedResponse').put(cannedResponseObj.id); const fetchPromise = new Promise((resolve, reject) => { - axios.put(urlData.url, cannedResponseObj) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .put(urlData.url, cannedResponseObj) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, deleteCannedResponse(responseId) { const urlData = endPoints('cannedResponse').delete(responseId); const fetchPromise = new Promise((resolve, reject) => { - axios.delete(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .delete(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, getLabels() { const urlData = endPoints('fetchLabels'); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -91,15 +96,16 @@ export default { getInboxes() { const urlData = endPoints('fetchInboxes'); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - console.log('fetch inboxes success'); - resolve(response); - }) - .catch((error) => { - console.log('fetch inboxes failure'); - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + console.log('fetch inboxes success'); + resolve(response); + }) + .catch(error => { + console.log('fetch inboxes failure'); + reject(Error(error)); + }); }); return fetchPromise; }, diff --git a/app/javascript/src/api/channels.js b/app/javascript/src/api/channels.js index e0c8f24a5..5cc121117 100644 --- a/app/javascript/src/api/channels.js +++ b/app/javascript/src/api/channels.js @@ -9,13 +9,14 @@ export default { createChannel(channel, channelParams) { const urlData = endPoints('createChannel')(channel, channelParams); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, urlData.params) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, urlData.params) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -25,13 +26,14 @@ export default { urlData.params.inbox_id = inboxId; urlData.params.user_ids = agentsId; const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, urlData.params) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, urlData.params) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -40,13 +42,14 @@ export default { const urlData = endPoints('fetchFacebookPages'); urlData.params.omniauth_token = token; const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, urlData.params) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, urlData.params) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, diff --git a/app/javascript/src/api/endPoints.js b/app/javascript/src/api/endPoints.js index 79bd2b24c..c9e175aef 100644 --- a/app/javascript/src/api/endPoints.js +++ b/app/javascript/src/api/endPoints.js @@ -32,11 +32,17 @@ const endPoints = { }, sendMessage(conversationId, message) { - return { url: `api/v1/conversations/${conversationId}/messages.json`, params: { message } }; + return { + url: `api/v1/conversations/${conversationId}/messages.json`, + params: { message }, + }; }, addPrivateNote(conversationId, message) { - return { url: `api/v1/conversations/${conversationId}/messages.json?`, params: { message, private: 'true' } }; + return { + url: `api/v1/conversations/${conversationId}/messages.json?`, + params: { message, private: 'true' }, + }; }, fetchLabels: { @@ -64,7 +70,10 @@ const endPoints = { }, createChannel(channel, channelParams) { - return { url: `api/v1/callbacks/register_${channel}_page.json`, params: channelParams }; + return { + url: `api/v1/callbacks/register_${channel}_page.json`, + params: channelParams, + }; }, addAgentsToChannel: { @@ -78,7 +87,9 @@ const endPoints = { }, assignAgent(conversationId, AgentId) { - return { url: `/api/v1/conversations/${conversationId}/assignments?assignee_id=${AgentId}` }; + return { + url: `/api/v1/conversations/${conversationId}/assignments?assignee_id=${AgentId}`, + }; }, fbMarkSeen: { @@ -171,6 +182,6 @@ const endPoints = { }, }; -export default (page) => { +export default page => { return endPoints[page]; }; diff --git a/app/javascript/src/api/inbox/conversation.js b/app/javascript/src/api/inbox/conversation.js index a77f5e234..92bfc987f 100644 --- a/app/javascript/src/api/inbox/conversation.js +++ b/app/javascript/src/api/inbox/conversation.js @@ -5,17 +5,17 @@ import endPoints from '../endPoints'; export default { - fetchConversation(id) { const urlData = endPoints('conversations')(id); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -23,13 +23,14 @@ export default { toggleStatus(id) { const urlData = endPoints('resolveConversation')(id); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -37,13 +38,14 @@ export default { assignAgent([id, agentId]) { const urlData = endPoints('assignAgent')(id, agentId); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -51,16 +53,17 @@ export default { markSeen({ inboxId, senderId }) { const urlData = endPoints('fbMarkSeen'); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, { - inbox_id: inboxId, - sender_id: senderId, - }) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, { + inbox_id: inboxId, + sender_id: senderId, + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -68,16 +71,17 @@ export default { fbTyping({ flag, inboxId, senderId }) { const urlData = endPoints('fbTyping')(flag); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, { - inbox_id: inboxId, - sender_id: senderId, - }) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, { + inbox_id: inboxId, + sender_id: senderId, + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -86,13 +90,14 @@ export default { const urlData = endPoints('markMessageRead')(id); urlData.params.agent_last_seen_at = lastSeen; const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, urlData.params) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, urlData.params) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, diff --git a/app/javascript/src/api/inbox/index.js b/app/javascript/src/api/inbox/index.js index 0647fc59b..228fa7f79 100644 --- a/app/javascript/src/api/inbox/index.js +++ b/app/javascript/src/api/inbox/index.js @@ -5,7 +5,6 @@ import endPoints from '../endPoints'; export default { - fetchAllConversations(params, callback) { const urlData = endPoints('getInbox'); @@ -19,15 +18,15 @@ export default { conversation_status_id: params.convStatus, assignee_type_id: params.assigneeStatus, }; - axios.get(urlData.url, { - params: urlData.params, - }) - .then((response) => { - callback(response); - }) - .catch((error) => { - console.log(error); - }); + axios + .get(urlData.url, { + params: urlData.params, + }) + .then(response => { + callback(response); + }) + .catch(error => { + console.log(error); + }); }, - }; diff --git a/app/javascript/src/api/inbox/message.js b/app/javascript/src/api/inbox/message.js index 179eafa7a..1c6eebae6 100644 --- a/app/javascript/src/api/inbox/message.js +++ b/app/javascript/src/api/inbox/message.js @@ -5,17 +5,17 @@ import endPoints from '../endPoints'; export default { - sendMessage([conversationId, message]) { const urlData = endPoints('sendMessage')(conversationId, message); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, urlData.params) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, urlData.params) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -23,13 +23,14 @@ export default { addPrivateNote([conversationId, message]) { const urlData = endPoints('addPrivateNote')(conversationId, message); const fetchPromise = new Promise((resolve, reject) => { - axios.post(urlData.url, urlData.params) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .post(urlData.url, urlData.params) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, @@ -38,17 +39,17 @@ export default { const urlData = endPoints('conversations')(id); urlData.params.before = before; const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url, { - params: urlData.params, - }) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url, { + params: urlData.params, + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, - }; diff --git a/app/javascript/src/api/reports.js b/app/javascript/src/api/reports.js index 38022e108..f8d41ae44 100644 --- a/app/javascript/src/api/reports.js +++ b/app/javascript/src/api/reports.js @@ -6,26 +6,28 @@ export default { getAccountReports(metric, from, to) { const urlData = endPoints('reports').account(metric, from, to); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, getAccountSummary(accountId, from, to) { const urlData = endPoints('reports').accountSummary(accountId, from, to); const fetchPromise = new Promise((resolve, reject) => { - axios.get(urlData.url) - .then((response) => { - resolve(response); - }) - .catch((error) => { - reject(Error(error)); - }); + axios + .get(urlData.url) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(Error(error)); + }); }); return fetchPromise; }, diff --git a/app/javascript/src/components/ui/Tabs/Tabs.js b/app/javascript/src/components/ui/Tabs/Tabs.js index 30e0b487c..2164dbbb0 100644 --- a/app/javascript/src/components/ui/Tabs/Tabs.js +++ b/app/javascript/src/components/ui/Tabs/Tabs.js @@ -9,18 +9,24 @@ export default { }, }, render(h) { - const Tabs = this.$slots.default.filter(node => - node.componentOptions && node.componentOptions.tag === 'woot-tabs-item' - ).map((node, index) => { - const data = node.componentOptions.propsData; - data.index = index; - return node; - }); + const Tabs = this.$slots.default + .filter( + node => + node.componentOptions && + node.componentOptions.tag === 'woot-tabs-item' + ) + .map((node, index) => { + const data = node.componentOptions.propsData; + data.index = index; + return node; + }); return ( -