Sort environments folders when opening them
Fixes gitlab-org/gitlab-ce#30814
This commit is contained in:
parent
6a2bcb4b2a
commit
0385f9efc2
3 changed files with 10 additions and 0 deletions
|
@ -31,6 +31,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
|
||||||
def folder
|
def folder
|
||||||
folder_environments = project.environments.where(environment_type: params[:id])
|
folder_environments = project.environments.where(environment_type: params[:id])
|
||||||
@environments = folder_environments.with_state(params[:scope] || :available)
|
@environments = folder_environments.with_state(params[:scope] || :available)
|
||||||
|
.order(:name)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|
4
changelogs/unreleased/zj-sort-env-folders.yml
Normal file
4
changelogs/unreleased/zj-sort-env-folders.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Sort folder for environments
|
||||||
|
merge_request:
|
||||||
|
author:
|
|
@ -84,6 +84,9 @@ describe Projects::EnvironmentsController do
|
||||||
create(:environment, project: project,
|
create(:environment, project: project,
|
||||||
name: 'staging-1.0/review',
|
name: 'staging-1.0/review',
|
||||||
state: :available)
|
state: :available)
|
||||||
|
create(:environment, project: project,
|
||||||
|
name: 'staging-1.0/preview',
|
||||||
|
state: :available)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when using default format' do
|
context 'when using default format' do
|
||||||
|
@ -107,6 +110,8 @@ describe Projects::EnvironmentsController do
|
||||||
expect(response).to be_ok
|
expect(response).to be_ok
|
||||||
expect(response).not_to render_template 'folder'
|
expect(response).not_to render_template 'folder'
|
||||||
expect(json_response['environments'][0])
|
expect(json_response['environments'][0])
|
||||||
|
.to include('name' => 'staging-1.0/preview')
|
||||||
|
expect(json_response['environments'][1])
|
||||||
.to include('name' => 'staging-1.0/review')
|
.to include('name' => 'staging-1.0/review')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue