From 4d47fc1c25ac4ded4ff5bccf819a871d43227b6c Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Fri, 10 May 2024 15:16:56 +0530 Subject: [PATCH] chore: rename from team_entites to team_entities --- .../integrations/linear_controller.rb | 4 +- .../i18n/locale/en/integrations.json | 41 +++++++++++++++++++ .../conversation/linear/validations.js | 10 +++++ config/routes.rb | 2 +- lib/integrations/linear/processor_service.rb | 4 +- lib/linear.rb | 4 +- lib/linear_queries.rb | 2 +- .../integrations/linear_controller_spec.rb | 10 ++--- .../linear/processor_service_spec.rb | 10 ++--- spec/lib/linear_spec.rb | 4 +- 10 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 app/javascript/dashboard/routes/dashboard/conversation/linear/validations.js diff --git a/app/controllers/api/v1/accounts/integrations/linear_controller.rb b/app/controllers/api/v1/accounts/integrations/linear_controller.rb index b27749f2e..968f164e0 100644 --- a/app/controllers/api/v1/accounts/integrations/linear_controller.rb +++ b/app/controllers/api/v1/accounts/integrations/linear_controller.rb @@ -8,9 +8,9 @@ class Api::V1::Accounts::Integrations::LinearController < Api::V1::Accounts::Bas end end - def team_entites + def team_entities team_id = params[:team_id] - entites = linear_processor_service.team_entites(team_id) + entites = linear_processor_service.team_entities(team_id) if entites.is_a?(Hash) && entites[:error] render json: { error: entites[:error] }, status: :unprocessable_entity else diff --git a/app/javascript/dashboard/i18n/locale/en/integrations.json b/app/javascript/dashboard/i18n/locale/en/integrations.json index 231892079..008ae37b4 100644 --- a/app/javascript/dashboard/i18n/locale/en/integrations.json +++ b/app/javascript/dashboard/i18n/locale/en/integrations.json @@ -203,6 +203,47 @@ "API_SUCCESS": "Dashboard app deleted successfully", "API_ERROR": "We couldn't delete the app. Please try again later" } + }, + "LINEAR": { + "ADD_OR_LINK": { + "TITLE": "Create/link linear issue", + "DESCRIPTION": "Create or link a linear issue to the conversation", + "FORM": { + "TITLE": { + "LABEL": "Title", + "PLACEHOLDER": "Enter title", + "REQUIRED_ERROR": "Title is required" + }, + "DESCRIPTION": { + "LABEL": "Description", + "PLACEHOLDER": "SLA for premium customers" + }, + "TEAM": { + "LABEL": "Team", + "REQUIRED_ERROR": "Team is required" + }, + "ASSIGNEE": { + "LABEL": "Assignee" + }, + "PRIORITY": { + "LABEL": "Priority" + }, + "LABEL": { + "LABEL": "Label" + }, + "STATUS": { + "LABEL": "Status" + }, + "PROJECT": { + "LABEL": "Project" + } + }, + "CREATE": "Create", + "CANCEL": "Cancel", + "CREATE_ERROR": "There was an error creating the issue, please try again", + "LOADING_TEAM_ERROR": "There was an error fetching the teams, please try again", + "LOADING_TEAM_ENTITIES_ERROR": "There was an error fetching the team entities, please try again" + } } } } diff --git a/app/javascript/dashboard/routes/dashboard/conversation/linear/validations.js b/app/javascript/dashboard/routes/dashboard/conversation/linear/validations.js new file mode 100644 index 000000000..b0edda5f4 --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/conversation/linear/validations.js @@ -0,0 +1,10 @@ +import { required } from 'vuelidate/lib/validators'; + +export default { + title: { + required, + }, + teamId: { + required, + }, +}; diff --git a/config/routes.rb b/config/routes.rb index c21186852..20696fdee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -230,7 +230,7 @@ Rails.application.routes.draw do resource :linear, controller: 'linear', only: [] do collection do get :teams - get :team_entites + get :team_entities post :create_issue post :link_issue post :unlink_issue diff --git a/lib/integrations/linear/processor_service.rb b/lib/integrations/linear/processor_service.rb index b686aa84b..ab5c4f3c9 100644 --- a/lib/integrations/linear/processor_service.rb +++ b/lib/integrations/linear/processor_service.rb @@ -8,8 +8,8 @@ class Integrations::Linear::ProcessorService response['teams']['nodes'].map(&:as_json) end - def team_entites(team_id) - response = linear_client.team_entites(team_id) + def team_entities(team_id) + response = linear_client.team_entities(team_id) return response if response[:error] { diff --git a/lib/linear.rb b/lib/linear.rb index c8971ceb8..9d7dc507c 100644 --- a/lib/linear.rb +++ b/lib/linear.rb @@ -23,10 +23,10 @@ class Linear execute_query(LinearQueries::TEAMS_QUERY) end - def team_entites(team_id) + def team_entities(team_id) raise ArgumentError, 'Missing team id' if team_id.blank? - execute_query(LinearQueries.team_entites_query(team_id)) + execute_query(LinearQueries.team_entities_query(team_id)) end def search_issue(term) diff --git a/lib/linear_queries.rb b/lib/linear_queries.rb index 0dee4a79e..f76f1dedc 100644 --- a/lib/linear_queries.rb +++ b/lib/linear_queries.rb @@ -10,7 +10,7 @@ module LinearQueries } GRAPHQL - def self.team_entites_query(team_id) + def self.team_entities_query(team_id) <<~GRAPHQL query { users { diff --git a/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb b/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb index 706679ed7..fcf57915c 100644 --- a/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/integrations/linear_controller_spec.rb @@ -40,7 +40,7 @@ RSpec.describe 'Linear Integration API', type: :request do end end - describe 'GET /api/v1/accounts/:account_id/integrations/linear/team_entites' do + describe 'GET /api/v1/accounts/:account_id/integrations/linear/team_entities' do let(:team_id) { 'team1' } context 'when it is an authenticated user' do @@ -55,8 +55,8 @@ RSpec.describe 'Linear Integration API', type: :request do end it 'returns team entities data' do - allow(processor_service).to receive(:team_entites).with(team_id).and_return(team_entities_data) - get "/api/v1/accounts/#{account.id}/integrations/linear/team_entites", + allow(processor_service).to receive(:team_entities).with(team_id).and_return(team_entities_data) + get "/api/v1/accounts/#{account.id}/integrations/linear/team_entities", params: { team_id: team_id }, headers: agent.create_new_auth_token, as: :json @@ -70,8 +70,8 @@ RSpec.describe 'Linear Integration API', type: :request do context 'when data retrieval fails' do it 'returns error message' do - allow(processor_service).to receive(:team_entites).with(team_id).and_return(error: 'error message') - get "/api/v1/accounts/#{account.id}/integrations/linear/team_entites", + allow(processor_service).to receive(:team_entities).with(team_id).and_return(error: 'error message') + get "/api/v1/accounts/#{account.id}/integrations/linear/team_entities", params: { team_id: team_id }, headers: agent.create_new_auth_token, as: :json diff --git a/spec/lib/integrations/linear/processor_service_spec.rb b/spec/lib/integrations/linear/processor_service_spec.rb index 9b6a7bb34..34b427af2 100644 --- a/spec/lib/integrations/linear/processor_service_spec.rb +++ b/spec/lib/integrations/linear/processor_service_spec.rb @@ -35,7 +35,7 @@ describe Integrations::Linear::ProcessorService do end end - describe '#team_entites' do + describe '#team_entities' do let(:team_id) { 'team1' } let(:entities_response) do { @@ -48,8 +48,8 @@ describe Integrations::Linear::ProcessorService do context 'when Linear client returns valid data' do it 'returns parsed entity data' do - allow(linear_client).to receive(:team_entites).with(team_id).and_return(entities_response) - result = service.team_entites(team_id) + allow(linear_client).to receive(:team_entities).with(team_id).and_return(entities_response) + result = service.team_entities(team_id) expect(result).to have_key(:users) expect(result).to have_key(:projects) expect(result).to have_key(:states) @@ -61,8 +61,8 @@ describe Integrations::Linear::ProcessorService do let(:error_response) { { error: 'Some error message' } } it 'returns the error' do - allow(linear_client).to receive(:team_entites).with(team_id).and_return(error_response) - result = service.team_entites(team_id) + allow(linear_client).to receive(:team_entities).with(team_id).and_return(error_response) + result = service.team_entities(team_id) expect(result).to eq(error_response) end end diff --git a/spec/lib/linear_spec.rb b/spec/lib/linear_spec.rb index 85b2ffbbf..143e64c7a 100644 --- a/spec/lib/linear_spec.rb +++ b/spec/lib/linear_spec.rb @@ -57,7 +57,7 @@ describe Linear do end it 'returns team entities' do - response = linear_client.team_entites(team_id) + response = linear_client.team_entities(team_id) expect(response).to eq({ 'users' => { 'nodes' => [{ 'id' => 'user1', 'name' => 'User One' }] }, 'projects' => { 'nodes' => [{ 'id' => 'project1', 'name' => 'Project One' }] }, @@ -75,7 +75,7 @@ describe Linear do end it 'raises an exception' do - response = linear_client.team_entites(team_id) + response = linear_client.team_entities(team_id) expect(response).to eq({ :error => 'Error: the server responded with status 422' }) end end