diff options
Diffstat (limited to 'app/assets/javascripts/snippets/mixins/snippets.js')
-rw-r--r-- | app/assets/javascripts/snippets/mixins/snippets.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/assets/javascripts/snippets/mixins/snippets.js b/app/assets/javascripts/snippets/mixins/snippets.js new file mode 100644 index 00000000000..837c41cdf6b --- /dev/null +++ b/app/assets/javascripts/snippets/mixins/snippets.js @@ -0,0 +1,39 @@ +import GetSnippetQuery from '../queries/snippet.query.graphql'; + +export const getSnippetMixin = { + apollo: { + snippet: { + query: GetSnippetQuery, + variables() { + return { + ids: this.snippetGid, + }; + }, + update: data => data.snippets.edges[0]?.node, + result(res) { + if (this.onSnippetFetch) { + this.onSnippetFetch(res); + } + }, + }, + }, + props: { + snippetGid: { + type: String, + required: true, + }, + }, + data() { + return { + snippet: {}, + newSnippet: false, + }; + }, + computed: { + isLoading() { + return this.$apollo.queries.snippet.loading; + }, + }, +}; + +export default () => {}; |