summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/snippets
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 18:08:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 18:08:06 +0000
commit7cc6c10c68915f5019ab8c2029eeb462c8fed4ef (patch)
tree419e5fee5bb60e71bef076157627812d54e142bc /app/assets/javascripts/snippets
parent630101f7f93847f39a4d2f87d92f514c973cdc1e (diff)
downloadgitlab-ce-7cc6c10c68915f5019ab8c2029eeb462c8fed4ef.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/snippets')
-rw-r--r--app/assets/javascripts/snippets/components/app.vue31
-rw-r--r--app/assets/javascripts/snippets/index.js34
-rw-r--r--app/assets/javascripts/snippets/queries/getSnippet.query.graphql13
3 files changed, 78 insertions, 0 deletions
diff --git a/app/assets/javascripts/snippets/components/app.vue b/app/assets/javascripts/snippets/components/app.vue
new file mode 100644
index 00000000000..e3d6cdd4606
--- /dev/null
+++ b/app/assets/javascripts/snippets/components/app.vue
@@ -0,0 +1,31 @@
+<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>
diff --git a/app/assets/javascripts/snippets/index.js b/app/assets/javascripts/snippets/index.js
new file mode 100644
index 00000000000..654856f8d14
--- /dev/null
+++ b/app/assets/javascripts/snippets/index.js
@@ -0,0 +1,34 @@
+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,
+ },
+ });
+ },
+ });
+};
diff --git a/app/assets/javascripts/snippets/queries/getSnippet.query.graphql b/app/assets/javascripts/snippets/queries/getSnippet.query.graphql
new file mode 100644
index 00000000000..5a5f0d05c5b
--- /dev/null
+++ b/app/assets/javascripts/snippets/queries/getSnippet.query.graphql
@@ -0,0 +1,13 @@
+query getSnippet($ids: [ID!]) {
+ snippets(ids: $ids) {
+ edges {
+ node {
+ title
+ description
+ createdAt
+ updatedAt
+ visibility
+ }
+ }
+ }
+}