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
c3168a3f
Commit
c3168a3f
authored
Oct 02, 2020
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'ntepluhina-graphql-startup-js-2' into 'master'"
This reverts merge request !36324
parent
9c885651
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
107 deletions
+15
-107
app/assets/javascripts/repository/index.js
app/assets/javascripts/repository/index.js
+14
-42
app/assets/javascripts/repository/queries/path_last_commit.query.graphql
...scripts/repository/queries/path_last_commit.query.graphql
+0
-9
app/helpers/startupjs_helper.rb
app/helpers/startupjs_helper.rb
+0
-13
app/views/layouts/_startup_js.html.haml
app/views/layouts/_startup_js.html.haml
+1
-21
app/views/projects/tree/show.html.haml
app/views/projects/tree/show.html.haml
+0
-2
spec/helpers/startupjs_helper_spec.rb
spec/helpers/startupjs_helper_spec.rb
+0
-20
No files found.
app/assets/javascripts/repository/index.js
View file @
c3168a3f
...
@@ -12,17 +12,12 @@ import { setTitle } from './utils/title';
...
@@ -12,17 +12,12 @@ import { setTitle } from './utils/title';
import
{
updateFormAction
}
from
'
./utils/dom
'
;
import
{
updateFormAction
}
from
'
./utils/dom
'
;
import
{
convertObjectPropsToCamelCase
,
parseBoolean
}
from
'
../lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
,
parseBoolean
}
from
'
../lib/utils/common_utils
'
;
import
{
__
}
from
'
../locale
'
;
import
{
__
}
from
'
../locale
'
;
import
PathLastCommitQuery
from
'
./queries/path_last_commit.query.graphql
'
;
export
default
function
setupVueRepositoryList
()
{
export
default
function
setupVueRepositoryList
()
{
const
el
=
document
.
getElementById
(
'
js-tree-list
'
);
const
el
=
document
.
getElementById
(
'
js-tree-list
'
);
const
{
dataset
}
=
el
;
const
{
dataset
}
=
el
;
const
{
projectPath
,
projectShortPath
,
ref
,
escapedRef
,
fullName
}
=
dataset
;
const
{
projectPath
,
projectShortPath
,
ref
,
escapedRef
,
fullName
}
=
dataset
;
const
router
=
createRouter
(
projectPath
,
escapedRef
);
const
router
=
createRouter
(
projectPath
,
escapedRef
);
const
pathRegex
=
/-
\/
tree
\/[^/]
+
\/(
.+$
)
/
;
const
matches
=
window
.
location
.
href
.
match
(
pathRegex
);
const
currentRoutePath
=
matches
?
matches
[
1
]
:
''
;
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeData
({
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeData
({
data
:
{
data
:
{
...
@@ -34,43 +29,6 @@ export default function setupVueRepositoryList() {
...
@@ -34,43 +29,6 @@ export default function setupVueRepositoryList() {
},
},
});
});
const
initLastCommitApp
=
()
=>
new
Vue
({
el
:
document
.
getElementById
(
'
js-last-commit
'
),
router
,
apolloProvider
,
render
(
h
)
{
return
h
(
LastCommit
,
{
props
:
{
currentPath
:
this
.
$route
.
params
.
path
,
},
});
},
});
if
(
window
.
gl
.
startup_graphql_calls
)
{
const
query
=
window
.
gl
.
startup_graphql_calls
.
find
(
call
=>
call
.
operationName
===
'
pathLastCommit
'
,
);
query
.
fetchCall
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
{
apolloProvider
.
clients
.
defaultClient
.
writeQuery
({
query
:
PathLastCommitQuery
,
data
:
res
.
data
,
variables
:
{
projectPath
,
ref
,
path
:
currentRoutePath
,
},
});
})
.
catch
(()
=>
{})
.
finally
(()
=>
initLastCommitApp
());
}
else
{
initLastCommitApp
();
}
router
.
afterEach
(({
params
:
{
path
}
})
=>
{
router
.
afterEach
(({
params
:
{
path
}
})
=>
{
setTitle
(
path
,
ref
,
fullName
);
setTitle
(
path
,
ref
,
fullName
);
});
});
...
@@ -119,6 +77,20 @@ export default function setupVueRepositoryList() {
...
@@ -119,6 +77,20 @@ export default function setupVueRepositoryList() {
});
});
}
}
// eslint-disable-next-line no-new
new
Vue
({
el
:
document
.
getElementById
(
'
js-last-commit
'
),
router
,
apolloProvider
,
render
(
h
)
{
return
h
(
LastCommit
,
{
props
:
{
currentPath
:
this
.
$route
.
params
.
path
,
},
});
},
});
const
treeHistoryLinkEl
=
document
.
getElementById
(
'
js-tree-history-link
'
);
const
treeHistoryLinkEl
=
document
.
getElementById
(
'
js-tree-history-link
'
);
const
{
historyLink
}
=
treeHistoryLinkEl
.
dataset
;
const
{
historyLink
}
=
treeHistoryLinkEl
.
dataset
;
...
...
app/assets/javascripts/repository/queries/path_last_commit.query.graphql
View file @
c3168a3f
query
pathLastCommit
(
$projectPath
:
ID
!,
$path
:
String
,
$ref
:
String
!)
{
query
pathLastCommit
(
$projectPath
:
ID
!,
$path
:
String
,
$ref
:
String
!)
{
project
(
fullPath
:
$projectPath
)
{
project
(
fullPath
:
$projectPath
)
{
__typename
repository
{
repository
{
__typename
tree
(
path
:
$path
,
ref
:
$ref
)
{
tree
(
path
:
$path
,
ref
:
$ref
)
{
__typename
lastCommit
{
lastCommit
{
__typename
sha
sha
title
title
titleHtml
titleHtml
...
@@ -17,20 +13,15 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
...
@@ -17,20 +13,15 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
authorName
authorName
authorGravatar
authorGravatar
author
{
author
{
__typename
name
name
avatarUrl
avatarUrl
webPath
webPath
}
}
signatureHtml
signatureHtml
pipelines
(
ref
:
$ref
,
first
:
1
)
{
pipelines
(
ref
:
$ref
,
first
:
1
)
{
__typename
edges
{
edges
{
__typename
node
{
node
{
__typename
detailedStatus
{
detailedStatus
{
__typename
detailsPath
detailsPath
icon
icon
tooltip
tooltip
...
...
app/helpers/startupjs_helper.rb
deleted
100644 → 0
View file @
9c885651
# frozen_string_literal: true
module
StartupjsHelper
def
page_startup_graphql_calls
@graphql_startup_calls
end
def
add_page_startup_graphql_call
(
query
,
variables
=
{})
@graphql_startup_calls
||=
[]
query_str
=
File
.
read
(
File
.
join
(
Rails
.
root
,
"app/assets/javascripts/
#{
query
}
.query.graphql"
))
@graphql_startup_calls
<<
{
query:
query_str
,
variables:
variables
}
end
end
app/views/layouts/_startup_js.html.haml
View file @
c3168a3f
-
return
unless
page_startup_api_calls
.
present?
||
page_startup_graphql_calls
.
present?
-
return
unless
page_startup_api_calls
.
present?
=
javascript_tag
nonce:
true
do
=
javascript_tag
nonce:
true
do
:plain
:plain
var gl = window.gl || {};
var gl = window.gl || {};
gl.startup_calls =
#{
page_startup_api_calls
.
to_json
}
;
gl.startup_calls =
#{
page_startup_api_calls
.
to_json
}
;
gl.startup_graphql_calls =
#{
page_startup_graphql_calls
.
to_json
}
;
if (gl.startup_calls && window.fetch) {
if (gl.startup_calls && window.fetch) {
Object.keys(gl.startup_calls).forEach(apiCall => {
Object.keys(gl.startup_calls).forEach(apiCall => {
// fetch won’t send cookies in older browsers, unless you set the credentials init option.
// fetch won’t send cookies in older browsers, unless you set the credentials init option.
...
@@ -16,21 +14,3 @@
...
@@ -16,21 +14,3 @@
};
};
});
});
}
}
if (gl.startup_graphql_calls && window.fetch) {
const url = `
#{
api_graphql_url
}
`
const opts = {
method: "POST",
headers: { "Content-Type": "application/json", 'X-CSRF-Token': "
#{
form_authenticity_token
}
" },
};
gl.startup_graphql_calls = gl.startup_graphql_calls.map(call => ({
operationName: call.query.match(/^query (.+)\(/)[1],
fetchCall: fetch(url, {
...opts,
credentials: 'same-origin',
body: JSON.stringify(call)
})
}))
}
app/views/projects/tree/show.html.haml
View file @
c3168a3f
-
current_route_path
=
request
.
fullpath
.
match
(
/-\/tree\/[^\/]+\/(.+$)/
).
to_a
[
1
]
-
add_page_startup_graphql_call
(
'repository/queries/path_last_commit'
,
{
projectPath:
@project
.
full_path
,
ref:
current_ref
,
currentRoutePath:
current_route_path
})
-
breadcrumb_title
_
(
"Repository"
)
-
breadcrumb_title
_
(
"Repository"
)
-
@content_class
=
"limit-container-width"
unless
fluid_layout
-
@content_class
=
"limit-container-width"
unless
fluid_layout
...
...
spec/helpers/startupjs_helper_spec.rb
deleted
100644 → 0
View file @
9c885651
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
StartupjsHelper
do
describe
'#page_startup_graphql_calls'
do
let
(
:query_location
)
{
'repository/queries/path_last_commit'
}
let
(
:query_content
)
do
File
.
read
(
File
.
join
(
Rails
.
root
,
'app/assets/javascripts'
,
"
#{
query_location
}
.query.graphql"
))
end
it
'returns an array containing GraphQL Page Startup Calls'
do
helper
.
add_page_startup_graphql_call
(
query_location
,
{
ref:
'foo'
})
startup_graphql_calls
=
helper
.
page_startup_graphql_calls
expect
(
startup_graphql_calls
).
to
include
({
query:
query_content
,
variables:
{
ref:
'foo'
}
})
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