parent
b18646040c
commit
2cc6485518
|
@ -8,6 +8,19 @@ body {
|
||||||
&.navless {
|
&.navless {
|
||||||
background-color: $white-light !important;
|
background-color: $white-light !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.card-content {
|
||||||
|
background-color: $gray-darker;
|
||||||
|
|
||||||
|
.content-wrapper {
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
.container-fluid,
|
||||||
|
.container-limited {
|
||||||
|
background-color: $gray-darker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
module MattermostHelper
|
module MattermostHelper
|
||||||
def mattermost_teams_options(teams)
|
def mattermost_teams_options(teams)
|
||||||
teams_options = teams.map do |id, options|
|
teams.map do |team|
|
||||||
[options['display_name'] || options['name'], id]
|
[team['display_name'] || team['name'], team['id']]
|
||||||
end
|
end
|
||||||
|
|
||||||
teams_options.compact.unshift(['Select team...', '0'])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
!!! 5
|
!!! 5
|
||||||
%html{ lang: "en", class: "#{page_class}" }
|
%html{ lang: "en", class: "#{page_class}" }
|
||||||
= render "layouts/head"
|
= render "layouts/head"
|
||||||
%body{ data: { page: body_data_page, project: "#{@project.path if @project}", group: "#{@group.path if @group}" } }
|
%body{ class: @body_class, data: { page: body_data_page, project: "#{@project.path if @project}", group: "#{@group.path if @group}" } }
|
||||||
= Gon::Base.render_data
|
= Gon::Base.render_data
|
||||||
|
|
||||||
= render "layouts/header/default", title: header_title
|
= render "layouts/header/default", title: header_title
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
This service will be installed on the Mattermost instance at
|
This service will be installed on the Mattermost instance at
|
||||||
%strong= link_to Gitlab.config.mattermost.host, Gitlab.config.mattermost.host
|
%strong= link_to Gitlab.config.mattermost.host, Gitlab.config.mattermost.host
|
||||||
%hr
|
%hr
|
||||||
= form_for(:mattermost, method: :post, url: namespace_project_mattermost_path(@project.namespace, @project)) do |f|
|
= form_for(:mattermost, method: :post, url: namespace_project_mattermost_path(@project.namespace, @project), html: { class: 'js-requires-input'} ) do |f|
|
||||||
%h4 Team
|
%h4 Team
|
||||||
%p
|
%p
|
||||||
= @teams.one? ? 'The team' : 'Select the team'
|
= @teams.one? ? 'The team' : 'Select the team'
|
||||||
where the slash commands will be used in
|
where the slash commands will be used in
|
||||||
- selected_id = @teams.one? ? @teams.keys.first : 0
|
- selected_id = @teams.one? ? @teams.first['id'] : nil
|
||||||
- options = mattermost_teams_options(@teams)
|
- options = options_for_select(mattermost_teams_options(@teams), selected_id)
|
||||||
- options = options_for_select(options, selected_id)
|
= f.select(:team_id, options, { include_blank: 'Select team...'}, { class: 'form-control', disabled: @teams.one?, selected: selected_id, required: true })
|
||||||
= f.select(:team_id, options, {}, { class: 'form-control', disabled: @teams.one?, selected: selected_id })
|
= f.hidden_field(:team_id, value: selected_id, required: true) if @teams.one?
|
||||||
= f.hidden_field(:team_id, value: selected_id) if @teams.one?
|
|
||||||
.help-block
|
.help-block
|
||||||
- if @teams.one?
|
- if @teams.one?
|
||||||
This is the only available team.
|
This is the only available team.
|
||||||
|
@ -25,7 +24,7 @@
|
||||||
%hr
|
%hr
|
||||||
%h4 Command trigger word
|
%h4 Command trigger word
|
||||||
%p Choose the word that will trigger commands
|
%p Choose the word that will trigger commands
|
||||||
= f.text_field(:trigger, value: @project.path, class: 'form-control')
|
= f.text_field(:trigger, value: @project.path, class: 'form-control', required: true)
|
||||||
.help-block
|
.help-block
|
||||||
%p
|
%p
|
||||||
Trigger word must be unique, and can't begin with a slash or contain any spaces.
|
Trigger word must be unique, and can't begin with a slash or contain any spaces.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
- @body_class = 'card-content'
|
||||||
|
|
||||||
.service-installation
|
.service-installation
|
||||||
.inline.pull-right
|
.inline.pull-right
|
||||||
= custom_icon('mattermost_logo', size: 48)
|
= custom_icon('mattermost_logo', size: 48)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Mattermost
|
module Mattermost
|
||||||
class Team < Client
|
class Team < Client
|
||||||
def all
|
def all
|
||||||
session_get('/api/v3/teams/all')
|
session_get('/api/v3/teams/all').values
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature 'Setup Mattermost slash commands', feature: true do
|
feature 'Setup Mattermost slash commands', :feature, :js do
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:project) { create(:empty_project) }
|
let(:project) { create(:empty_project) }
|
||||||
let(:service) { project.create_mattermost_slash_commands_service }
|
let(:service) { project.create_mattermost_slash_commands_service }
|
||||||
|
@ -62,11 +62,11 @@ feature 'Setup Mattermost slash commands', feature: true do
|
||||||
|
|
||||||
click_link 'Add to Mattermost'
|
click_link 'Add to Mattermost'
|
||||||
|
|
||||||
team_name = teams.first[1]['display_name']
|
team_name = teams.first['display_name']
|
||||||
select_element = find('select#mattermost_team_id')
|
select_element = find('#mattermost_team_id')
|
||||||
selected_option = select_element.find('option[selected]')
|
selected_option = select_element.find('option[selected]')
|
||||||
|
|
||||||
expect(select_element['disabled']).to eq('disabled')
|
expect(select_element['disabled']).to be(true)
|
||||||
expect(selected_option).to have_content(team_name.to_s)
|
expect(selected_option).to have_content(team_name.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ feature 'Setup Mattermost slash commands', feature: true do
|
||||||
|
|
||||||
click_link 'Add to Mattermost'
|
click_link 'Add to Mattermost'
|
||||||
|
|
||||||
expect(find('input#mattermost_team_id', visible: false).value).to eq(teams.first[0].to_s)
|
expect(find('input#mattermost_team_id', visible: false).value).to eq(teams.first['id'])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows an explanation user is a member of multiple teams' do
|
it 'shows an explanation user is a member of multiple teams' do
|
||||||
|
@ -92,12 +92,9 @@ feature 'Setup Mattermost slash commands', feature: true do
|
||||||
|
|
||||||
click_link 'Add to Mattermost'
|
click_link 'Add to Mattermost'
|
||||||
|
|
||||||
select_element = find('select#mattermost_team_id')
|
select_element = find('#mattermost_team_id')
|
||||||
selected_option = select_element.find('option[selected]')
|
|
||||||
|
|
||||||
expect(select_element['disabled']).to be(nil)
|
expect(select_element['disabled']).to be(false)
|
||||||
expect(selected_option).to have_content('Select team...')
|
|
||||||
# The 'Select team...' placeholder is item `0`.
|
|
||||||
expect(select_element.all('option').count).to eq(3)
|
expect(select_element.all('option').count).to eq(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -110,20 +107,37 @@ feature 'Setup Mattermost slash commands', feature: true do
|
||||||
expect(page).to have_content('test mattermost error message')
|
expect(page).to have_content('test mattermost error message')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'enables the submit button if the required fields are provided', :js do
|
||||||
|
stub_teams(count: 1)
|
||||||
|
|
||||||
|
click_link 'Add to Mattermost'
|
||||||
|
|
||||||
|
expect(find('input[type="submit"]')['disabled']).not_to be(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'disables the submit button if the required fields are not provided', :js do
|
||||||
|
stub_teams(count: 1)
|
||||||
|
|
||||||
|
click_link 'Add to Mattermost'
|
||||||
|
|
||||||
|
fill_in('mattermost_trigger', with: '')
|
||||||
|
|
||||||
|
expect(find('input[type="submit"]')['disabled']).to be(true)
|
||||||
|
end
|
||||||
|
|
||||||
def stub_teams(count: 0)
|
def stub_teams(count: 0)
|
||||||
teams = create_teams(count)
|
teams = create_teams(count)
|
||||||
|
|
||||||
allow_any_instance_of(MattermostSlashCommandsService).to receive(:list_teams) { teams }
|
allow_any_instance_of(MattermostSlashCommandsService).to receive(:list_teams) { [teams, nil] }
|
||||||
|
|
||||||
teams
|
teams
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_teams(count = 0)
|
def create_teams(count = 0)
|
||||||
teams = {}
|
teams = []
|
||||||
|
|
||||||
count.times do |i|
|
count.times do |i|
|
||||||
i += 1
|
teams.push({ "id" => "x#{i}", "display_name" => "x#{i}-name" })
|
||||||
teams[i] = { id: i, display_name: i }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
teams
|
teams
|
||||||
|
|
Loading…
Reference in New Issue