diff --git a/.gitignore b/.gitignore index dec3727..29d12a4 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,10 @@ jspm_packages # Built css files *.css + +# Lock file +yarn.lock + +# Builds +/lib +/src/index.js diff --git a/README.rst b/README.rst index 2bf40f6..ff705e5 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ Setup development environment .. code-block:: bash - npm i + yarn #. Build styles @@ -32,7 +32,8 @@ Setup development environment GITLAB_URL="http://gitlab.localhost" \ GITLAB_TOKEN="personal_access_token" \ - npm start + GITLAB_GROUP_ID=1234567 \ + yarn start - ``GITLAB_URL`` is the home page for your GitLab instance diff --git a/package.json b/package.json index db7c006..7dbdf20 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ ] }, "engines": { - "node": ">=5.0 <6", - "npm": ">=3.3 <4" + "node": ">=5.0", + "npm": ">=3.3" }, "dependencies": { "react": "15.6.1", @@ -43,8 +43,8 @@ "scripts": { "clean": "rm -rf ./lib", "build": "webpack && gulp sass && cp -R ./src/resources ./lib", - "lib": "npm run clean && babel src -d lib", - "prepublish": "npm run lib", + "lib": "yarn clean && babel src -d lib", + "prepublish": "yarn lib", "start": "webpack-dev-server" } } diff --git a/src/actions/member.jsx b/src/actions/member.jsx index 23d7c71..8d3fa48 100644 --- a/src/actions/member.jsx +++ b/src/actions/member.jsx @@ -1,10 +1,11 @@ import { gitlabRequest } from './gitlabApi'; +import {GITLAB_GROUP_ID} from "../config"; export const MEMBERS_SET = 'MEMBERS_SET'; export function fetchMembers() { - return gitlabRequest('/users', {active: true, blocked: false}); + return gitlabRequest('/groups/'+GITLAB_GROUP_ID+'/members/all', {active: true, blocked: false}); } export function membersSet(data) { diff --git a/src/actions/project.jsx b/src/actions/project.jsx index 6de2047..c995690 100644 --- a/src/actions/project.jsx +++ b/src/actions/project.jsx @@ -1,10 +1,11 @@ import { gitlabRequest } from './gitlabApi'; +import {GITLAB_GROUP_ID} from "../config"; export const PROJECTS_SET = 'PROJECTS_SET'; export function fetchProjects() { - return gitlabRequest('/projects'); + return gitlabRequest('/groups/'+GITLAB_GROUP_ID+'/projects'); } export function projectsSet(data) { diff --git a/src/config.jsx b/src/config.jsx index 0528648..2ad1017 100644 --- a/src/config.jsx +++ b/src/config.jsx @@ -1,3 +1,4 @@ // Environment variables (see README and webpack.config.js) export const GITLAB_URL = __GITLAB_URL; export const GITLAB_TOKEN = __GITLAB_TOKEN; +export const GITLAB_GROUP_ID = __GITLAB_GROUP_ID; diff --git a/src/middlewares/gitlabApi.jsx b/src/middlewares/gitlabApi.jsx index 04d4d10..dea7b10 100644 --- a/src/middlewares/gitlabApi.jsx +++ b/src/middlewares/gitlabApi.jsx @@ -4,7 +4,7 @@ import { ACTIONS } from '../actions/gitlabApi'; const MAX_PER_PAGE = 100; function Deferred() { - var self = this; + let self = this; this.promise = new Promise((resolve, reject) => { self.resolve = resolve; self.reject = reject; @@ -37,7 +37,7 @@ export const isApiAction = (action) => { }; export const createGitlabApiMiddleware = (instanceUrl, accessToken) => { - return (store) => { + return (/*store*/) => { return (next) => { return (action) => { if (!isApiAction(action)) { @@ -47,7 +47,7 @@ export const createGitlabApiMiddleware = (instanceUrl, accessToken) => { let result; const { type: actionType, payload: actionPayload } = action; - if (actionType == ACTIONS.GITLAB_REQUEST) { + if (actionType === ACTIONS.GITLAB_REQUEST) { const { url, args, paginated } = actionPayload; result = fetchPart(`${instanceUrl}/api/v4/${url.replace(/^\/?/, '')}`, { ...args, diff --git a/src/reducers/members.jsx b/src/reducers/members.jsx index 516621d..a22abc3 100644 --- a/src/reducers/members.jsx +++ b/src/reducers/members.jsx @@ -4,7 +4,7 @@ import { MEMBERS_SET } from '../actions/member'; let initialState = []; export default function (state=initialState, action) { - if (action.type == MEMBERS_SET) { + if (action.type === MEMBERS_SET) { return [{ id: null, name: 'No assignee', @@ -12,6 +12,7 @@ export default function (state=initialState, action) { capacity: 0, }].concat(action.payload.data.map(member => { // TODO: find a way to store capacity in some kind of gitlab custom fields + // now bio isn't exists in member object let match = /\/capacity\s+(\d+)/.exec(member.bio); return {...member, capacity: match ? parseInt(match[1]): 30} })); diff --git a/src/robots.txt b/src/robots.txt new file mode 100644 index 0000000..77470cb --- /dev/null +++ b/src/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 64172f0..da386b2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,7 +6,8 @@ const LISTEN_HOST = env.LISTEN_HOST || 'localhost', LISTEN_PORT = env.LISTEN_PORT || 3030, GITLAB_URL = env.GITLAB_URL || 'localhost', - GITLAB_TOKEN = env.GITLAB_TOKEN || ''; + GITLAB_TOKEN = env.GITLAB_TOKEN || '', + GITLAB_GROUP_ID = env.GITLAB_GROUP_ID || ''; module.exports = { entry: './src', @@ -47,7 +48,8 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ __GITLAB_URL: JSON.stringify(GITLAB_URL), - __GITLAB_TOKEN: JSON.stringify(GITLAB_TOKEN) + __GITLAB_TOKEN: JSON.stringify(GITLAB_TOKEN), + __GITLAB_GROUP_ID: JSON.stringify(GITLAB_GROUP_ID) }) ] };