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
5a0dadf7
Commit
5a0dadf7
authored
Oct 03, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the project template endpoints in the frontend
parent
9c0ea135
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
26 deletions
+43
-26
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+19
-0
app/assets/javascripts/blob/file_template_mediator.js
app/assets/javascripts/blob/file_template_mediator.js
+9
-6
app/assets/javascripts/blob/template_selectors/ci_yaml_selector.js
...s/javascripts/blob/template_selectors/ci_yaml_selector.js
+1
-3
app/assets/javascripts/blob/template_selectors/dockerfile_selector.js
...avascripts/blob/template_selectors/dockerfile_selector.js
+1
-3
app/assets/javascripts/blob/template_selectors/gitignore_selector.js
...javascripts/blob/template_selectors/gitignore_selector.js
+1
-3
app/assets/javascripts/blob/template_selectors/license_selector.js
...s/javascripts/blob/template_selectors/license_selector.js
+1
-3
app/assets/javascripts/blob_edit/blob_bundle.js
app/assets/javascripts/blob_edit/blob_bundle.js
+2
-1
app/assets/javascripts/blob_edit/edit_blob.js
app/assets/javascripts/blob_edit/edit_blob.js
+4
-3
app/assets/javascripts/ide/stores/modules/file_templates/actions.js
.../javascripts/ide/stores/modules/file_templates/actions.js
+2
-2
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+3
-2
No files found.
app/assets/javascripts/api.js
View file @
5a0dadf7
...
...
@@ -22,6 +22,8 @@ const Api = {
ldapGroupsPath
:
'
/api/:version/ldap/:provider/groups.json
'
,
dockerfilePath
:
'
/api/:version/templates/dockerfiles/:key
'
,
issuableTemplatePath
:
'
/:namespace_path/:project_path/templates/:type/:key
'
,
projectTemplatePath
:
'
/api/:version/projects/:id/templates/:type/:key
'
,
projectTemplatesPath
:
'
/api/:version/projects/:id/templates/:type
'
,
usersPath
:
'
/api/:version/users.json
'
,
userStatusPath
:
'
/api/:version/user/status
'
,
commitPath
:
'
/api/:version/projects/:id/repository/commits
'
,
...
...
@@ -223,6 +225,23 @@ const Api = {
return
axios
.
get
(
url
).
then
(({
data
})
=>
callback
(
data
));
},
projectTemplate
(
id
,
type
,
key
,
options
,
callback
)
{
const
url
=
Api
.
buildUrl
(
this
.
projectTemplatePath
)
.
replace
(
'
:id
'
,
encodeURIComponent
(
id
))
.
replace
(
'
:type
'
,
type
)
.
replace
(
'
:key
'
,
encodeURIComponent
(
key
));
return
axios
.
get
(
url
,
{
params
:
options
}).
then
(({
data
})
=>
callback
(
data
));
},
projectTemplates
(
id
,
type
,
params
=
{},
callback
)
{
const
url
=
Api
.
buildUrl
(
this
.
projectTemplatesPath
)
.
replace
(
'
:id
'
,
encodeURIComponent
(
id
))
.
replace
(
'
:type
'
,
type
);
return
axios
.
get
(
url
,
{
params
}).
then
(({
data
})
=>
callback
(
data
));
},
issueTemplate
(
namespacePath
,
projectPath
,
key
,
type
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
issuableTemplatePath
)
.
replace
(
'
:key
'
,
encodeURIComponent
(
key
))
...
...
app/assets/javascripts/blob/file_template_mediator.js
View file @
5a0dadf7
/* eslint-disable class-methods-use-this */
import
Api
from
'
~/api
'
;
import
$
from
'
jquery
'
;
import
Flash
from
'
../flash
'
;
import
FileTemplateTypeSelector
from
'
./template_selectors/type_selector
'
;
...
...
@@ -9,9 +11,10 @@ import GitignoreSelector from './template_selectors/gitignore_selector';
import
LicenseSelector
from
'
./template_selectors/license_selector
'
;
export
default
class
FileTemplateMediator
{
constructor
({
editor
,
currentAction
})
{
constructor
({
editor
,
currentAction
,
projectId
})
{
this
.
editor
=
editor
;
this
.
currentAction
=
currentAction
;
this
.
projectId
=
projectId
;
this
.
initTemplateSelectors
();
this
.
initTemplateTypeSelector
();
...
...
@@ -126,7 +129,7 @@ export default class FileTemplateMediator {
selector
.
renderLoading
();
// in case undo menu is already already there
this
.
destroyUndoMenu
();
this
.
fetchFileTemplate
(
selector
.
config
.
endpoint
,
query
,
data
)
this
.
fetchFileTemplate
(
selector
.
config
.
type
,
query
,
data
)
.
then
((
file
)
=>
{
this
.
showUndoMenu
();
this
.
setEditorContent
(
file
);
...
...
@@ -149,15 +152,15 @@ export default class FileTemplateMediator {
});
}
fetchFileTemplate
(
apiCall
,
query
,
data
)
{
fetchFileTemplate
(
type
,
query
,
data
)
{
return
new
Promise
((
resolve
)
=>
{
const
resolveFile
=
file
=>
resolve
(
file
);
if
(
!
data
)
{
apiCall
(
query
,
resolveFile
);
}
else
{
apiCall
(
query
,
data
,
resolveFile
);
data
=
{};
}
Api
.
projectTemplate
(
this
.
projectId
,
type
,
query
,
data
,
resolveFile
);
});
}
...
...
app/assets/javascripts/blob/template_selectors/ci_yaml_selector.js
View file @
5a0dadf7
import
Api
from
'
../../api
'
;
import
FileTemplateSelector
from
'
../file_template_selector
'
;
export
default
class
BlobCiYamlSelector
extends
FileTemplateSelector
{
...
...
@@ -9,7 +7,7 @@ export default class BlobCiYamlSelector extends FileTemplateSelector {
key
:
'
gitlab-ci-yaml
'
,
name
:
'
.gitlab-ci.yml
'
,
pattern
:
/
(
.gitlab-ci.yml
)
/
,
endpoint
:
Api
.
gitlabCiYml
,
type
:
'
gitlab_ci_ymls
'
,
dropdown
:
'
.js-gitlab-ci-yml-selector
'
,
wrapper
:
'
.js-gitlab-ci-yml-selector-wrap
'
,
};
...
...
app/assets/javascripts/blob/template_selectors/dockerfile_selector.js
View file @
5a0dadf7
import Api from '../../api';
import FileTemplateSelector from '../file_template_selector';
export default class DockerfileSelector extends FileTemplateSelector {
...
...
@@ -9,7 +7,7 @@ export default class DockerfileSelector extends FileTemplateSelector {
key: 'dockerfile',
name: 'Dockerfile',
pattern: /(Dockerfile)/,
endpoint: Api.dockerfileYml
,
type: 'dockerfiles'
,
dropdown: '.js-dockerfile-selector',
wrapper: '.js-dockerfile-selector-wrap',
};
...
...
app/assets/javascripts/blob/template_selectors/gitignore_selector.js
View file @
5a0dadf7
import
Api
from
'
../../api
'
;
import
FileTemplateSelector
from
'
../file_template_selector
'
;
export
default
class
BlobGitignoreSelector
extends
FileTemplateSelector
{
...
...
@@ -9,7 +7,7 @@ export default class BlobGitignoreSelector extends FileTemplateSelector {
key
:
'
gitignore
'
,
name
:
'
.gitignore
'
,
pattern
:
/
(
.gitignore
)
/
,
endpoint
:
Api
.
gitignoreText
,
type
:
'
gitignores
'
,
dropdown
:
'
.js-gitignore-selector
'
,
wrapper
:
'
.js-gitignore-selector-wrap
'
,
};
...
...
app/assets/javascripts/blob/template_selectors/license_selector.js
View file @
5a0dadf7
import
Api
from
'
../../api
'
;
import
FileTemplateSelector
from
'
../file_template_selector
'
;
export
default
class
BlobLicenseSelector
extends
FileTemplateSelector
{
...
...
@@ -9,7 +7,7 @@ export default class BlobLicenseSelector extends FileTemplateSelector {
key
:
'
license
'
,
name
:
'
LICENSE
'
,
pattern
:
/^
(
.+
\/)?(
licen
[
sc
]
e|copying
)(
$|
\.)
/i
,
endpoint
:
Api
.
licenseText
,
type
:
'
licenses
'
,
dropdown
:
'
.js-license-selector
'
,
wrapper
:
'
.js-license-selector-wrap
'
,
};
...
...
app/assets/javascripts/blob_edit/blob_bundle.js
View file @
5a0dadf7
...
...
@@ -15,8 +15,9 @@ export default () => {
const
assetsPath
=
editBlobForm
.
data
(
'
assetsPrefix
'
);
const
blobLanguage
=
editBlobForm
.
data
(
'
blobLanguage
'
);
const
currentAction
=
$
(
'
.js-file-title
'
).
data
(
'
currentAction
'
);
const
projectId
=
editBlobForm
.
data
(
'
project-id
'
);
new
EditBlob
(
`
${
urlRoot
}${
assetsPath
}
`
,
blobLanguage
,
currentAction
);
new
EditBlob
(
`
${
urlRoot
}${
assetsPath
}
`
,
blobLanguage
,
currentAction
,
projectId
);
new
NewCommitForm
(
editBlobForm
);
}
...
...
app/assets/javascripts/blob_edit/edit_blob.js
View file @
5a0dadf7
...
...
@@ -7,11 +7,11 @@ import { __ } from '~/locale';
import
TemplateSelectorMediator
from
'
../blob/file_template_mediator
'
;
export
default
class
EditBlob
{
constructor
(
assetsPath
,
aceMode
,
currentAction
)
{
constructor
(
assetsPath
,
aceMode
,
currentAction
,
projectId
)
{
this
.
configureAceEditor
(
aceMode
,
assetsPath
);
this
.
initModePanesAndLinks
();
this
.
initSoftWrap
();
this
.
initFileSelectors
(
currentAction
);
this
.
initFileSelectors
(
currentAction
,
projectId
);
}
configureAceEditor
(
aceMode
,
assetsPath
)
{
...
...
@@ -30,10 +30,11 @@ export default class EditBlob {
}
}
initFileSelectors
(
currentAction
)
{
initFileSelectors
(
currentAction
,
projectId
)
{
this
.
fileTemplateMediator
=
new
TemplateSelectorMediator
({
currentAction
,
editor
:
this
.
editor
,
projectId
});
}
...
...
app/assets/javascripts/ide/stores/modules/file_templates/actions.js
View file @
5a0dadf7
...
...
@@ -28,7 +28,7 @@ export const fetchTemplateTypes = ({ dispatch, state }, page = 1) => {
dispatch
(
'
requestTemplateTypes
'
);
return
Api
.
templates
(
state
.
selectedTemplateType
.
key
,
{
page
})
return
Api
.
projectTemplates
(
state
.
currentProjectId
,
state
.
selectedTemplateType
.
key
,
{
page
})
.
then
(({
data
,
headers
})
=>
{
const
nextPage
=
parseInt
(
normalizeHeaders
(
headers
)[
'
X-NEXT-PAGE
'
],
10
);
...
...
@@ -79,7 +79,7 @@ export const fetchTemplate = ({ dispatch, state }, template) => {
return
dispatch
(
'
setFileTemplate
'
,
template
);
}
return
Api
.
templates
(
`
${
state
.
selectedTemplateType
.
key
}
/
${
template
.
key
||
template
.
name
}
`
)
return
Api
.
projectTemplate
(
'
1
'
,
state
.
selectedTemplateType
.
key
,
template
.
key
||
template
.
name
)
.
then
(({
data
})
=>
{
dispatch
(
'
setFileTemplate
'
,
data
);
})
...
...
app/helpers/blob_helper.rb
View file @
5a0dadf7
...
...
@@ -191,11 +191,12 @@ module BlobHelper
@dockerfile_names
||=
template_dropdown_names
(
TemplateFinder
.
build
(
:dockerfiles
,
project
).
execute
)
end
def
blob_editor_paths
def
blob_editor_paths
(
project
=
@project
)
{
'relative-url-root'
=>
Rails
.
application
.
config
.
relative_url_root
,
'assets-prefix'
=>
Gitlab
::
Application
.
config
.
assets
.
prefix
,
'blob-language'
=>
@blob
&&
@blob
.
language
.
try
(
:ace_mode
)
'blob-language'
=>
@blob
&&
@blob
.
language
.
try
(
:ace_mode
),
'project-id'
=>
project
.
id
}
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