Commit d5581f4d authored by Clorichel's avatar Clorichel
Browse files

initial vue-github-api release 🎉

parent 22e7e355
Pipeline #5264647 passed with stages
in 17 minutes and 13 seconds
......@@ -28,20 +28,20 @@ npm-publish:
- rm ~/.npmrc
environment:
name: npm package
url: https://www.npmjs.com/package/vue-gitlab-api
url: https://www.npmjs.com/package/vue-github-api
only:
- master
pages:
stage: deploy
script:
- ./node_modules/.bin/jsdoc src/GitLabAPI.js
- ./node_modules/.bin/jsdoc src/GitHubAPI.js
- mv out public
artifacts:
paths:
- public
environment:
name: JSDoc API Documentation
url: https://clorichel.gitlab.io/vue-gitlab-api/
url: https://clorichel.gitlab.io/vue-github-api/
only:
- master
\ No newline at end of file
......@@ -12,61 +12,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Now able to use a callback function with full response for GET requests, or to assign data as usual
- Support for POST requests on GitLab API with custom parameters
- Ability fo use a callback function with full response for POST requests, or to assign data returned to Vue.js component data
- Made it clear using Private Token or Personal Access Token is the same
- work in progress on [clorichel/vue-gitlab-api issues](https://gitlab.com/clorichel/vue-gitlab-api/issues?scope=all&state=opened&utf8=%E2%9C%93&label_name%5B%5D=Feature)...
- work in progress on [clorichel/vue-github-api issues](https://gitlab.com/clorichel/vue-github-api/issues?scope=all&state=opened&utf8=%E2%9C%93&label_name%5B%5D=Feature)...
## 0.1.7 - 2016-10-29
## 0.1.0 - 2016-12-05
### Added
- Now able to use a callback function with full response for GET requests, or to assign data as usual
- Support for POST requests on GitLab API with custom parameters
- Ability fo use a callback function with full response for POST requests, or to assign data returned to Vue.js component data
- Made it clear using Private Token or Personal Access Token is the same
- Initial port starting from clorichel/vue-gitlab-api@019f3f28a64b80b13a63e84c12e4955dbbb2683d
- Support to consume GitHub API
## 0.1.6 - 2016-10-26
### Added
- Vuex store module provides downloading state (Boolean) and total number or running requests
- Using Vuex? You can now register your application Vuex store to improve it with GitLabAPI Vuex store module
## 0.1.5 - 2016-10-26
### Added
- Improved Readme and example with changed behavior
- Filling in the reactive data property now uses stock Vue.set
- Error messages on API request is now much readable
### Changed
- Reactive data to fill in do no more have to be an empty array, but an empty object
## 0.1.4 - 2016-10-25
### Added
- One can now send in a callback function to customize behavior on requests errors
## 0.1.3 - 2016-10-25
### Fixed
- Library dist file is now built to make it usable
## 0.1.2 - 2016-10-25
### Added
- Readme now gives credit for the chosen logo
### Fixed
- Ensured that dist folder is deployed with npm package
## 0.1.1 - 2016-10-25
### Added
- Just bumped version to npm publish again
## 0.1.0 - 2016-10-25
### Added
- This CHANGELOG file to hopefully serve as an evolving example of a standardized open source project CHANGELOG
- README describes main topics to get started
- Now published as the vue-gitlab-api NPM package to simplify installing and using
- Support for GET requests on GitLab API with custom parameters, assigning data returned to Vue.js component data
- Library supports setting GitLab instance URL and user Private Token after booting
- GitLabAPI.js has been created as a Vue.js plugin
- A DevTest vue has been created for developers convenience
- Initial vue-cli scaffolding on webpack template with unit tests
[Unreleased]: https://gitlab.com/clorichel/vue-gitlab-api/compare/v0.1.7...master
\ No newline at end of file
[Unreleased]: https://gitlab.com/clorichel/vue-github-api/compare/v0.1.0...master
\ No newline at end of file
# vue-gitlab-api
# vue-github-api
A deadly simple Vue.js plugin to consume GitLab API.
A deadly simple Vue.js plugin to consume GitHub API.
Head to [the extensive JSDoc API documentation for vue-gitlab-api](https://clorichel.gitlab.io/vue-gitlab-api/Vue_GitLabAPI.html), or keep on reading for an easy process to integrate it in your application.
Head to [the extensive JSDoc API documentation for vue-github-api](https://clorichel.gitlab.io/vue-github-api/Vue_GitHubAPI.html), or keep on reading for an easy process to integrate it in your application.
## Using it
### Install and import
```bash
npm install vue-gitlab-api
npm install vue-github-api
```
In your main application JS file (typically `main.js` if you are using [vue-cli](https://github.com/vuejs/vue-cli) webpack template), simply use the plugin:
......@@ -19,40 +19,39 @@ In your main application JS file (typically `main.js` if you are using [vue-cli]
import VueResource from 'vue-resource'
Vue.use(VueResource)
// import vue-gitlab-api
import GitLabAPI from 'vue-gitlab-api'
Vue.use(GitLabAPI, { url: 'https://gitlab.com', token: 'user Private Token or Personal Access Token' })
// import vue-github-api
import GitHubAPI from 'vue-github-api'
Vue.use(GitHubAPI, { token: 'user Personal Access Token' })
```
You can configure _application wide_ options while `Vue.use`'ing this plugin:
| Name | Description |
|---------|---------------------------------------------------------------------------------------|
| `url` | your GitLab instance URL (defaults to https://gitlab.com) |
| `token` | your GitLab user _Private Token_ or _Personal Access Token_ use to connect to the API |
| Name | Description |
|---------|-----------------------------------------------------------------------|
| `token` | one of your GitHub user _Personal Access Token_ to connect to the API |
### Consume GitLab API
### Consume GitHub API
From anywhere now, you can simply consume GitLab API:
From anywhere now, you can simply consume GitHub API:
```javascript
Vue.GitLabAPI.get('/projects', {}, [this.myGitLabData, 'projects'])
Vue.GitHubAPI.get('/projects', {}, [this.myGitHubData, 'projects'])
```
You can also use it in your `.vue` components with `this.GitLabAPI`:
You can also use it in your `.vue` components with `this.GitHubAPI`:
```javascript
this.GitLabAPI.get('/projects', {}, [this.myGitLabData, 'projects'])
this.GitHubAPI.get('/projects', {}, [this.myGitHubData, 'projects'])
```
That was it! Now that you are bootstrapped in, have a look at all the methods available to you in the extensive JSDoc API documentation available on [these auto-generated GitLab Pages](https://clorichel.gitlab.io/vue-gitlab-api/Vue_GitLabAPI.html).
That was it! Now that you are bootstrapped in, have a look at all the methods available to you in the extensive JSDoc API documentation available on [these auto-generated GitLab Pages](https://clorichel.gitlab.io/vue-github-api/Vue_GitHubAPI.html).
**Important:** if you want your filled-in property `this.myGitLabData.projects` to be reactive "the Vue.js way", you MUST define this variable as a data in your components or vues, with a default value of an empty object (read `myGitLabData: {}`). See how to do it on a vue component on this example:
**Important:** if you want your filled-in property `this.myGitHubData.projects` to be reactive "the Vue.js way", you MUST define this variable as a data in your components or vues, with a default value of an empty object (read `myGitHubData: {}`). See how to do it on a vue component on this example:
```javascript
<template>
<div>
<p>Projects grabbed: {{ projectsCount }}</p>
<p>Repositories grabbed: {{ repositoriesCount }}</p>
</div>
</template>
......@@ -60,16 +59,16 @@ That was it! Now that you are bootstrapped in, have a look at all the methods av
export default {
data () {
return {
myGitLabData: {}
myGitHubData: {}
}
},
mounted: function () {
this.GitLabAPI.get('projects', {}, [this.myGitLabData, 'projects'])
this.GitHubAPI.get('/user/repos', {}, [this.myGitHubData, 'repositories'])
},
computed: {
projectsCount: function () {
if (this.myGitLabData.projects) {
return this.myGitLabData.projects.length
repositoriesCount: function () {
if (this.myGitHubData.repositories) {
return this.myGitHubData.repositories.length
}
return 'none yet...'
}
......@@ -80,34 +79,31 @@ export default {
This is due to the fact Vue does not allow to add new reactive properties dynamically. Read more about it on the awesome [Vue.js guide](http://vuejs.org/guide/reactivity.html#Change-Detection-Caveats).
During your application workflow, you could want to change GitLab instance URL, and/or user authentication token. These methods will let you do it easily:
During your application workflow, you could want to change GitHub user authentication token. This method will let you do it easily:
```javascript
// set application wide GitLabAPI url value
this.GitLabAPI.setUrl('https://your.gitlab-instance.com')
// set application wide GitLabAPI token value
this.GitLabAPI.setToken('other user Private Token or Personal Access Token')
// set application wide GitHubAPI token value
this.GitHubAPI.setToken('other user Personal Access Token')
```
## Vuex store module
Using Vuex? You can attach _vue-gitlab-api_ Vuex module to your application store. Within one of your `.vue` components, simply register it before you using it from your application:
Using Vuex? You can attach _vue-github-api_ Vuex module to your application store. Within one of your `.vue` components, simply register it before you using it from your application:
```javascript
// registers GitLabAPI Vuex module to your application Vuex store
this.GitLabAPI.registerStore(this.$store)
// registers GitHubAPI Vuex module to your application Vuex store
this.GitHubAPI.registerStore(this.$store)
// you are now able to read this state
this.$store.state.GitLabAPI.downloading
this.$store.state.GitHubAPI.downloading
```
Here are Vuex `states` provided by _vue-gitlab-api_ to your application:
Here are Vuex `states` provided by _vue-github-api_ to your application:
| Vuex state | Type | Description |
|---------------|---------|----------------------------------------------------|
| `downloading` | Boolean | Defines if vue-gitlab-api is currently downloading |
| `running` | Number | Count vue-gitlab-api requests running now |
| `downloading` | Boolean | Defines if vue-github-api is currently downloading |
| `running` | Number | Count vue-github-api requests running now |
Have a look at [Vuex](https://github.com/vuejs/vuex) for more details, or read on this complete example:
......@@ -118,13 +114,13 @@ import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
// remember vue-resource is needed for vue-gitlab-api
// remember vue-resource is needed for vue-github-api
import VueResource from 'vue-resource'
Vue.use(VueResource)
// using vue-gitlab-api
import GitLabAPI from 'vue-gitlab-api'
Vue.use(GitLabAPI, { url: 'https://gitlab.com', token: 'user Private Token' })
// using vue-github-api
import GitHubAPI from 'vue-github-api'
Vue.use(GitHubAPI, { token: 'user Private Token' })
// declare your Vuex store
const store = new Vuex.Store({})
......@@ -133,15 +129,15 @@ const store = new Vuex.Store({})
const app = new Vue({
el: '#app',
mounted: {
// register GitLabAPI Vuex store!
this.GitLabAPI.registerStore(store)
// register GitHubAPI Vuex store!
this.GitHubAPI.registerStore(store)
},
computed: {
// with this computed property, do something insanely simple such as:
// <p v-if="downloading">Downloading from GitLab...</p>
// <p v-if="downloading">Downloading from GitHub...</p>
downloading: function () {
if (typeof store.state.GitLabAPI !== 'undefined') {
return store.state.GitLabAPI.downloading
if (typeof store.state.GitHubAPI !== 'undefined') {
return store.state.GitHubAPI.downloading
} else {
return false
}
......@@ -154,7 +150,7 @@ const app = new Vue({
Initial scaffolding was done with [vue-cli](https://github.com/vuejs/vue-cli) webpack template. For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
Simply said, one can start working on its own customized version of _vue-gitlab-api_ in no time:
Simply said, one can start working on its own customized version of _vue-github-api_ in no time:
``` bash
# install dependencies
......@@ -164,7 +160,7 @@ npm install
npm run unit
# build JSDoc API documentation (defaults to the ./out folder)
./node_modules/.bin/jsdoc src/GitLabAPI.js
./node_modules/.bin/jsdoc src/GitHubAPI.js
# serve with hot reload at localhost:8080
npm run dev
......@@ -172,13 +168,13 @@ npm run dev
## What's next?
Without any obligation nor due date, one could expect to be done this non-exhaustive [list of improvements grouped on issues labeled `Feature`](https://gitlab.com/clorichel/vue-gitlab-api/issues?scope=all&state=opened&utf8=%E2%9C%93&label_name%5B%5D=Feature).
Without any obligation nor due date, one could expect to be done this non-exhaustive [list of improvements grouped on issues labeled `Feature`](https://gitlab.com/clorichel/vue-github-api/issues?scope=all&state=opened&utf8=%E2%9C%93&label_name%5B%5D=Feature).
You can read on the [Changelog](CHANGELOG.md) too, for historical and upcoming new features, changes, deprecations, removed features, bug and security fixes.
## Support
Your are free to [open an issue](https://gitlab.com/clorichel/vue-gitlab-api/issues/new) right in this GitLab repository whether you should be facing a problem or a bug. Please advise this is not a commercial product, so one could experience random response time. Positive, friendly and productive conversations are expected on the issues. Screenshots and steps to reproduce are highly appreciated. Chances are you may get your issue solved if you follow these simple guidelines.
Your are free to [open an issue](https://gitlab.com/clorichel/vue-github-api/issues/new) right in this GitLab repository whether you should be facing a problem or a bug. Please advise this is not a commercial product, so one could experience random response time. Positive, friendly and productive conversations are expected on the issues. Screenshots and steps to reproduce are highly appreciated. Chances are you may get your issue solved if you follow these simple guidelines.
## Credits
......@@ -187,4 +183,4 @@ Your are free to [open an issue](https://gitlab.com/clorichel/vue-gitlab-api/iss
## License
The _vue-gitlab-api_ plugin is distributed under the [MIT License (MIT)](LICENSE). Please have a look at the dependencies licenses if you plan on using, building, or distributing this plugin.
\ No newline at end of file
The _vue-github-api_ plugin is distributed under the [MIT License (MIT)](LICENSE). Please have a look at the dependencies licenses if you plan on using, building, or distributing this plugin.
\ No newline at end of file
......@@ -15,11 +15,11 @@ var webpackConfig = merge(baseWebpackConfig, {
loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true })
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
entry: './src/GitLabAPI.js',
entry: './src/GitHubAPI.js',
output: {
path: config.build.assetsRoot,
filename: 'vue-gitlab-api.js',
library: 'GitLabAPI',
filename: 'vue-github-api.js',
library: 'GitHubAPI',
libraryTarget: 'umd'
},
vue: {
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<title>vue-gitlab-api</title>
<title>vue-github-api</title>
</head>
<body>
<div id="app"></div>
......
{
"name": "vue-gitlab-api",
"version": "0.1.7",
"description": "A deadly simple Vue.js plugin to consume GitLab API.",
"name": "vue-github-api",
"version": "0.1.0",
"description": "A deadly simple Vue.js plugin to consume GitHub API.",
"author": "clorichel <contact@clorichel.com>",
"homepage": "https://gitlab.com/clorichel/vue-gitlab-api",
"homepage": "https://gitlab.com/clorichel/vue-github-api",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/clorichel/vue-gitlab-api/issues"
"url": "https://gitlab.com/clorichel/vue-github-api/issues"
},
"repository": {
"type": "git",
"url": "https://gitlab.com/clorichel/vue-gitlab-api.git"
"url": "https://gitlab.com/clorichel/vue-github-api.git"
},
"keywords": [
"vue",
"vue-resource",
"gitlab",
"github",
"api"
],
"scripts": {
......@@ -25,7 +25,7 @@
"test": "npm run unit",
"lint": "eslint --ext .js,.vue src test/unit/specs"
},
"main": "dist/vue-gitlab-api.js",
"main": "dist/vue-github-api.js",
"dependencies": {
"vue": "^2.0.1",
"vue-resource": "^1.0.3"
......
(function () {
function install (Vue, options) {
// default GitLab instance url, without trailing slash
var url = 'https://gitlab.com'
// GitLab user Private Token or Personal Access Token
// GitHub user Private Token or Personal Access Token
var token = 'you MUST provide an user Private Token or Personal Access Token'
// reading options
if (typeof options !== 'undefined') {
// a token is mandatory to connect to GitLab API,
// a token is mandatory to connect to GitHub API,
// but it could be set later with .setToken
if (typeof options.token !== 'undefined') {
token = options.token
}
// an url may not be mandatory if user runs GitLab from localhost
if (typeof options.url !== 'undefined') {
// sanitizing url coming from options with no trailing slash
url = options.url.replace(/\/$/, '')
}
}
// GitLab API full url
var apiUrl = url + '/api/v3'
// GitHub API full url
var apiUrl = 'https://api.github.com'
// adding an instance method by attaching it to Vue.prototype
/**
* A deadly simple Vue.js plugin to consume GitLab API.
* A deadly simple Vue.js plugin to consume GitHub API.
*
* @mixin
* @author {@link http://clorichel.com Pierre-Alexandre Clorichel}
* @license {@link https://gitlab.com/clorichel/vue-gitlab-api/blob/master/LICENSE MIT License}
* @see {@link https://gitlab.com/clorichel/vue-gitlab-api Project repository on GitLab.com}
* @license {@link https://gitlab.com/clorichel/vue-github-api/blob/master/LICENSE MIT License}
* @see {@link https://gitlab.com/clorichel/vue-github-api Project repository on GitLab.com}
* @see {@link http://clorichel.com http://clorichel.com}
*/
Vue.prototype.GitLabAPI = {
/**
* Set application wide GitLabAPI url value
* @param {String} newUrl The new GitLab URL value
* @example
* // from anywhere in the global Vue scope
* Vue.GitLabAPI.setUrl('https://your.gitlab-instance.com')
*
* // from a .vue component
* this.GitLabAPI.setUrl('https://your.gitlab-instance.com')
*/
setUrl: function (newUrl) {
// sanitizing url with no trailing slash
if (typeof newUrl === 'undefined') {
console.warn('[vue-gitlab-api] This GitLab instance URL may not be correct')
url = ''
} else {
url = newUrl.replace(/\/$/, '')
}
apiUrl = url + '/api/v3'
},
Vue.prototype.GitHubAPI = {
/**
* Set application wide GitLabAPI token value
* Set application wide GitHubAPI token value
* @param {String} newToken The new token value
* @example
* // from anywhere in the global Vue scope
* Vue.GitLabAPI.setToken('your user token')
* Vue.GitHubAPI.setToken('your user token')
*
* // from a .vue component
* this.GitLabAPI.setToken('your user token')
* this.GitHubAPI.setToken('your user token')
*/
setToken: function (newToken) {
if (typeof newToken === 'undefined' || newToken == null || newToken === '') {
console.error('[vue-gitlab-api] You MUST provide a non empty Private Token or Personal Access Token')
console.error('[vue-github-api] You MUST provide a non empty Private Token or Personal Access Token')
return
}
token = newToken
......@@ -77,41 +48,41 @@
* A request callback function.
*
* @callback requestCallback
* @param {Object} response Full response from GitLab API
* @param {Object} response Full response from GitHub API
*/
/**
* A request error callback function.
*
* @callback errorCallback
* @param {Object} response Full response from GitLab API
* @param {Object} response Full response from GitHub API
*/
/**
* Issue a GET request on 'GitLabAPI_url/api/v3' with params and a variable to fill in
* @param {String} uri The GitLab API uri to consume such as '/projects'
* Issue a GET request on 'https://api.github.com' with params and a variable to fill in
* @param {String} uri The GitHub API uri to consume such as '/user/repos'
* @param {Object} params A parameters object such as { 'project_id': 72 }
* @param {(Array|requestCallback)} fillIn The Vue.js defined data to fill in with results from GitLab API, or a callback function fed with full response
* @param {(Array|requestCallback)} fillIn The Vue.js defined data to fill in with results from GitHub API, or a callback function fed with full response
* @param {errorCallback} errorCb A callback function in case of error (response is passed to callback)
* @example
* // -------------------------------------------------
* // 1- With an array to fill in a Vue.js defined data
* // -------------------------------------------------
* // from anywhere in the global Vue scope
* Vue.GitLabAPI.get('/projects', {}, [this.myGitLabData, 'projects'])
* Vue.GitHubAPI.get('/user/repos', {}, [this.myGitHubData, 'repositories'])
* // from a .vue component
* this.GitLabAPI.get('/projects', {}, [this.myGitLabData, 'projects'])
* this.GitHubAPI.get('/user/repos', {}, [this.myGitHubData, 'repositories'])
*
*
* // ----------------------------------------------------------
* // 2- With a callback function to play with the full response
* // ----------------------------------------------------------
* // from anywhere in the global Vue scope
* Vue.GitLabAPI.get('/projects', {}, (response) => {
* Vue.GitHubAPI.get('/user/repos', {}, (response) => {
* console.log('got response:', response)
* })
* // from a .vue component
* this.GitLabAPI.get('/projects', {}, (response) => {
* this.GitHubAPI.get('/user/repos', {}, (response) => {
* console.log('got response:', response)
* })
*/
......@@ -132,7 +103,7 @@
apiUrl + uri,
{
headers: {
'PRIVATE-TOKEN': token
'Authorization': 'token ' + token
},
params: params
}
......@@ -156,26 +127,26 @@
errorCb(response)
} else {
// no errorCb function defined, default to console error
console.error('[vue-gitlab-api] GET ' + uri + ' failed: "' + response.body.message + '" on ' + apiUrl + ' (using token "' + token + '")')
console.error('[vue-github-api] GET ' + uri + ' failed: "' + response.body.message + '" on ' + apiUrl + ' (using token "' + token + '")')
}
})
},
/**
* Issue a POST request on 'GitLabAPI_url/api/v3' with params and a variable to fill in
* @param {String} uri The GitLab API uri to consume such as '/projects'
* Issue a POST request on 'https://api.github.com' with params and a variable to fill in
* @param {String} uri The GitHub API uri to consume such as '/user/repos'
* @param {Object} params A parameters object such as { 'project_id': 72 }
* @param {(Array|requestCallback)} fillIn The Vue.js defined data to fill in with results from GitLab API, or a callback function fed with full response
* @param {(Array|requestCallback)} fillIn The Vue.js defined data to fill in with results from GitHub API, or a callback function fed with full response
* @param {errorCallback} errorCb A callback function in case of error (response is passed to callback)
* @example
* // from anywhere in the global Vue scope
* Vue.GitLabAPI.post('/projects/YOUR_PROJECT_ID/issues', {
* title: 'My new issues from vue-gitlab-api'
* Vue.GitHubAPI.post('/repos/OWNER_NAME/REPO_NAME/issues', {
* title: 'My new issues from vue-github-api'
* }, (response) => { console.log('posted it!', response) })
*
* // from a .vue component
* this.GitLabAPI.post('/projects/YOUR_PROJECT_ID/issues', {
* title: 'My new issues from vue-gitlab-api'
* this.GitHubAPI.post('/repos/OWNER_NAME/REPO_NAME/issues', {
* title: 'My new issues from vue-github-api'
* }, (response) => { console.log('posted it!', response) })
*/
post: function (uri, params, fillIn, errorCb) {
......@@ -196,7 +167,7 @@
params,
{
headers: {
'PRIVATE-TOKEN': token
'Authorization': 'token ' + token
}
}
).then((response) => {
......@@ -219,28 +190,28 @@
errorCb(response)
} else {
// no errorCb function defined, default to console error
console.error('[vue-gitlab-api] POST ' + uri + ' failed: "' + response.body.message + '" on ' + apiUrl + ' (using token "' + token + '")')
console.error('[vue-github-api] POST ' + uri + ' failed: "' + response.body.message + '" on ' + apiUrl + ' (using token "' + token + '")')
}
})
},
/**
* Register your application Vuex store to improve it with GitLabAPI Vuex store module
* Register your application Vuex store to improve it with GitHubAPI Vuex store module
* @param {Object} store Your application Vuex store
* @example
* // from within a .vue component
* this.GitLabAPI.registerStore(this.$store)
* this.GitHubAPI.registerStore(this.$store)
*/
registerStore: function (store) {
if (typeof store === 'undefined') {
console.error('[vue-gitlab-api] This do not appear to be a Vuex store')
console.error('[vue-github-api] This do not appear to be a Vuex store')
return
}
// registering GitLabAPI Vuex module
store.registerModule('GitLabAPI', {
// registering GitHubAPI Vuex module
store.registerModule('GitHubAPI', {
state: {
// is GitLabAPI currently downloading?
// is GitHubAPI currently downloading?
downloading: false,
// how many downloads are running
running: 0
......@@ -285,7 +256,7 @@
/**
* Verifying what to fill in from API consuming functions
* @param {(Array|requestCallback)} fillIn The Vue.js defined data to fill in with results from GitLab API, or a callback function fed with full response
* @param {(Array|requestCallback)} fillIn The Vue.js defined data to fill in with results from GitHub API, or a callback function fed with full response
* @return {Boolean} True if the fillIn type is ok, false (with a console error) if not
* @private
*/
......@@ -295,16 +266,16 @@
// variable to fill in MUST be defined, as a Vue data (to be reactive),
// and user MUST provide the key to fill in within that data, examples:
// - [this.dataPropertyName, 'keyToFillDataIn']
// - [this.GitLab, 'projects']
// - [this.GitHub, 'repositories']
if (!(fillIn instanceof Array) || fillIn.length < 2) {
console.error('[vue-gitlab-api] You MUST define the Vue data you want to fill as a two values array')
console.error('[vue-github-api] You MUST define the Vue data you want to fill as a two values array')
return false
}
// ensure reactive data is not an array but an object, or Vue.set will
// fail in indexing the data to the expected key
if (Array.isArray(fillIn[0]) || typeof fillIn[0] !== 'object') {
console.error('[vue-gitlab-api] Your Vue data to fill MUST be an object (ie `{}`)')
console.error('[vue-github-api] Your Vue data to fill MUST be an object (ie `{}`)')
return false
}
}
......