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
a5438f30
Commit
a5438f30
authored
Oct 29, 2020
by
derek-knox
Committed by
Chad Woolley
Nov 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial mr template API setup
Add endpoint to get desired payload Add namespace and project props
parent
8d9b0d04
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
0 deletions
+59
-0
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+12
-0
app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
...scripts/static_site_editor/components/edit_meta_modal.vue
+18
-0
app/assets/javascripts/static_site_editor/pages/home.vue
app/assets/javascripts/static_site_editor/pages/home.vue
+2
-0
app/controllers/projects/templates_controller.rb
app/controllers/projects/templates_controller.rb
+8
-0
config/routes/project.rb
config/routes/project.rb
+5
-0
lib/gitlab/template/base_template.rb
lib/gitlab/template/base_template.rb
+14
-0
No files found.
app/assets/javascripts/api.js
View file @
a5438f30
...
...
@@ -34,6 +34,7 @@ const Api = {
mergeRequestsPath
:
'
/api/:version/merge_requests
'
,
groupLabelsPath
:
'
/groups/:namespace_path/-/labels
'
,
issuableTemplatePath
:
'
/:namespace_path/:project_path/templates/:type/:key
'
,
issuableTemplatesPath
:
'
/:namespace_path/:project_path/templates/:type
'
,
projectTemplatePath
:
'
/api/:version/projects/:id/templates/:type/:key
'
,
projectTemplatesPath
:
'
/api/:version/projects/:id/templates/:type
'
,
userCountsPath
:
'
/api/:version/user_counts
'
,
...
...
@@ -471,6 +472,17 @@ const Api = {
.
catch
(
callback
);
},
issueTemplates
(
namespacePath
,
projectPath
,
type
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
issuableTemplatesPath
)
.
replace
(
'
:type
'
,
type
)
.
replace
(
'
:project_path
'
,
projectPath
)
.
replace
(
'
:namespace_path
'
,
namespacePath
);
return
axios
.
get
(
url
)
.
then
(({
data
})
=>
callback
(
null
,
data
))
.
catch
(
callback
);
},
users
(
query
,
options
)
{
const
url
=
Api
.
buildUrl
(
this
.
usersPath
);
return
axios
.
get
(
url
,
{
...
...
app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
View file @
a5438f30
<
script
>
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
{
__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
Api
from
'
~/api
'
;
import
LocalStorageSync
from
'
~/vue_shared/components/local_storage_sync.vue
'
;
import
EditMetaControls
from
'
./edit_meta_controls.vue
'
;
...
...
@@ -18,6 +19,14 @@ export default {
type
:
String
,
required
:
true
,
},
namespace
:
{
type
:
String
,
required
:
true
,
},
project
:
{
type
:
String
,
required
:
true
,
},
},
data
()
{
return
{
...
...
@@ -49,10 +58,19 @@ export default {
};
},
},
mounted
()
{
this
.
initTemplates
();
},
methods
:
{
hide
()
{
this
.
$refs
.
modal
.
hide
();
},
initTemplates
()
{
Api
.
issueTemplates
(
this
.
namespace
,
this
.
project
,
'
merge_request
'
,
(
err
,
templates
)
=>
{
if
(
err
)
return
;
// Error handled by global AJAX error handler
this
.
mergeRequestTemplates
=
templates
;
});
},
show
()
{
this
.
$refs
.
modal
.
show
();
},
...
...
app/assets/javascripts/static_site_editor/pages/home.vue
View file @
a5438f30
...
...
@@ -148,6 +148,8 @@ export default {
<edit-meta-modal
ref=
"editMetaModal"
:source-path=
"appData.sourcePath"
:namespace=
"appData.project.split('/')[0]"
:project=
"appData.project.split('/')[1]"
@
primary=
"onSubmit"
@
hide=
"onHideModal"
/>
...
...
app/controllers/projects/templates_controller.rb
View file @
a5438f30
...
...
@@ -7,6 +7,14 @@ class Projects::TemplatesController < Projects::ApplicationController
feature_category
:templates
def
index
templates
=
@template_type
.
template_subsets
(
project
)
respond_to
do
|
format
|
format
.
json
{
render
json:
templates
.
to_json
}
end
end
def
show
template
=
@template_type
.
find
(
params
[
:key
],
project
)
...
...
config/routes/project.rb
View file @
a5438f30
...
...
@@ -403,6 +403,11 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
#
# Templates
#
get
'/templates/:template_type'
=>
'templates#index'
,
# rubocop:todo Cop/PutProjectRoutesUnderScope
as: :templates
,
defaults:
{
format:
'json'
},
constraints:
{
template_type:
%r{issue|merge_request}
,
format:
'json'
}
get
'/templates/:template_type/:key'
=>
'templates#show'
,
# rubocop:todo Cop/PutProjectRoutesUnderScope
as: :template
,
defaults:
{
format:
'json'
},
...
...
lib/gitlab/template/base_template.rb
View file @
a5438f30
...
...
@@ -105,6 +105,20 @@ module Gitlab
files
.
map
{
|
t
|
{
name:
t
.
name
}
}
end
end
def
template_subsets
(
project
=
nil
)
return
[]
if
project
&&
!
project
.
repository
.
exists?
if
categories
.
any?
categories
.
keys
.
map
do
|
category
|
files
=
self
.
by_category
(
category
,
project
)
[
category
,
files
.
map
{
|
t
|
{
key:
t
.
key
,
name:
t
.
name
,
content:
t
.
content
}
}]
end
.
to_h
else
files
=
self
.
all
(
project
)
files
.
map
{
|
t
|
{
key:
t
.
key
,
name:
t
.
name
,
content:
t
.
content
}
}
end
end
end
end
end
...
...
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