diff --git a/.babelrc b/.babelrc index 41789cac..9fe4b349 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,5 @@ { "presets": ["es2015", "stage-2"], - "plugins": ["transform-runtime"], + "plugins": ["transform-runtime", "lodash"], "comments": false } diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c05e34f4..1d3cba05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,16 +23,16 @@ before_script: # This folder is cached between builds # http://docs.gitlab.com/ce/ci/yaml/README.html#cache -cache: - paths: - - node_modules/ +#cache: +# paths: +# - node_modules/ test: script: - npm install -g yarn - yarn - npm run unit - + build: script: - npm install -g yarn diff --git a/package.json b/package.json index 437ad57f..b0a95a6f 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "babel-plugin-add-module-exports": "^0.2.1", + "babel-plugin-lodash": "^3.2.11", "diff": "^3.0.1", "karma-mocha-reporter": "^2.2.1", "node-sass": "^3.10.1", diff --git a/src/App.scss b/src/App.scss index 3547f258..34c7ee74 100644 --- a/src/App.scss +++ b/src/App.scss @@ -107,6 +107,7 @@ main-router { padding: 0.6em 0 0.5em; text-align: center; font-size: 1.3em; + line-height: 24px; } .panel-footer { diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index 10f987a8..7dbbf588 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -1,4 +1,4 @@ -import { sortBy, take } from 'lodash' +import { sortBy, take, filter } from 'lodash' const Notifications = { data () { @@ -7,8 +7,30 @@ const Notifications = { } }, computed: { + notifications () { + return this.$store.state.statuses.notifications + }, + unseenNotifications () { + return filter(this.notifications, ({seen}) => !seen) + }, visibleNotifications () { - return take(sortBy(this.$store.state.statuses.notifications, ({action}) => -action.id), this.visibleNotificationCount) + // Don't know why, but sortBy([seen, -action.id]) doesn't work. + let sortedNotifications = sortBy(this.notifications, ({action}) => -action.id) + sortedNotifications = sortBy(sortedNotifications, 'seen') + return take(sortedNotifications, this.visibleNotificationCount) + }, + unseenCount () { + return this.unseenNotifications.length + } + }, + watch: { + unseenCount (count) { + this.$store.dispatch('setPageTitle', `(${count})`) + } + }, + methods: { + markAsSeen () { + this.$store.commit('markNotificationsAsSeen', this.visibleNotifications) } } } diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index 0846c27b..785cc019 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -1,13 +1,14 @@