Commit 29eb045b authored by Baodong's avatar Baodong Committed by Mikołaj Wawrzyniak

Shimo integration: part of models

parent daebde1b
......@@ -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[
......
# frozen_string_literal: true
module Integrations
class Shimo < Integration
prop_accessor :external_wiki_url
validates :external_wiki_url, presence: true, public_url: true, if: :activated?
def render?
valid? && 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
'shimo'
end
# support for `test` method
def execute(_data)
response = Gitlab::HTTP.get(properties['external_wiki_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 fields
[
{
type: 'text',
name: 'external_wiki_url',
title: s_('Shimo|Shimo Workspace URL'),
required: true
}
]
end
end
end
......@@ -189,6 +189,7 @@ class Project < ApplicationRecord
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,7 @@ class Project < ApplicationRecord
end
def disabled_integrations
[]
[:shimo]
end
def find_or_initialize_integration(name)
......
---
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: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
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: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
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: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
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: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
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: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
......@@ -16819,6 +16819,7 @@ State of a Sentry error.
| <a id="servicetypeprometheus_service"></a>`PROMETHEUS_SERVICE` | PrometheusService type. |
| <a id="servicetypepushover_service"></a>`PUSHOVER_SERVICE` | PushoverService type. |
| <a id="servicetyperedmine_service"></a>`REDMINE_SERVICE` | RedmineService type. |
| <a id="servicetypeshimo_service"></a>`SHIMO_SERVICE` | ShimoService type. |
| <a id="servicetypeslack_service"></a>`SLACK_SERVICE` | SlackService type. |
| <a id="servicetypeslack_slash_commands_service"></a>`SLACK_SLASH_COMMANDS_SERVICE` | SlackSlashCommandsService type. |
| <a id="servicetypeteamcity_service"></a>`TEAMCITY_SERVICE` | TeamcityService type. |
......
......@@ -530,6 +530,14 @@ module API
desc: 'The Mattermost token'
}
],
'shimo' => [
{
required: true,
name: :external_wiki_url,
type: String,
desc: 'Shimo workspace URL'
}
],
'slack-slash-commands' => [
{
required: true,
......
......@@ -7,7 +7,7 @@ module Gitlab
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
......
......@@ -31751,6 +31751,15 @@ msgstr ""
msgid "Sherlock Transactions"
msgstr ""
msgid "Shimo|Link to a Shimo Workspace from the sidebar."
msgstr ""
msgid "Shimo|Shimo"
msgstr ""
msgid "Shimo|Shimo Workspace URL"
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 ""
......
......@@ -111,6 +111,12 @@ FactoryBot.define do
end
end
factory :shimo_integration, class: 'Integrations::Shimo' do
project
active { true }
external_wiki_url { 'https://shimo.example.com/desktop' }
end
factory :confluence_integration, class: 'Integrations::Confluence' do
project
active { true }
......
......@@ -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
......
# 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[external_wiki_url])
end
end
describe '#create' do
let(:project) { create(:project, :repository) }
let(:external_wiki_url) { 'https://shimo.example.com/desktop' }
let(:params) { { active: true, project: project, external_wiki_url: external_wiki_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.external_wiki_url).to eq(external_wiki_url)
end
end
context 'with invalid params' do
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 external_wiki_url' do
params['external_wiki_url'] = 'Fake Invalid URL'
expect { described_class.create!(params) }.to raise_error(ActiveRecord::RecordInvalid)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment