diff --git a/.taskcluster.yml b/.taskcluster.yml index 6bc48f708..b01a2f794 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -32,6 +32,17 @@ tasks: else: 'dev' else: 'dev' + backend_url: + $if: 'tasks_for == "github-push"' + then: + $if: 'event.ref == "refs/heads/testing"' + then: 'https://api.code-review.testing.moz.tools' + else: 'https://api.code-review.moz.tools' + else: + $if: 'tasks_for == "github-pull-request"' + then: 'https://api.code-review.testing.moz.tools' + else: 'https://api.code-review.moz.tools' + taskboot_image: "mozilla/taskboot:0.1.10" pip_install: "pip install --disable-pip-version-check --no-cache-dir --quiet" @@ -129,6 +140,8 @@ tasks: payload: maxRunTime: 3600 image: node:11-alpine + env: + BACKEND_URL: "${backend_url}" command: - sh - -lxce diff --git a/frontend/.neutrinorc.js b/frontend/.neutrinorc.js index 0c6bf4aca..5d104d8a9 100644 --- a/frontend/.neutrinorc.js +++ b/frontend/.neutrinorc.js @@ -2,6 +2,7 @@ fs = require('fs'); const envs = { CONFIG: process.env.CONFIG || 'staging', + BACKEND_URL: process.env.BACKEND_URL || 'http://localhost:8000', }; const PORT = process.env.PORT || 8010; // HTTPS can be disabled by setting HTTPS_DISABLED environment variable to @@ -26,7 +27,7 @@ module.exports = { '@neutrinojs/vue', { html: { - title: 'Mozilla Static Analysis' + title: 'Mozilla Code Review Bot' }, devServer: { port: PORT, diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 7025ac200..c3f37b959 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,6 +1,6 @@ { "name": "code-review-frontend", - "version": "1.0.5", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/frontend/src/App.vue b/frontend/src/App.vue index f5ac17eb4..f61a5374d 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,24 +1,9 @@ + + + + diff --git a/frontend/src/Issues.vue b/frontend/src/Issues.vue new file mode 100644 index 000000000..0da38753e --- /dev/null +++ b/frontend/src/Issues.vue @@ -0,0 +1,197 @@ + + + + + diff --git a/frontend/src/Revision.vue b/frontend/src/Revision.vue new file mode 100644 index 000000000..4a7981fa9 --- /dev/null +++ b/frontend/src/Revision.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/frontend/src/Stats.vue b/frontend/src/Stats.vue index 388a02bd0..95025f655 100644 --- a/frontend/src/Stats.vue +++ b/frontend/src/Stats.vue @@ -9,30 +9,30 @@ export default { ], data () { return { - sort: 'published' + sort: 'detected' } }, components: { Progress }, mounted () { - this.$store.dispatch('calc_stats') + this.$store.dispatch('load_stats') }, computed: { checks () { - if (!this.stats || !this.stats.loaded) { + if (!this.stats) { return null } let sortStr = (x, y) => x.toLowerCase().localeCompare(y.toLowerCase()) var sorts = { + 'repository': (x, y) => sortStr(x.repository, y.repository), 'analyzer': (x, y) => sortStr(x.analyzer, y.analyzer) || sortStr(x.check, y.check), 'check': (x, y) => sortStr(x.check, y.check), 'detected': (x, y) => y.total - x.total, 'published': (x, y) => y.publishable - x.publishable } - // Apply local sort to the checks from store - var checks = Object.values(this.stats.checks) - checks.sort(sorts[this.sort]) - return checks + // Apply local sort to the stats from store + this.stats.sort(sorts[this.sort]) + return this.stats } }, methods: { @@ -51,6 +51,9 @@ export default { + @@ -67,11 +70,9 @@ export default { + - +
+ Repository + Analyzer
{{ check.repository }} {{ check.analyzer }} - {{ check.check }} - {{ check.message }} - {{ check.check }} {{ check.total }} {{ check.publishable }} diff --git a/frontend/src/Task.vue b/frontend/src/Task.vue deleted file mode 100644 index b9b49ad1e..000000000 --- a/frontend/src/Task.vue +++ /dev/null @@ -1,223 +0,0 @@ - - - - - diff --git a/frontend/src/Tasks.vue b/frontend/src/Tasks.vue index f9f7979c3..c491e6dc7 100644 --- a/frontend/src/Tasks.vue +++ b/frontend/src/Tasks.vue @@ -5,29 +5,13 @@ import Choice from './Choice.vue' export default { mounted () { - // Load new tasks at startup - this.load_tasks() - }, - watch: { - '$route' (to, from, next) { - // Load new tasks when route change - if (to.path !== from.path) { - this.load_tasks() - } - } + this.load_tasks('production') }, methods: { - load_tasks () { - var payload = {} - - // Reset state + load_tasks (channel) { + this.$set(this, 'channel', channel) this.$store.commit('reset') - - // Load a specific revision only - if (this.$route.params.revision) { - payload['revision'] = this.$route.params.revision - } - this.$store.dispatch('load_index', payload) + this.$store.dispatch('load_index', { channel }) } }, components: { @@ -35,6 +19,7 @@ export default { }, data: function () { return { + channel: 'production', filters: { state: null, issues: null, @@ -73,7 +58,7 @@ export default { // Filter by states if (this.filters.state !== null) { - tasks = _.filter(tasks, t => t.state_full === this.filters.state.key) + tasks = _.filter(tasks, t => t.data.state === this.filters.state.key) } // Filter by issues @@ -89,22 +74,37 @@ export default { }) } - return tasks + // Sort by indexation date + return tasks.sort((x, y) => { + return new Date(y.data.indexed) - new Date(x.data.indexed) + }) }, tasks_total () { return this.$store.state.tasks ? this.$store.state.tasks.length : 0 }, states () { - return this.$store.state.states + let currentTasks = this.$store.state.tasks + const states = currentTasks.reduce((states, task) => { + if (states[task.data.state] === undefined) { + states[task.data.state] = 0 + } + states[task.data.state] += 1 + return states + }, {}) + + // Order states by their nb, and calc percents + return Object.keys(states).map(state => { + let nb = states[state] + return { + 'key': state, + 'name': state.startsWith('error.') ? 'error: ' + state.substring(6) : state, + 'nb': nb, + 'percent': currentTasks && currentTasks.length > 0 ? Math.round(nb * 100 / currentTasks.length) : 0 + } + }).sort((x, y) => { return y.nb - x.nb }) }, repositories () { - // Convert repositories set to an array - return [...this.$store.state.repositories].map(url => { - if (url.startsWith('https://hg.mozilla.org/')) { - return url.substring(23) - } - return url - }) + return [] } } } @@ -112,6 +112,10 @@ export default {