Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
cea54a80
Commit
cea54a80
authored
Nov 01, 2021
by
Andrew Fontaine
Committed by
Natalia Tepluhina
Nov 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set up entry point for new environments table
parent
5fc6db78
Changes
19
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
886 additions
and
41 deletions
+886
-41
app/assets/javascripts/environments/components/new_environments_app.vue
...ascripts/environments/components/new_environments_app.vue
+6
-0
app/assets/javascripts/environments/graphql/client.js
app/assets/javascripts/environments/graphql/client.js
+29
-0
app/assets/javascripts/environments/graphql/mutations/cancel_auto_stop.mutation.graphql
...ments/graphql/mutations/cancel_auto_stop.mutation.graphql
+5
-0
app/assets/javascripts/environments/graphql/mutations/delete_environment.mutation.graphql
...nts/graphql/mutations/delete_environment.mutation.graphql
+5
-0
app/assets/javascripts/environments/graphql/mutations/rollback_environment.mutation.graphql
...s/graphql/mutations/rollback_environment.mutation.graphql
+5
-0
app/assets/javascripts/environments/graphql/mutations/stop_environment.mutation.graphql
...ments/graphql/mutations/stop_environment.mutation.graphql
+5
-0
app/assets/javascripts/environments/graphql/queries/environmentApp.query.graphql
...environments/graphql/queries/environmentApp.query.graphql
+8
-0
app/assets/javascripts/environments/graphql/queries/folder.query.graphql
...scripts/environments/graphql/queries/folder.query.graphql
+7
-0
app/assets/javascripts/environments/graphql/resolvers.js
app/assets/javascripts/environments/graphql/resolvers.js
+51
-0
app/assets/javascripts/environments/graphql/typedefs.graphql
app/assets/javascripts/environments/graphql/typedefs.graphql
+35
-0
app/assets/javascripts/environments/index.js
app/assets/javascripts/environments/index.js
+35
-32
app/assets/javascripts/environments/new_index.js
app/assets/javascripts/environments/new_index.js
+38
-0
app/assets/javascripts/pages/projects/environments/index/index.js
...ts/javascripts/pages/projects/environments/index/index.js
+9
-1
app/views/projects/environments/index.html.haml
app/views/projects/environments/index.html.haml
+17
-8
config/feature_flags/development/new_environments_table.yml
config/feature_flags/development/new_environments_table.yml
+8
-0
ee/spec/features/projects/environments/environments_spec.rb
ee/spec/features/projects/environments/environments_spec.rb
+1
-0
spec/features/projects/environments/environments_spec.rb
spec/features/projects/environments/environments_spec.rb
+1
-0
spec/frontend/environments/graphql/mock_data.js
spec/frontend/environments/graphql/mock_data.js
+530
-0
spec/frontend/environments/graphql/resolvers_spec.js
spec/frontend/environments/graphql/resolvers_spec.js
+91
-0
No files found.
app/assets/javascripts/environments/components/new_environments_app.vue
0 → 100644
View file @
cea54a80
<
script
>
export
default
{};
</
script
>
<
template
>
<div></div>
</
template
>
app/assets/javascripts/environments/graphql/client.js
0 → 100644
View file @
cea54a80
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
environmentApp
from
'
./queries/environmentApp.query.graphql
'
;
import
{
resolvers
}
from
'
./resolvers
'
;
import
typedefs
from
'
./typedefs.graphql
'
;
export
const
apolloProvider
=
(
endpoint
)
=>
{
const
defaultClient
=
createDefaultClient
(
resolvers
(
endpoint
),
{
assumeImmutableResults
:
true
,
},
typedefs
,
);
const
{
cache
}
=
defaultClient
;
cache
.
writeQuery
({
query
:
environmentApp
,
data
:
{
availableCount
:
0
,
environments
:
[],
reviewApp
:
{},
stoppedCount
:
0
,
},
});
return
new
VueApollo
({
defaultClient
,
});
};
app/assets/javascripts/environments/graphql/mutations/cancel_auto_stop.mutation.graphql
0 → 100644
View file @
cea54a80
mutation
(
$environment
:
Environment
)
{
cancelAutoStop
(
environment
:
$environment
)
@client
{
errors
}
}
app/assets/javascripts/environments/graphql/mutations/delete_environment.mutation.graphql
0 → 100644
View file @
cea54a80
mutation
(
$environment
:
Environment
)
{
deleteEnvironment
(
environment
:
$environment
)
@client
{
errors
}
}
app/assets/javascripts/environments/graphql/mutations/rollback_environment.mutation.graphql
0 → 100644
View file @
cea54a80
mutation
(
$environment
:
Environment
)
{
rollbackEnvironment
(
environment
:
$environment
)
@client
{
errors
}
}
app/assets/javascripts/environments/graphql/mutations/stop_environment.mutation.graphql
0 → 100644
View file @
cea54a80
mutation
(
$environment
:
Environment
)
{
stopEnvironment
(
environment
:
$environment
)
@client
{
errors
}
}
app/assets/javascripts/environments/graphql/queries/environmentApp.query.graphql
0 → 100644
View file @
cea54a80
query
getEnvironmentApp
{
environmentApp
@client
{
availableCount
environments
reviewApp
stoppedCount
}
}
app/assets/javascripts/environments/graphql/queries/folder.query.graphql
0 → 100644
View file @
cea54a80
query
getEnvironmentFolder
(
$environment
:
NestedEnvironment
)
{
folder
(
environment
:
$environment
)
@client
{
availableCount
environments
stoppedCount
}
}
app/assets/javascripts/environments/graphql/resolvers.js
0 → 100644
View file @
cea54a80
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
const
mapNestedEnvironment
=
(
env
)
=>
({
...
convertObjectPropsToCamelCase
(
env
,
{
deep
:
true
}),
__typename
:
'
NestedEnvironment
'
,
});
const
mapEnvironment
=
(
env
)
=>
({
...
convertObjectPropsToCamelCase
(
env
),
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename
:
'
Environment
'
,
});
export
const
resolvers
=
(
endpoint
)
=>
({
Query
:
{
environmentApp
()
{
return
axios
.
get
(
endpoint
,
{
params
:
{
nested
:
true
}
}).
then
((
res
)
=>
({
availableCount
:
res
.
data
.
available_count
,
environments
:
res
.
data
.
environments
.
map
(
mapNestedEnvironment
),
reviewApp
:
{
...
convertObjectPropsToCamelCase
(
res
.
data
.
review_app
),
__typename
:
'
ReviewApp
'
,
},
stoppedCount
:
res
.
data
.
stopped_count
,
__typename
:
'
EnvironmentApp
'
,
}));
},
folder
(
_
,
{
environment
:
{
folderPath
}
})
{
return
axios
.
get
(
folderPath
,
{
params
:
{
per_page
:
3
}
}).
then
((
res
)
=>
({
availableCount
:
res
.
data
.
available_count
,
environments
:
res
.
data
.
environments
.
map
(
mapEnvironment
),
stoppedCount
:
res
.
data
.
stopped_count
,
__typename
:
'
EnvironmentFolder
'
,
}));
},
},
Mutations
:
{
stopEnvironment
(
_
,
{
environment
:
{
stopPath
}
})
{
return
axios
.
post
(
stopPath
);
},
deleteEnvironment
(
_
,
{
environment
:
{
deletePath
}
})
{
return
axios
.
delete
(
deletePath
);
},
rollbackEnvironment
(
_
,
{
environment
:
{
retryUrl
}
})
{
return
axios
.
post
(
retryUrl
);
},
cancelAutoStop
(
_
,
{
environment
:
{
autoStopPath
}
})
{
return
axios
.
post
(
autoStopPath
);
},
},
});
app/assets/javascripts/environments/graphql/typedefs.graphql
0 → 100644
View file @
cea54a80
type
Environment
{
id
:
Int
!
globalId
:
ID
!
name
:
String
!
folderPath
:
String
stopPath
:
String
deletePath
:
String
retryUrl
:
String
autoStopPath
:
String
}
type
NestedEnvironment
{
name
:
String
!
size
:
Int
!
latest
:
Environment
!
}
type
EnvironmentFolder
{
environments
:
[
Environment
!]!
availableCount
:
Int
!
stoppedCount
:
Int
!
}
type
ReviewApp
{
canSetupReviewApp
:
Boolean
!
allClustersEmpty
:
Boolean
!
reviewSnippet
:
String
}
type
EnvironmentApp
{
stoppedCount
:
Int
!
availableCount
:
Int
!
environments
:
[
NestedEnvironment
!]!
reviewApp
:
ReviewApp
!
}
app/assets/javascripts/environments/index.js
View file @
cea54a80
...
@@ -12,8 +12,8 @@ const apolloProvider = new VueApollo({
...
@@ -12,8 +12,8 @@ const apolloProvider = new VueApollo({
defaultClient
:
createDefaultClient
({},
{
assumeImmutableResults
:
true
}),
defaultClient
:
createDefaultClient
({},
{
assumeImmutableResults
:
true
}),
});
});
export
default
()
=>
{
export
default
(
el
)
=>
{
const
el
=
document
.
getElementById
(
'
environments-list-view
'
);
if
(
el
)
{
return
new
Vue
({
return
new
Vue
({
el
,
el
,
components
:
{
components
:
{
...
@@ -45,4 +45,7 @@ export default () => {
...
@@ -45,4 +45,7 @@ export default () => {
});
});
},
},
});
});
}
return
null
;
};
};
app/assets/javascripts/environments/new_index.js
0 → 100644
View file @
cea54a80
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
{
parseBoolean
}
from
'
../lib/utils/common_utils
'
;
import
{
apolloProvider
}
from
'
./graphql/client
'
;
import
EnvironmentsApp
from
'
./components/new_environments_app.vue
'
;
Vue
.
use
(
VueApollo
);
export
default
(
el
)
=>
{
if
(
el
)
{
const
{
canCreateEnvironment
,
endpoint
,
newEnvironmentPath
,
helpPagePath
,
projectPath
,
defaultBranchName
,
}
=
el
.
dataset
;
return
new
Vue
({
el
,
apolloProvider
:
apolloProvider
(
endpoint
),
provide
:
{
projectPath
,
defaultBranchName
,
endpoint
,
newEnvironmentPath
,
helpPagePath
,
canCreateEnvironment
:
parseBoolean
(
canCreateEnvironment
),
},
render
(
h
)
{
return
h
(
EnvironmentsApp
);
},
});
}
return
null
;
};
app/assets/javascripts/pages/projects/environments/index/index.js
View file @
cea54a80
import
initEnvironments
from
'
~/environments/
'
;
import
initEnvironments
from
'
~/environments/
'
;
import
initNewEnvironments
from
'
~/environments/new_index
'
;
initEnvironments
();
let
el
=
document
.
getElementById
(
'
environments-list-view
'
);
if
(
el
)
{
initEnvironments
(
el
);
}
else
{
el
=
document
.
getElementById
(
'
environments-table
'
);
initNewEnvironments
(
el
);
}
app/views/projects/environments/index.html.haml
View file @
cea54a80
-
page_title
_
(
"Environments"
)
-
page_title
_
(
"Environments"
)
-
add_page_specific_style
'page_bundles/environments'
#environments-list-view
{
data:
{
environments_data:
environments_list_data
,
-
if
Feature
.
enabled?
(
:new_environments_table
)
#environments-table
{
data:
{
endpoint:
project_environments_path
(
@project
,
format: :json
),
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
).
to_s
,
"can-create-environment"
=>
can?
(
current_user
,
:create_environment
,
@project
).
to_s
,
"new-environment-path"
=>
new_project_environment_path
(
@project
),
"help-page-path"
=>
help_page_path
(
"ci/environments/index.md"
),
"project-path"
=>
@project
.
full_path
,
"default-branch-name"
=>
@project
.
default_branch_or_main
}
}
-
else
-
add_page_specific_style
'page_bundles/environments'
#environments-list-view
{
data:
{
environments_data:
environments_list_data
,
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
).
to_s
,
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
).
to_s
,
"can-create-environment"
=>
can?
(
current_user
,
:create_environment
,
@project
).
to_s
,
"can-create-environment"
=>
can?
(
current_user
,
:create_environment
,
@project
).
to_s
,
"new-environment-path"
=>
new_project_environment_path
(
@project
),
"new-environment-path"
=>
new_project_environment_path
(
@project
),
...
...
config/feature_flags/development/new_environments_table.yml
0 → 100644
View file @
cea54a80
---
name
:
new_environments_table
introduced_by_url
:
rollout_issue_url
:
milestone
:
'
14.4'
type
:
development
group
:
group::release
default_enabled
:
false
ee/spec/features/projects/environments/environments_spec.rb
View file @
cea54a80
...
@@ -8,6 +8,7 @@ RSpec.describe 'Environments page', :js do
...
@@ -8,6 +8,7 @@ RSpec.describe 'Environments page', :js do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
stub_feature_flags
(
new_environments_table:
false
)
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:protected_environments
).
and_return
(
true
)
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:protected_environments
).
and_return
(
true
)
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
...
...
spec/features/projects/environments/environments_spec.rb
View file @
cea54a80
...
@@ -8,6 +8,7 @@ RSpec.describe 'Environments page', :js do
...
@@ -8,6 +8,7 @@ RSpec.describe 'Environments page', :js do
let
(
:role
)
{
:developer
}
let
(
:role
)
{
:developer
}
before
do
before
do
stub_feature_flags
(
new_environments_table:
false
)
project
.
add_role
(
user
,
role
)
project
.
add_role
(
user
,
role
)
sign_in
(
user
)
sign_in
(
user
)
end
end
...
...
spec/frontend/environments/graphql/mock_data.js
0 → 100644
View file @
cea54a80
This diff is collapsed.
Click to expand it.
spec/frontend/environments/graphql/resolvers_spec.js
0 → 100644
View file @
cea54a80
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
resolvers
}
from
'
~/environments/graphql/resolvers
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
environmentsApp
,
resolvedEnvironmentsApp
,
folder
,
resolvedFolder
}
from
'
./mock_data
'
;
const
ENDPOINT
=
`
${
TEST_HOST
}
/environments`
;
describe
(
'
~/frontend/environments/graphql/resolvers
'
,
()
=>
{
let
mockResolvers
;
let
mock
;
beforeEach
(()
=>
{
mockResolvers
=
resolvers
(
ENDPOINT
);
mock
=
new
MockAdapter
(
axios
);
});
afterEach
(()
=>
{
mock
.
reset
();
});
describe
(
'
environmentApp
'
,
()
=>
{
it
(
'
should fetch environments and map them to frontend data
'
,
async
()
=>
{
mock
.
onGet
(
ENDPOINT
,
{
params
:
{
nested
:
true
}
}).
reply
(
200
,
environmentsApp
);
const
app
=
await
mockResolvers
.
Query
.
environmentApp
();
expect
(
app
).
toEqual
(
resolvedEnvironmentsApp
);
});
});
describe
(
'
folder
'
,
()
=>
{
it
(
'
should fetch the folder url passed to it
'
,
async
()
=>
{
mock
.
onGet
(
ENDPOINT
,
{
params
:
{
per_page
:
3
}
}).
reply
(
200
,
folder
);
const
environmentFolder
=
await
mockResolvers
.
Query
.
folder
(
null
,
{
environment
:
{
folderPath
:
ENDPOINT
},
});
expect
(
environmentFolder
).
toEqual
(
resolvedFolder
);
});
});
describe
(
'
stopEnvironment
'
,
()
=>
{
it
(
'
should post to the stop environment path
'
,
async
()
=>
{
mock
.
onPost
(
ENDPOINT
).
reply
(
200
);
await
mockResolvers
.
Mutations
.
stopEnvironment
(
null
,
{
environment
:
{
stopPath
:
ENDPOINT
}
});
expect
(
mock
.
history
.
post
).
toContainEqual
(
expect
.
objectContaining
({
url
:
ENDPOINT
,
method
:
'
post
'
}),
);
});
});
describe
(
'
rollbackEnvironment
'
,
()
=>
{
it
(
'
should post to the retry environment path
'
,
async
()
=>
{
mock
.
onPost
(
ENDPOINT
).
reply
(
200
);
await
mockResolvers
.
Mutations
.
rollbackEnvironment
(
null
,
{
environment
:
{
retryUrl
:
ENDPOINT
},
});
expect
(
mock
.
history
.
post
).
toContainEqual
(
expect
.
objectContaining
({
url
:
ENDPOINT
,
method
:
'
post
'
}),
);
});
});
describe
(
'
deleteEnvironment
'
,
()
=>
{
it
(
'
should DELETE to the delete environment path
'
,
async
()
=>
{
mock
.
onDelete
(
ENDPOINT
).
reply
(
200
);
await
mockResolvers
.
Mutations
.
deleteEnvironment
(
null
,
{
environment
:
{
deletePath
:
ENDPOINT
},
});
expect
(
mock
.
history
.
delete
).
toContainEqual
(
expect
.
objectContaining
({
url
:
ENDPOINT
,
method
:
'
delete
'
}),
);
});
});
describe
(
'
cancelAutoStop
'
,
()
=>
{
it
(
'
should post to the auto stop path
'
,
async
()
=>
{
mock
.
onPost
(
ENDPOINT
).
reply
(
200
);
await
mockResolvers
.
Mutations
.
cancelAutoStop
(
null
,
{
environment
:
{
autoStopPath
:
ENDPOINT
},
});
expect
(
mock
.
history
.
post
).
toContainEqual
(
expect
.
objectContaining
({
url
:
ENDPOINT
,
method
:
'
post
'
}),
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment