From 4d8a62179e02a5d57dd59c1f39ce523a862e3536 Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 17:50:54 +0800 Subject: [PATCH 01/22] Add Shimo sidebar logo --- app/assets/images/logos/shimo.svg | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 app/assets/images/logos/shimo.svg diff --git a/app/assets/images/logos/shimo.svg b/app/assets/images/logos/shimo.svg new file mode 100644 index 00000000000000..d6f2cad839eee5 --- /dev/null +++ b/app/assets/images/logos/shimo.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + -- GitLab From e7670e5990a3812497e8a237b06548de37b6af9b Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 17:54:13 +0800 Subject: [PATCH 02/22] Add Shimo model --- app/models/integration.rb | 2 +- app/models/integrations/shimo.rb | 56 +++++++++++++++++++ app/models/project.rb | 5 +- .../development/shimo_integration.yml | 8 +++ lib/gitlab/integrations/sti_type.rb | 2 +- spec/factories/integrations.rb | 6 ++ spec/models/integrations/shimo_spec.rb | 40 +++++++++++++ 7 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 app/models/integrations/shimo.rb create mode 100644 config/feature_flags/development/shimo_integration.yml create mode 100644 spec/models/integrations/shimo_spec.rb diff --git a/app/models/integration.rb b/app/models/integration.rb index 4dd3e1a1785831..0a1f61fd540078 100644 --- a/app/models/integration.rb +++ b/app/models/integration.rb @@ -14,7 +14,7 @@ class Integration < ApplicationRecord asana assembla bamboo bugzilla buildkite campfire confluence custom_issue_tracker datadog discord drone_ci emails_on_push ewm external_wiki flowdock hangouts_chat irker jira mattermost mattermost_slash_commands microsoft_teams packagist pipelines_email - pivotaltracker prometheus pushover redmine slack slack_slash_commands teamcity unify_circuit webex_teams youtrack zentao + pivotaltracker prometheus pushover redmine shimo slack slack_slash_commands teamcity unify_circuit webex_teams youtrack zentao ].freeze PROJECT_SPECIFIC_INTEGRATION_NAMES = %w[ diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb new file mode 100644 index 00000000000000..907293a8f841d7 --- /dev/null +++ b/app/models/integrations/shimo.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Integrations + class Shimo < Integration + prop_accessor :workspace_url + validates :workspace_url, presence: true, public_url: true, if: :activated? + + def feature_flag_enabled? + Feature.enabled?(:shimo_integration, project) + end + + def render? + return false unless feature_flag_enabled? + + workspace_url.present? && activated? + end + + def title + s_('Shimo|Shimo') + end + + def description + s_('Shimo|Link to a Shimo Workspace from the sidebar.') + end + + def self.to_param + name.demodulize.downcase + end + + def execute(_data) + response = Gitlab::HTTP.get(properties['workspace_url'], verify: true, use_read_total_timeout: true) + response.body if response.code == 200 + rescue StandardError + nil + end + + def self.supported_events + %w() + end + + def self.supported_event_actions + %w() + end + + def fields + [ + { + type: 'text', + name: 'workspace_url', + title: s_('Shimo|Shimo workspace URL'), + required: true + } + ] + end + end +end diff --git a/app/models/project.rb b/app/models/project.rb index f2c26f918069ee..34e6f8bca125c7 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -189,6 +189,7 @@ def self.integration_association_name(name) has_one :prometheus_integration, class_name: 'Integrations::Prometheus', inverse_of: :project has_one :pushover_integration, class_name: 'Integrations::Pushover' has_one :redmine_integration, class_name: 'Integrations::Redmine' + has_one :shimo_integration, class_name: 'Integrations::Shimo' has_one :slack_integration, class_name: 'Integrations::Slack' has_one :slack_slash_commands_integration, class_name: 'Integrations::SlackSlashCommands' has_one :teamcity_integration, class_name: 'Integrations::Teamcity' @@ -1453,7 +1454,9 @@ def find_or_initialize_integrations end def disabled_integrations - [] + disabled_integrations = [] + disabled_integrations << :shimo unless shimo_integration&.feature_flag_enabled? + disabled_integrations end def find_or_initialize_integration(name) diff --git a/config/feature_flags/development/shimo_integration.yml b/config/feature_flags/development/shimo_integration.yml new file mode 100644 index 00000000000000..3ac45ddb9e8155 --- /dev/null +++ b/config/feature_flags/development/shimo_integration.yml @@ -0,0 +1,8 @@ +--- +name: shimo_integration +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73129 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343386 +milestone: '14.5' +type: development +group: group::integrations +default_enabled: false diff --git a/lib/gitlab/integrations/sti_type.rb b/lib/gitlab/integrations/sti_type.rb index 91797a7b99bcaf..1350d75b2169a0 100644 --- a/lib/gitlab/integrations/sti_type.rb +++ b/lib/gitlab/integrations/sti_type.rb @@ -7,7 +7,7 @@ class StiType < ActiveRecord::Type::String Asana Assembla Bamboo Bugzilla Buildkite Campfire Confluence CustomIssueTracker Datadog Discord DroneCi EmailsOnPush Ewm ExternalWiki Flowdock HangoutsChat Irker Jenkins Jira Mattermost MattermostSlashCommands MicrosoftTeams MockCi MockMonitoring Packagist PipelinesEmail Pivotaltracker - Prometheus Pushover Redmine Slack SlackSlashCommands Teamcity UnifyCircuit WebexTeams Youtrack Zentao + Prometheus Pushover Redmine Shimo Slack SlackSlashCommands Teamcity UnifyCircuit WebexTeams Youtrack Zentao )).freeze def self.namespaced_integrations diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index 63f85c04ac7a6b..2ddcfa1649f8e0 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -111,6 +111,12 @@ end end + factory :shimo_integration, class: 'Integrations::Shimo' do + project + active { true } + workspace_url { 'https://shimo.im/desktop' } + end + factory :confluence_integration, class: 'Integrations::Confluence' do project active { true } diff --git a/spec/models/integrations/shimo_spec.rb b/spec/models/integrations/shimo_spec.rb new file mode 100644 index 00000000000000..56ef12ab7d4b9d --- /dev/null +++ b/spec/models/integrations/shimo_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Integrations::Shimo do + describe '#fields' do + let(:shimo_integration) { create(:shimo_integration) } + + it 'returns custom fields' do + expect(shimo_integration.fields.pluck(:name)).to eq(%w[workspace_url]) + end + end + + describe '#create' do + let(:project) { create(:project, :repository) } + let(:workspace_url) { 'https://shimo.im/' } + let(:params) { { active: true, project: project, workspace_url: workspace_url } } + + context 'with valid params' do + it 'creates the Shimo integration' do + shimo = described_class.create!(params) + + expect(shimo.valid?).to be true + expect(shimo.render?).to be true + expect(shimo.workspace_url).to eq(workspace_url) + end + end + + context 'with invalid params' do + before do + params['workspace_url'] = nil + end + it 'cannot create the Shimo integration' do + shimo = described_class.create!(params) + + expect(shimo.valid?).to be false + end + end + end +end -- GitLab From 6da9b91a6453e1cf40cba02d6806e071ff13764f Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 17:54:53 +0800 Subject: [PATCH 03/22] Add shimo menu --- lib/sidebars/projects/menus/shimo_menu.rb | 41 +++++++++++++++++++ lib/sidebars/projects/panel.rb | 1 + .../projects/menus/shimo_menu_spec.rb | 33 +++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 lib/sidebars/projects/menus/shimo_menu.rb create mode 100644 spec/lib/sidebars/projects/menus/shimo_menu_spec.rb diff --git a/lib/sidebars/projects/menus/shimo_menu.rb b/lib/sidebars/projects/menus/shimo_menu.rb new file mode 100644 index 00000000000000..571889c242e462 --- /dev/null +++ b/lib/sidebars/projects/menus/shimo_menu.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + class ShimoMenu < ::Sidebars::Menu + override :link + def link + project_integrations_shimo_home_path(context.project) + end + + override :title + def title + s_('Shimo|Shimo') + end + + override :image_path + def image_path + 'logos/shimo.svg' + end + + override :image_html_options + def image_html_options + { + size: 16 + } + end + + override :render? + def render? + context.project.shimo_integration&.render? + end + + override :active_routes + def active_routes + { controller: :shimo } + end + end + end + end +end diff --git a/lib/sidebars/projects/panel.rb b/lib/sidebars/projects/panel.rb index 374662162b5c85..484d349250ecd2 100644 --- a/lib/sidebars/projects/panel.rb +++ b/lib/sidebars/projects/panel.rb @@ -34,6 +34,7 @@ def add_menus add_menu(Sidebars::Projects::Menus::AnalyticsMenu.new(context)) add_menu(confluence_or_wiki_menu) add_menu(Sidebars::Projects::Menus::ExternalWikiMenu.new(context)) + add_menu(Sidebars::Projects::Menus::ShimoMenu.new(context)) if context.project.shimo_integration&.feature_flag_enabled? add_menu(Sidebars::Projects::Menus::SnippetsMenu.new(context)) add_menu(Sidebars::Projects::Menus::SettingsMenu.new(context)) end diff --git a/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb new file mode 100644 index 00000000000000..46f5a3925809ea --- /dev/null +++ b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::Projects::Menus::ShimoMenu do + let(:project) { create(:project) } + let(:context) { Sidebars::Projects::Context.new(current_user: project.owner, container: project) } + let(:shimo_integration) { create(:shimo_integration, project: project) } + + subject(:shimo_menu) { described_class.new(context) } + + describe '#render?' do + context 'when integration is activated' do + it 'renders the menu' do + expect(shimo_menu.render?).to eq true + end + + it 'renders menu link' do + expect(shimo_menu.link).to eq project_integrations_shimo_home_path(project) + end + end + + context 'when integration is inactivated' do + before do + shimo_integration.active = false + end + + it 'returns false' do + expect(shimo_menu.render?).to eq false + end + end + end +end -- GitLab From 2509133fde3f799b16e3b1b1d49d9da1793ffcfc Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 17:56:31 +0800 Subject: [PATCH 04/22] Add Shimo Controller Add Integration of Shimo. Changelog: added --- .../concerns/integrations/params.rb | 1 + .../projects/integrations/shimo_controller.rb | 18 +++++++++++ .../integrations/shimo/home.html.haml | 11 +++++++ config/routes/project.rb | 4 +++ .../integrations/shimo_controller_spec.rb | 32 +++++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 app/controllers/projects/integrations/shimo_controller.rb create mode 100644 app/views/projects/integrations/shimo/home.html.haml create mode 100644 spec/controllers/projects/integrations/shimo_controller_spec.rb diff --git a/app/controllers/concerns/integrations/params.rb b/app/controllers/concerns/integrations/params.rb index 201fb1dc83f2c9..82058acfcf2f27 100644 --- a/app/controllers/concerns/integrations/params.rb +++ b/app/controllers/concerns/integrations/params.rb @@ -76,6 +76,7 @@ module Params :user_key, :username, :webhook, + :workspace_url, :zentao_product_xid ].freeze diff --git a/app/controllers/projects/integrations/shimo_controller.rb b/app/controllers/projects/integrations/shimo_controller.rb new file mode 100644 index 00000000000000..2a7979b70e8aa8 --- /dev/null +++ b/app/controllers/projects/integrations/shimo_controller.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Projects + module Integrations + class ShimoController < Projects::ApplicationController + before_action :check_enable + + # GET /*namespace_id/:project_id/-/integrations/shimo/home + def home; end + + private + + def check_enable + render_404 unless project.shimo_integration&.render? + end + end + end +end diff --git a/app/views/projects/integrations/shimo/home.html.haml b/app/views/projects/integrations/shimo/home.html.haml new file mode 100644 index 00000000000000..bb9c709711dc83 --- /dev/null +++ b/app/views/projects/integrations/shimo/home.html.haml @@ -0,0 +1,11 @@ +- breadcrumb_title s_('Shimo|Shimo Workspace') +- page_title s_('Shimo|Shimo Workspace') +- add_page_specific_style 'page_bundles/wiki' += render layout: 'shared/empty_states/wikis_layout', locals: { image_path: 'illustrations/wiki_login_empty.svg' } do + %h4 + = s_('Shimo|Shimo Workspace is enabled') + %p + = format s_("Shimo|You've enabled the Shimo Workspace integration. Your wiki will be viewable directly within Shimo. We are hard at work integrating Shimo more seamlessly into GitLab.").html_safe + = link_to @project.shimo_integration.workspace_url, target: '_blank', rel: 'noopener noreferrer', class: 'gl-button btn btn-success external-url', title: s_('Shimo|Go to Shimo') do + = sprite_icon('external-link') + = s_('Shimo|Go to Shimo') diff --git a/config/routes/project.rb b/config/routes/project.rb index 446ecc4159b291..9b15ea92e52b10 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -451,6 +451,10 @@ end end end + + namespace :integrations do + get 'shimo/home', to: 'shimo#home' + end end # End of the /-/ scope. diff --git a/spec/controllers/projects/integrations/shimo_controller_spec.rb b/spec/controllers/projects/integrations/shimo_controller_spec.rb new file mode 100644 index 00000000000000..757029936ea006 --- /dev/null +++ b/spec/controllers/projects/integrations/shimo_controller_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Projects::Integrations::ShimoController do + let_it_be(:project) { create(:project) } + let_it_be(:shimo_integration) { create(:shimo_integration, project: project) } + + describe 'GET #home' do + context 'when Shimo integration is inactivated' do + before do + shimo_integration.active = false + end + + it 'returns 404 status' do + get :home, params: { namespace_id: project.namespace, project_id: project } + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when Shimo integration is activated' do + it 'renders the "home" template' do + get :home, params: { namespace_id: project.namespace, project_id: project } + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template(:home) + expect(response.body).to include shimo_integration.workspace_url + end + end + end +end -- GitLab From 51d8716982c8f0e5bac035b3cf0ad06618462b8b Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 18:05:30 +0800 Subject: [PATCH 05/22] Update gitlab.pot --- locale/gitlab.pot | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 658c60aac03579..68f2e7c6472c5c 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -31599,6 +31599,27 @@ msgstr "" msgid "Sherlock Transactions" msgstr "" +msgid "Shimo|Go to Shimo" +msgstr "" + +msgid "Shimo|Link to a Shimo Workspace from the sidebar." +msgstr "" + +msgid "Shimo|Shimo" +msgstr "" + +msgid "Shimo|Shimo Workspace" +msgstr "" + +msgid "Shimo|Shimo Workspace is enabled" +msgstr "" + +msgid "Shimo|Shimo workspace URL" +msgstr "" + +msgid "Shimo|You've enabled the Shimo Workspace integration. Your wiki will be viewable directly within Shimo. We are hard at work integrating Shimo more seamlessly into GitLab." +msgstr "" + msgid "Should you ever lose your phone or access to your one time password secret, each of these recovery codes can be used one time each to regain access to your account. Please save them in a safe place, or you %{boldStart}will%{boldEnd} lose access to your account." msgstr "" -- GitLab From 5c7b121e0fbdfeeeb39600e1b79c95aae61eff98 Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 20:51:45 +0800 Subject: [PATCH 06/22] Update all_models.yml --- spec/lib/gitlab/import_export/all_models.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 95217b43d1397e..b474f5825fdf85 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -384,6 +384,7 @@ project: - emails_on_push_integration - pipelines_email_integration - mattermost_slash_commands_integration +- shimo_integration - slack_slash_commands_integration - irker_integration - packagist_integration -- GitLab From f5949f68cb629c15640d6c9902a12ad28f8b6dd1 Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 20:57:04 +0800 Subject: [PATCH 07/22] Refactor for too high method --- lib/sidebars/projects/panel.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sidebars/projects/panel.rb b/lib/sidebars/projects/panel.rb index 484d349250ecd2..41a0baf8fb3d20 100644 --- a/lib/sidebars/projects/panel.rb +++ b/lib/sidebars/projects/panel.rb @@ -32,11 +32,15 @@ def add_menus add_menu(Sidebars::Projects::Menus::InfrastructureMenu.new(context)) add_menu(Sidebars::Projects::Menus::PackagesRegistriesMenu.new(context)) add_menu(Sidebars::Projects::Menus::AnalyticsMenu.new(context)) + add_wiki_menus + add_menu(Sidebars::Projects::Menus::SnippetsMenu.new(context)) + add_menu(Sidebars::Projects::Menus::SettingsMenu.new(context)) + end + + def add_wiki_menus add_menu(confluence_or_wiki_menu) add_menu(Sidebars::Projects::Menus::ExternalWikiMenu.new(context)) add_menu(Sidebars::Projects::Menus::ShimoMenu.new(context)) if context.project.shimo_integration&.feature_flag_enabled? - add_menu(Sidebars::Projects::Menus::SnippetsMenu.new(context)) - add_menu(Sidebars::Projects::Menus::SettingsMenu.new(context)) end def confluence_or_wiki_menu -- GitLab From edc8b893ad7eae3c0fa36562cfec3d2341ce493d Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 21:33:40 +0800 Subject: [PATCH 08/22] Add Shimo metrics config --- .../20211028210001_projects_shimo_active.yml | 22 +++++++++++++++++++ .../20211028210002_groups_shimo_active.yml | 22 +++++++++++++++++++ .../20211028210003_instances_shimo_active.yml | 22 +++++++++++++++++++ ...10004_projects_inheriting_shimo_active.yml | 22 +++++++++++++++++++ ...8210005_groups_inheriting_shimo_active.yml | 22 +++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 config/metrics/counts_all/20211028210001_projects_shimo_active.yml create mode 100644 config/metrics/counts_all/20211028210002_groups_shimo_active.yml create mode 100644 config/metrics/counts_all/20211028210003_instances_shimo_active.yml create mode 100644 config/metrics/counts_all/20211028210004_projects_inheriting_shimo_active.yml create mode 100644 config/metrics/counts_all/20211028210005_groups_inheriting_shimo_active.yml diff --git a/config/metrics/counts_all/20211028210001_projects_shimo_active.yml b/config/metrics/counts_all/20211028210001_projects_shimo_active.yml new file mode 100644 index 00000000000000..5be51ba4cb2dd4 --- /dev/null +++ b/config/metrics/counts_all/20211028210001_projects_shimo_active.yml @@ -0,0 +1,22 @@ +--- +key_path: counts.projects_shimo_active +name: count_all_projects_shimo_active +description: Count of projects with active Shimo integrations +product_section: dev +product_stage: ecosystem +product_group: group::integrations +product_category: integrations +value_type: number +status: active +milestone: "14.5" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343386 +time_frame: all +data_source: database +data_category: Operational +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate diff --git a/config/metrics/counts_all/20211028210002_groups_shimo_active.yml b/config/metrics/counts_all/20211028210002_groups_shimo_active.yml new file mode 100644 index 00000000000000..f57deeae590d7f --- /dev/null +++ b/config/metrics/counts_all/20211028210002_groups_shimo_active.yml @@ -0,0 +1,22 @@ +--- +key_path: counts.groups_shimo_active +name: count_all_groups_shimo_active +description: Count of groups with active Shimo integrations +product_section: dev +product_stage: ecosystem +product_group: group::integrations +product_category: integrations +value_type: number +status: active +milestone: "14.5" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343386 +time_frame: all +data_source: database +data_category: Operational +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate diff --git a/config/metrics/counts_all/20211028210003_instances_shimo_active.yml b/config/metrics/counts_all/20211028210003_instances_shimo_active.yml new file mode 100644 index 00000000000000..7d1c6ea3706b75 --- /dev/null +++ b/config/metrics/counts_all/20211028210003_instances_shimo_active.yml @@ -0,0 +1,22 @@ +--- +key_path: counts.instances_shimo_active +name: count_all_instances_shimo_active +description: Count of instances with active Shimo integrations +product_section: dev +product_stage: ecosystem +product_group: group::integrations +product_category: integrations +value_type: number +status: active +milestone: "14.5" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343386 +time_frame: all +data_source: database +data_category: Operational +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate diff --git a/config/metrics/counts_all/20211028210004_projects_inheriting_shimo_active.yml b/config/metrics/counts_all/20211028210004_projects_inheriting_shimo_active.yml new file mode 100644 index 00000000000000..42f01ccff3a98d --- /dev/null +++ b/config/metrics/counts_all/20211028210004_projects_inheriting_shimo_active.yml @@ -0,0 +1,22 @@ +--- +key_path: counts.projects_inheriting_shimo_active +name: count_all_projects_inheriting_shimo_active +description: Count of projects that inherit active Shimo integrations +product_section: dev +product_stage: ecosystem +product_group: group::integrations +product_category: integrations +value_type: number +status: active +milestone: "14.5" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343386 +time_frame: all +data_source: database +data_category: Operational +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate diff --git a/config/metrics/counts_all/20211028210005_groups_inheriting_shimo_active.yml b/config/metrics/counts_all/20211028210005_groups_inheriting_shimo_active.yml new file mode 100644 index 00000000000000..6292ad0aaae431 --- /dev/null +++ b/config/metrics/counts_all/20211028210005_groups_inheriting_shimo_active.yml @@ -0,0 +1,22 @@ +--- +key_path: counts.groups_inheriting_shimo_active +name: count_all_groups_inheriting_shimo_active +description: Count of groups that inherit active Shimo integrations +product_section: dev +product_stage: ecosystem +product_group: group::integrations +product_category: integrations +value_type: number +status: active +milestone: "14.5" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343386 +time_frame: all +data_source: database +data_category: Operational +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate -- GitLab From 348211837ae15cda17e3d59823fedcaf346eebcf Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 21:11:48 +0800 Subject: [PATCH 09/22] Update GraphQL reference doc By rake: gitlab:graphql:compile_docs --- doc/api/graphql/reference/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index ea40b5b1d50e56..20486ccd9daea9 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -16680,6 +16680,7 @@ State of a Sentry error. | `PROMETHEUS_SERVICE` | PrometheusService type. | | `PUSHOVER_SERVICE` | PushoverService type. | | `REDMINE_SERVICE` | RedmineService type. | +| `SHIMO_SERVICE` | ShimoService type. | | `SLACK_SERVICE` | SlackService type. | | `SLACK_SLASH_COMMANDS_SERVICE` | SlackSlashCommandsService type. | | `TEAMCITY_SERVICE` | TeamcityService type. | -- GitLab From 9e9e8ac525b6766f0a167fb2a001f55cccff3522 Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 21:42:13 +0800 Subject: [PATCH 10/22] Update Shimo integration helpers --- lib/api/helpers/integrations_helpers.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/api/helpers/integrations_helpers.rb b/lib/api/helpers/integrations_helpers.rb index 7ae46abd0971c5..4e65aae6a3b86b 100644 --- a/lib/api/helpers/integrations_helpers.rb +++ b/lib/api/helpers/integrations_helpers.rb @@ -530,6 +530,14 @@ def self.integrations desc: 'The Mattermost token' } ], + 'shimo' => [ + { + required: true, + name: :workspace_url, + type: String, + desc: 'Shimo workspace URLn' + } + ], 'slack-slash-commands' => [ { required: true, -- GitLab From 4f00f6c5cab4bf3b3858605bc27e20d24f2b3375 Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 21:58:54 +0800 Subject: [PATCH 11/22] Refactor ShimoMenu rspec --- .../projects/menus/shimo_menu_spec.rb | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb index 46f5a3925809ea..d080fc0780ab9a 100644 --- a/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb @@ -5,28 +5,40 @@ RSpec.describe Sidebars::Projects::Menus::ShimoMenu do let(:project) { create(:project) } let(:context) { Sidebars::Projects::Context.new(current_user: project.owner, container: project) } - let(:shimo_integration) { create(:shimo_integration, project: project) } subject(:shimo_menu) { described_class.new(context) } describe '#render?' do - context 'when integration is activated' do - it 'renders the menu' do - expect(shimo_menu.render?).to eq true - end - - it 'renders menu link' do - expect(shimo_menu.link).to eq project_integrations_shimo_home_path(project) + context 'without a valid Shimo integration' do + it "doesn't render the menu" do + expect(shimo_menu.render?).to be_falsey end end - context 'when integration is inactivated' do + context 'with a valid Shimo integration' do before do - shimo_integration.active = false + create(:shimo_integration, project: project) + end + + context 'when integration is activated' do + it 'renders the menu' do + expect(shimo_menu.render?).to eq true + end + + it 'renders menu link' do + expected_url = Rails.application.routes.url_helpers.project_integrations_shimo_home_path(project) + expect(shimo_menu.link).to eq expected_url + end end - it 'returns false' do - expect(shimo_menu.render?).to eq false + context 'when integration is inactivated' do + before do + shimo_integration.update!(active: false) + end + + it "doesn't render the menu" do + expect(shimo_menu.render?).to eq false + end end end end -- GitLab From d9ce65b7e84e26c560170e243a699f86a4d2855b Mon Sep 17 00:00:00 2001 From: Baodong Date: Thu, 28 Oct 2021 22:01:26 +0800 Subject: [PATCH 12/22] Fix Shimo unit tests --- .../projects/integrations/shimo_controller.rb | 2 ++ app/models/integrations/shimo.rb | 2 +- lib/api/helpers/integrations_helpers.rb | 2 +- .../projects/integrations/shimo_controller_spec.rb | 9 ++++++++- spec/lib/sidebars/projects/menus/shimo_menu_spec.rb | 4 +--- spec/models/integrations/shimo_spec.rb | 9 +++++---- spec/requests/api/integrations_spec.rb | 2 +- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/controllers/projects/integrations/shimo_controller.rb b/app/controllers/projects/integrations/shimo_controller.rb index 2a7979b70e8aa8..b6eaba6809b1af 100644 --- a/app/controllers/projects/integrations/shimo_controller.rb +++ b/app/controllers/projects/integrations/shimo_controller.rb @@ -3,6 +3,8 @@ module Projects module Integrations class ShimoController < Projects::ApplicationController + feature_category :integrations + before_action :check_enable # GET /*namespace_id/:project_id/-/integrations/shimo/home diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb index 907293a8f841d7..876e25da7d107d 100644 --- a/app/models/integrations/shimo.rb +++ b/app/models/integrations/shimo.rb @@ -12,7 +12,7 @@ def feature_flag_enabled? def render? return false unless feature_flag_enabled? - workspace_url.present? && activated? + valid? && activated? end def title diff --git a/lib/api/helpers/integrations_helpers.rb b/lib/api/helpers/integrations_helpers.rb index 4e65aae6a3b86b..83dc25a9e34ab0 100644 --- a/lib/api/helpers/integrations_helpers.rb +++ b/lib/api/helpers/integrations_helpers.rb @@ -535,7 +535,7 @@ def self.integrations required: true, name: :workspace_url, type: String, - desc: 'Shimo workspace URLn' + desc: 'Shimo workspace URL' } ], 'slack-slash-commands' => [ diff --git a/spec/controllers/projects/integrations/shimo_controller_spec.rb b/spec/controllers/projects/integrations/shimo_controller_spec.rb index 757029936ea006..726956a096dcae 100644 --- a/spec/controllers/projects/integrations/shimo_controller_spec.rb +++ b/spec/controllers/projects/integrations/shimo_controller_spec.rb @@ -4,12 +4,17 @@ RSpec.describe ::Projects::Integrations::ShimoController do let_it_be(:project) { create(:project) } + let_it_be(:user) { create(:user, developer_projects: [project]) } let_it_be(:shimo_integration) { create(:shimo_integration, project: project) } + before do + sign_in(user) + end + describe 'GET #home' do context 'when Shimo integration is inactivated' do before do - shimo_integration.active = false + shimo_integration.update!(active: false) end it 'returns 404 status' do @@ -20,6 +25,8 @@ end context 'when Shimo integration is activated' do + render_views + it 'renders the "home" template' do get :home, params: { namespace_id: project.namespace, project_id: project } diff --git a/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb index d080fc0780ab9a..8ffdb49c58fbaa 100644 --- a/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb @@ -16,9 +16,7 @@ end context 'with a valid Shimo integration' do - before do - create(:shimo_integration, project: project) - end + let!(:shimo_integration) { create(:shimo_integration, project: project) } context 'when integration is activated' do it 'renders the menu' do diff --git a/spec/models/integrations/shimo_spec.rb b/spec/models/integrations/shimo_spec.rb index 56ef12ab7d4b9d..34f505bd735fde 100644 --- a/spec/models/integrations/shimo_spec.rb +++ b/spec/models/integrations/shimo_spec.rb @@ -27,13 +27,14 @@ end context 'with invalid params' do - before do + it 'cannot create the Shimo integration without workspace_url' do params['workspace_url'] = nil + expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid) end - it 'cannot create the Shimo integration' do - shimo = described_class.create!(params) - expect(shimo.valid?).to be false + it 'cannot create the Shimo integration with invalid workspace_url' do + params['workspace_url'] = 'Fake Invalid URL' + expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid) end end end diff --git a/spec/requests/api/integrations_spec.rb b/spec/requests/api/integrations_spec.rb index 649647804c0f25..5cad8863501e43 100644 --- a/spec/requests/api/integrations_spec.rb +++ b/spec/requests/api/integrations_spec.rb @@ -105,7 +105,7 @@ delete api("/projects/#{project.id}/#{endpoint}/#{dashed_integration}", user) expect(response).to have_gitlab_http_status(:no_content) - project.send(integration_method).reload + project.reload.send(integration_method).reload expect(project.send(integration_method).activated?).to be_falsey end end -- GitLab From e807f71cfaed7d91cbb6179be7f38094378bd26e Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 09:53:13 +0800 Subject: [PATCH 13/22] Fix Shimo text --- app/views/projects/integrations/shimo/home.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/projects/integrations/shimo/home.html.haml b/app/views/projects/integrations/shimo/home.html.haml index bb9c709711dc83..c6243f41379d70 100644 --- a/app/views/projects/integrations/shimo/home.html.haml +++ b/app/views/projects/integrations/shimo/home.html.haml @@ -3,9 +3,9 @@ - add_page_specific_style 'page_bundles/wiki' = render layout: 'shared/empty_states/wikis_layout', locals: { image_path: 'illustrations/wiki_login_empty.svg' } do %h4 - = s_('Shimo|Shimo Workspace is enabled') + = s_('Shimo|Shimo Workspace integration is enabled') %p - = format s_("Shimo|You've enabled the Shimo Workspace integration. Your wiki will be viewable directly within Shimo. We are hard at work integrating Shimo more seamlessly into GitLab.").html_safe + = format s_("Shimo|You've enabled the Shimo Workspace integration. You can view your wiki directly in Shimo.").html_safe = link_to @project.shimo_integration.workspace_url, target: '_blank', rel: 'noopener noreferrer', class: 'gl-button btn btn-success external-url', title: s_('Shimo|Go to Shimo') do - = sprite_icon('external-link') = s_('Shimo|Go to Shimo') + = sprite_icon('external-link') -- GitLab From 8b1b284d5dae79c4ffa5d68ce7feeeddeac37ef9 Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 09:54:19 +0800 Subject: [PATCH 14/22] Remove useless method --- app/models/integrations/shimo.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb index 876e25da7d107d..a4fa4b7f28a12b 100644 --- a/app/models/integrations/shimo.rb +++ b/app/models/integrations/shimo.rb @@ -38,10 +38,6 @@ def self.supported_events %w() end - def self.supported_event_actions - %w() - end - def fields [ { -- GitLab From 403b9791ea0392dfa1985a1d8c324b004c3094e8 Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 11:12:29 +0800 Subject: [PATCH 15/22] Update shimo.rb --- app/models/integrations/shimo.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb index a4fa4b7f28a12b..8ec239352c02ab 100644 --- a/app/models/integrations/shimo.rb +++ b/app/models/integrations/shimo.rb @@ -24,9 +24,10 @@ def description end def self.to_param - name.demodulize.downcase + 'shimo' end + # support for `test` method def execute(_data) response = Gitlab::HTTP.get(properties['workspace_url'], verify: true, use_read_total_timeout: true) response.body if response.code == 200 -- GitLab From 2cd324cedb2a74da554397867805acba36e1ff4d Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 11:16:29 +0800 Subject: [PATCH 16/22] Update shimo.rb --- app/models/integrations/shimo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb index 8ec239352c02ab..b2d2953b558bf3 100644 --- a/app/models/integrations/shimo.rb +++ b/app/models/integrations/shimo.rb @@ -44,7 +44,7 @@ def fields { type: 'text', name: 'workspace_url', - title: s_('Shimo|Shimo workspace URL'), + title: s_('Shimo|Shimo Workspace URL'), required: true } ] -- GitLab From 8276764bf8fc9e19f3f76fd5870f9b80880b9d97 Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 11:27:18 +0800 Subject: [PATCH 17/22] Use external_link to simplify the code --- app/views/projects/integrations/shimo/home.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/projects/integrations/shimo/home.html.haml b/app/views/projects/integrations/shimo/home.html.haml index c6243f41379d70..9d6bc3c2a97ea5 100644 --- a/app/views/projects/integrations/shimo/home.html.haml +++ b/app/views/projects/integrations/shimo/home.html.haml @@ -6,6 +6,6 @@ = s_('Shimo|Shimo Workspace integration is enabled') %p = format s_("Shimo|You've enabled the Shimo Workspace integration. You can view your wiki directly in Shimo.").html_safe - = link_to @project.shimo_integration.workspace_url, target: '_blank', rel: 'noopener noreferrer', class: 'gl-button btn btn-success external-url', title: s_('Shimo|Go to Shimo') do - = s_('Shimo|Go to Shimo') - = sprite_icon('external-link') + = external_link(s_('Shimo|Go to Shimo Workspace'), + @project.shimo_integration.workspace_url, + class: 'gl-button btn btn-success external-url') -- GitLab From 4befbe1ad2a4020a83b052ac7a690e27ce897423 Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 11:37:23 +0800 Subject: [PATCH 18/22] Update Shimo routes --- app/controllers/projects/integrations/shimo_controller.rb | 3 +-- .../integrations/shimo/{home.html.haml => index.html.haml} | 0 config/routes/project.rb | 2 +- lib/sidebars/projects/menus/shimo_menu.rb | 2 +- spec/lib/sidebars/projects/menus/shimo_menu_spec.rb | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) rename app/views/projects/integrations/shimo/{home.html.haml => index.html.haml} (100%) diff --git a/app/controllers/projects/integrations/shimo_controller.rb b/app/controllers/projects/integrations/shimo_controller.rb index b6eaba6809b1af..95426aca13040b 100644 --- a/app/controllers/projects/integrations/shimo_controller.rb +++ b/app/controllers/projects/integrations/shimo_controller.rb @@ -7,8 +7,7 @@ class ShimoController < Projects::ApplicationController before_action :check_enable - # GET /*namespace_id/:project_id/-/integrations/shimo/home - def home; end + def index; end private diff --git a/app/views/projects/integrations/shimo/home.html.haml b/app/views/projects/integrations/shimo/index.html.haml similarity index 100% rename from app/views/projects/integrations/shimo/home.html.haml rename to app/views/projects/integrations/shimo/index.html.haml diff --git a/config/routes/project.rb b/config/routes/project.rb index 9b15ea92e52b10..ea682538111a60 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -453,7 +453,7 @@ end namespace :integrations do - get 'shimo/home', to: 'shimo#home' + resources :shimo, only: [:index] end end # End of the /-/ scope. diff --git a/lib/sidebars/projects/menus/shimo_menu.rb b/lib/sidebars/projects/menus/shimo_menu.rb index 571889c242e462..5122f4a369415a 100644 --- a/lib/sidebars/projects/menus/shimo_menu.rb +++ b/lib/sidebars/projects/menus/shimo_menu.rb @@ -6,7 +6,7 @@ module Menus class ShimoMenu < ::Sidebars::Menu override :link def link - project_integrations_shimo_home_path(context.project) + project_integrations_shimo_index_path(context.project) end override :title diff --git a/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb index 8ffdb49c58fbaa..636440c96791e0 100644 --- a/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb +++ b/spec/lib/sidebars/projects/menus/shimo_menu_spec.rb @@ -24,7 +24,7 @@ end it 'renders menu link' do - expected_url = Rails.application.routes.url_helpers.project_integrations_shimo_home_path(project) + expected_url = Rails.application.routes.url_helpers.project_integrations_shimo_index_path(project) expect(shimo_menu.link).to eq expected_url end end -- GitLab From 3554675f3ac7ede88c62c4b5c55c08aee5b83ded Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 11:46:29 +0800 Subject: [PATCH 19/22] Rename check method of Shimo --- app/controllers/projects/integrations/shimo_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects/integrations/shimo_controller.rb b/app/controllers/projects/integrations/shimo_controller.rb index 95426aca13040b..c1da33c617d375 100644 --- a/app/controllers/projects/integrations/shimo_controller.rb +++ b/app/controllers/projects/integrations/shimo_controller.rb @@ -5,13 +5,13 @@ module Integrations class ShimoController < Projects::ApplicationController feature_category :integrations - before_action :check_enable + before_action :ensure_renderable def index; end private - def check_enable + def ensure_renderable render_404 unless project.shimo_integration&.render? end end -- GitLab From 1d2bc9876342bd6afa41d95ab421241165c7c09d Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 14:26:58 +0800 Subject: [PATCH 20/22] Reuse external_wiki_url --- app/controllers/concerns/integrations/params.rb | 1 - app/models/integrations/shimo.rb | 8 ++++---- .../projects/integrations/shimo/index.html.haml | 2 +- lib/api/helpers/integrations_helpers.rb | 2 +- .../integrations/shimo_controller_spec.rb | 2 +- spec/factories/integrations.rb | 2 +- spec/models/integrations/shimo_spec.rb | 16 ++++++++-------- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/controllers/concerns/integrations/params.rb b/app/controllers/concerns/integrations/params.rb index 82058acfcf2f27..201fb1dc83f2c9 100644 --- a/app/controllers/concerns/integrations/params.rb +++ b/app/controllers/concerns/integrations/params.rb @@ -76,7 +76,6 @@ module Params :user_key, :username, :webhook, - :workspace_url, :zentao_product_xid ].freeze diff --git a/app/models/integrations/shimo.rb b/app/models/integrations/shimo.rb index b2d2953b558bf3..fe39dd705d002b 100644 --- a/app/models/integrations/shimo.rb +++ b/app/models/integrations/shimo.rb @@ -2,8 +2,8 @@ module Integrations class Shimo < Integration - prop_accessor :workspace_url - validates :workspace_url, presence: true, public_url: true, if: :activated? + prop_accessor :external_wiki_url + validates :external_wiki_url, presence: true, public_url: true, if: :activated? def feature_flag_enabled? Feature.enabled?(:shimo_integration, project) @@ -29,7 +29,7 @@ def self.to_param # support for `test` method def execute(_data) - response = Gitlab::HTTP.get(properties['workspace_url'], verify: true, use_read_total_timeout: true) + response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true, use_read_total_timeout: true) response.body if response.code == 200 rescue StandardError nil @@ -43,7 +43,7 @@ def fields [ { type: 'text', - name: 'workspace_url', + name: 'external_wiki_url', title: s_('Shimo|Shimo Workspace URL'), required: true } diff --git a/app/views/projects/integrations/shimo/index.html.haml b/app/views/projects/integrations/shimo/index.html.haml index 9d6bc3c2a97ea5..fa7505cfe08360 100644 --- a/app/views/projects/integrations/shimo/index.html.haml +++ b/app/views/projects/integrations/shimo/index.html.haml @@ -7,5 +7,5 @@ %p = format s_("Shimo|You've enabled the Shimo Workspace integration. You can view your wiki directly in Shimo.").html_safe = external_link(s_('Shimo|Go to Shimo Workspace'), - @project.shimo_integration.workspace_url, + @project.shimo_integration.external_wiki_url, class: 'gl-button btn btn-success external-url') diff --git a/lib/api/helpers/integrations_helpers.rb b/lib/api/helpers/integrations_helpers.rb index 83dc25a9e34ab0..e7fdb6645a507f 100644 --- a/lib/api/helpers/integrations_helpers.rb +++ b/lib/api/helpers/integrations_helpers.rb @@ -533,7 +533,7 @@ def self.integrations 'shimo' => [ { required: true, - name: :workspace_url, + name: :external_wiki_url, type: String, desc: 'Shimo workspace URL' } diff --git a/spec/controllers/projects/integrations/shimo_controller_spec.rb b/spec/controllers/projects/integrations/shimo_controller_spec.rb index 726956a096dcae..8930ce759fa8c8 100644 --- a/spec/controllers/projects/integrations/shimo_controller_spec.rb +++ b/spec/controllers/projects/integrations/shimo_controller_spec.rb @@ -32,7 +32,7 @@ expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:home) - expect(response.body).to include shimo_integration.workspace_url + expect(response.body).to include shimo_integration.external_wiki_url end end end diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index 2ddcfa1649f8e0..63a5fadb6a82a8 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -114,7 +114,7 @@ factory :shimo_integration, class: 'Integrations::Shimo' do project active { true } - workspace_url { 'https://shimo.im/desktop' } + external_wiki_url { 'https://shimo.im/desktop' } end factory :confluence_integration, class: 'Integrations::Confluence' do diff --git a/spec/models/integrations/shimo_spec.rb b/spec/models/integrations/shimo_spec.rb index 34f505bd735fde..17546d68bcf076 100644 --- a/spec/models/integrations/shimo_spec.rb +++ b/spec/models/integrations/shimo_spec.rb @@ -7,14 +7,14 @@ let(:shimo_integration) { create(:shimo_integration) } it 'returns custom fields' do - expect(shimo_integration.fields.pluck(:name)).to eq(%w[workspace_url]) + expect(shimo_integration.fields.pluck(:name)).to eq(%w[external_wiki_url]) end end describe '#create' do let(:project) { create(:project, :repository) } - let(:workspace_url) { 'https://shimo.im/' } - let(:params) { { active: true, project: project, workspace_url: workspace_url } } + let(:external_wiki_url) { 'https://shimo.im/' } + let(:params) { { active: true, project: project, external_wiki_url: external_wiki_url } } context 'with valid params' do it 'creates the Shimo integration' do @@ -22,18 +22,18 @@ expect(shimo.valid?).to be true expect(shimo.render?).to be true - expect(shimo.workspace_url).to eq(workspace_url) + expect(shimo.external_wiki_url).to eq(external_wiki_url) end end context 'with invalid params' do - it 'cannot create the Shimo integration without workspace_url' do - params['workspace_url'] = nil + it 'cannot create the Shimo integration without external_wiki_url' do + params['external_wiki_url'] = nil expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid) end - it 'cannot create the Shimo integration with invalid workspace_url' do - params['workspace_url'] = 'Fake Invalid URL' + it 'cannot create the Shimo integration with invalid external_wiki_url' do + params['external_wiki_url'] = 'Fake Invalid URL' expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid) end end -- GitLab From 1af01d88c2718d6aa86b8e8701d08867a7733eb1 Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 14:47:20 +0800 Subject: [PATCH 21/22] Update gitlab.pot --- locale/gitlab.pot | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 68f2e7c6472c5c..267d0648e2e9ee 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -31599,7 +31599,7 @@ msgstr "" msgid "Sherlock Transactions" msgstr "" -msgid "Shimo|Go to Shimo" +msgid "Shimo|Go to Shimo Workspace" msgstr "" msgid "Shimo|Link to a Shimo Workspace from the sidebar." @@ -31611,13 +31611,13 @@ msgstr "" msgid "Shimo|Shimo Workspace" msgstr "" -msgid "Shimo|Shimo Workspace is enabled" +msgid "Shimo|Shimo Workspace URL" msgstr "" -msgid "Shimo|Shimo workspace URL" +msgid "Shimo|Shimo Workspace integration is enabled" msgstr "" -msgid "Shimo|You've enabled the Shimo Workspace integration. Your wiki will be viewable directly within Shimo. We are hard at work integrating Shimo more seamlessly into GitLab." +msgid "Shimo|You've enabled the Shimo Workspace integration. You can view your wiki directly in Shimo." msgstr "" msgid "Should you ever lose your phone or access to your one time password secret, each of these recovery codes can be used one time each to regain access to your account. Please save them in a safe place, or you %{boldStart}will%{boldEnd} lose access to your account." -- GitLab From bdf625b6b81cda0c94b2d992ddde28a442404866 Mon Sep 17 00:00:00 2001 From: Baodong Date: Wed, 3 Nov 2021 14:47:35 +0800 Subject: [PATCH 22/22] Fix shimo test --- .../projects/integrations/shimo_controller_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/controllers/projects/integrations/shimo_controller_spec.rb b/spec/controllers/projects/integrations/shimo_controller_spec.rb index 8930ce759fa8c8..1dfc1a96fdc0ec 100644 --- a/spec/controllers/projects/integrations/shimo_controller_spec.rb +++ b/spec/controllers/projects/integrations/shimo_controller_spec.rb @@ -11,14 +11,14 @@ sign_in(user) end - describe 'GET #home' do + describe 'GET #index' do context 'when Shimo integration is inactivated' do before do shimo_integration.update!(active: false) end it 'returns 404 status' do - get :home, params: { namespace_id: project.namespace, project_id: project } + get :index, params: { namespace_id: project.namespace, project_id: project } expect(response).to have_gitlab_http_status(:not_found) end @@ -27,11 +27,11 @@ context 'when Shimo integration is activated' do render_views - it 'renders the "home" template' do - get :home, params: { namespace_id: project.namespace, project_id: project } + it 'renders the "index" template' do + get :index, params: { namespace_id: project.namespace, project_id: project } expect(response).to have_gitlab_http_status(:ok) - expect(response).to render_template(:home) + expect(response).to render_template(:index) expect(response.body).to include shimo_integration.external_wiki_url end end -- GitLab