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
1518d4bc
Commit
1518d4bc
authored
Dec 13, 2019
by
Denys Mishunov
Committed by
Phil Hughes
Dec 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set up basic Vue app + GraphQL + Apollo
The basic Vue application with support for GraphQL and Apollo
parent
262bcdd6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
123 additions
and
1 deletion
+123
-1
app/assets/javascripts/pages/snippets/show/index.js
app/assets/javascripts/pages/snippets/show/index.js
+3
-0
app/assets/javascripts/snippets/components/app.vue
app/assets/javascripts/snippets/components/app.vue
+31
-0
app/assets/javascripts/snippets/index.js
app/assets/javascripts/snippets/index.js
+34
-0
app/assets/javascripts/snippets/queries/getSnippet.query.graphql
...ets/javascripts/snippets/queries/getSnippet.query.graphql
+13
-0
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+1
-1
spec/frontend/snippets/components/app_spec.js
spec/frontend/snippets/components/app_spec.js
+41
-0
No files found.
app/assets/javascripts/pages/snippets/show/index.js
View file @
1518d4bc
...
...
@@ -3,6 +3,7 @@ import BlobViewer from '~/blob/viewer';
import
ZenMode
from
'
~/zen_mode
'
;
import
initNotes
from
'
~/init_notes
'
;
import
snippetEmbed
from
'
~/snippet/snippet_embed
'
;
import
initSnippetsApp
from
'
~/snippets
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
if
(
!
gon
.
features
.
snippetsVue
)
{
...
...
@@ -11,5 +12,7 @@ document.addEventListener('DOMContentLoaded', () => {
initNotes
();
new
ZenMode
();
// eslint-disable-line no-new
snippetEmbed
();
}
else
{
initSnippetsApp
();
}
});
app/assets/javascripts/snippets/components/app.vue
0 → 100644
View file @
1518d4bc
<
script
>
import
getSnippet
from
'
../queries/getSnippet.query.graphql
'
;
export
default
{
apollo
:
{
snippetData
:
{
query
:
getSnippet
,
variables
()
{
return
{
ids
:
this
.
snippetGid
,
};
},
update
:
data
=>
data
.
snippets
.
edges
[
0
].
node
,
},
},
props
:
{
snippetGid
:
{
type
:
String
,
required
:
true
,
},
},
data
()
{
return
{
snippetData
:
{},
};
},
};
</
script
>
<
template
>
<div
class=
"js-snippet-view"
></div>
</
template
>
app/assets/javascripts/snippets/index.js
0 → 100644
View file @
1518d4bc
import
Vue
from
'
vue
'
;
import
Translate
from
'
~/vue_shared/translate
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
SnippetsApp
from
'
./components/app.vue
'
;
Vue
.
use
(
VueApollo
);
Vue
.
use
(
Translate
);
export
default
()
=>
{
const
el
=
document
.
getElementById
(
'
js-snippet-view
'
);
if
(
!
el
)
{
return
false
;
}
const
{
snippetGid
}
=
el
.
dataset
;
const
apolloProvider
=
new
VueApollo
({
defaultClient
:
createDefaultClient
(),
});
return
new
Vue
({
el
,
apolloProvider
,
render
(
createElement
)
{
return
createElement
(
SnippetsApp
,
{
props
:
{
snippetGid
,
},
});
},
});
};
app/assets/javascripts/snippets/queries/getSnippet.query.graphql
0 → 100644
View file @
1518d4bc
query
getSnippet
(
$ids
:
[
ID
!])
{
snippets
(
ids
:
$ids
)
{
edges
{
node
{
title
description
createdAt
updatedAt
visibility
}
}
}
}
app/views/snippets/show.html.haml
View file @
1518d4bc
...
...
@@ -5,7 +5,7 @@
-
page_title
"
#{
@snippet
.
title
}
(
#{
@snippet
.
to_reference
}
)"
,
_
(
"Snippets"
)
-
if
Feature
.
enabled?
(
:snippets_vue
)
#js-snippet-view
{
'data-qa-selector'
:
'snippet_view'
}
#js-snippet-view
{
data:
{
'qa-selector'
:
'snippet_view'
,
'snippet-gid'
:
@snippet
.
to_global_id
}
}
-
else
=
render
'shared/snippets/header'
...
...
spec/frontend/snippets/components/app_spec.js
0 → 100644
View file @
1518d4bc
import
SnippetApp
from
'
~/snippets/components/app.vue
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
describe
(
'
Snippet view app
'
,
()
=>
{
let
wrapper
;
let
snippetDataMock
;
const
localVue
=
createLocalVue
();
const
defaultProps
=
{
snippetGid
:
'
gid://gitlab/PersonalSnippet/35
'
,
};
function
createComponent
({
props
=
defaultProps
,
snippetData
=
{}
}
=
{})
{
snippetDataMock
=
jest
.
fn
();
const
$apollo
=
{
queries
:
{
snippetData
:
snippetDataMock
,
},
};
wrapper
=
shallowMount
(
SnippetApp
,
{
sync
:
false
,
mocks
:
{
$apollo
},
localVue
,
propsData
:
{
...
props
,
},
});
wrapper
.
setData
({
snippetData
,
});
}
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
renders itself
'
,
()
=>
{
createComponent
();
expect
(
wrapper
.
find
(
'
.js-snippet-view
'
).
exists
()).
toBe
(
true
);
});
});
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