Skip to content

Commit ca7d085

Browse files
authored
Merge pull request #331 from Human-Connection/develop
Update Master and fix several issues
2 parents 7a04080 + 394707b commit ca7d085

File tree

20 files changed

+1227
-199
lines changed

20 files changed

+1227
-199
lines changed

.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"env": {
3+
"test": {
4+
"plugins": ["transform-object-rest-spread"],
5+
"presets": [
6+
["env", { "targets": { "node": "current" }}]
7+
]
8+
}
9+
}
10+
}
11+

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
sourceType: 'module'
77
},
88
env: {
9+
jest: true,
910
browser: true,
1011
node: true
1112
},

.travis.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,23 @@ after_success:
2727
- chmod +x send.sh
2828
- ./send.sh success $WEBHOOK_URL
2929
- if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then
30-
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
31-
docker tag humanconnection/frontend-nuxt humanconnection/frontend-nuxt:alpha;
32-
docker push humanconnection/frontend-nuxt:alpha;
30+
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" &&
31+
docker tag humanconnection/frontend-nuxt humanconnection/frontend-nuxt:alpha &&
32+
docker push humanconnection/frontend-nuxt:alpha &&
33+
wget https://raw.githubusercontent.com/Human-Connection/Discord-Bot/develop/tester.sh &&
34+
chmod +x tester.sh &&
35+
./tester.sh alpha $WEBHOOK_URL;
3336
fi
3437
- if [ $TRAVIS_BRANCH == "develop" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then
35-
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
36-
docker tag humanconnection/frontend-nuxt humanconnection/frontend-nuxt:edge;
37-
docker push humanconnection/frontend-nuxt:edge;
38+
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" &&
39+
docker tag humanconnection/frontend-nuxt humanconnection/frontend-nuxt:edge &&
40+
docker push humanconnection/frontend-nuxt:edge &&
41+
wget https://raw.githubusercontent.com/Human-Connection/Discord-Bot/develop/tester.sh &&
42+
chmod +x tester.sh &&
43+
./tester.sh staging $WEBHOOK_URL;
3844
fi
3945

4046
after_failure:
4147
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
4248
- chmod +x send.sh
43-
- ./send.sh failure $WEBHOOK_URL
49+
- ./send.sh failure $WEBHOOK_URL

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at developer@human-connection.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

components/Contributions/ContributionsForm.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@
427427
return
428428
}
429429
this.$emit('validate', true)
430+
this.editorText('')
430431
431432
this.isLoading = true
432433
@@ -452,6 +453,7 @@
452453
} catch (err) {
453454
console.error(err)
454455
this.isLoading = false
456+
this.$emit('validate', false)
455457
this.$toast.open({
456458
message: err.message,
457459
type: 'is-danger'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { shallowMount } from '@vue/test-utils'
2+
import Icon from './Icon'
3+
4+
test('It should render an `<i>`.', () => {
5+
const wrapper = shallowMount(Icon)
6+
7+
expect(wrapper.is('i')).toBeTruthy()
8+
})

components/layout/Topbar.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
:class="{ 'is-active': menuIsActive }">
77
<div class="hc-navbar-item hc-navbar-brand">
88
<h1 class="is-hidden">Human-Connection</h1>
9-
<a class="hc-navbar-brand-logo"
10-
@click="onLogoClick"
9+
<nuxt-link to="/" class="hc-navbar-brand-logo"
10+
@click.native="onLogoClick"
1111
:title="$t('component.layout.topbarLabel')">
1212
<img class="is-hidden-mobile"
1313
src="/Logo-Horizontal-Alpha.svg"
1414
alt="Human-Connection.org"/>
1515
<img class="is-hidden-tablet"
1616
src="/Logo-Globe-Alpha.svg"
1717
alt="Human-Connection.org"/>
18-
</a>
18+
</nuxt-link>
1919
</div>
2020
<div class="hc-navbar-item hc-navbar-search">
2121
<top-search></top-search>

components/mixins/protectable.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// This mixin can be loaded for every page component with input fields. It will confirm leaving the page in case the user has some (unsaved) input/draft pending.
22
let protectable = {
33
beforeRouteLeave (to, from, next) {
4-
if (this.isComposing) {
4+
next(false)
5+
if (this.isComposing && !this.isSubmitting) {
56
this.$dialog.confirm({
67
title: this.$t('component.contribution.draft'),
78
message: this.$t('component.contribution.draftMsg'),
@@ -17,6 +18,8 @@ let protectable = {
1718
},
1819
mounted () {
1920
window.addEventListener('beforeunload', this.beforeUnload)
21+
this.isSubmitting = false
22+
this.isComposing = false
2023
},
2124
beforeDestroy () {
2225
window.removeEventListener('beforeunload', this.beforeUnload)

package.json

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
"eslint": "eslint --ext .js,.vue .",
3838
"styleguide": "vue-styleguidist server",
3939
"styleguide:build": "vue-styleguidist build",
40-
"test": "ava",
40+
"test": "yarn run test:jest && yarn run test:ava",
41+
"test:jest": "jest",
42+
"test:ava": "ava test/**/*.ava.js",
4143
"cypress:open": "cypress open",
4244
"cypress:run": "cypress run",
4345
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
@@ -116,10 +118,11 @@
116118
},
117119
"devDependencies": {
118120
"@nuxtjs/webpackmonitor": "~0.1.0",
119-
"@vue/test-utils": "^1.0.0-beta.20",
120-
"ava": "~0.25.0",
121+
"@vue/server-test-utils": "^1.0.0-beta.25",
122+
"@vue/test-utils": "^1.0.0-beta.25",
123+
"ava": "^0.25.0",
124+
"babel-jest": "^23.6.0",
121125
"backpack-core": "~0.7.0",
122-
"browser-env": "~3.2.4",
123126
"codecov": "~3.0.4",
124127
"eslint": "~4.19.1",
125128
"eslint-config-standard": "~11.0.0-beta.0",
@@ -131,21 +134,39 @@
131134
"eslint-plugin-standard": "~3.1.0",
132135
"eslint-plugin-vue": "^4.5.0",
133136
"istanbul": "~0.4.5",
134-
"jsdom": "~11.10.0",
137+
"jest": "^23.6.0",
138+
"jsdom": "^12.0.0",
139+
"jsdom-global": "^3.0.2",
135140
"less": "~2.7.3",
136141
"less-loader": "^4.1.0",
137142
"node-sass": "~4.9.0",
138143
"require-extension-hooks": "~0.3.3",
139144
"require-extension-hooks-babel": "~0.1.1",
140145
"require-extension-hooks-vue": "~1.0.0",
141146
"sass-loader": "~6.0.7",
147+
"sinon": "^6.3.4",
142148
"source-map-support": "~0.5.6",
143149
"vue-docgen-api": "^2.3.11",
150+
"vue-jest": "^2.6.0",
144151
"vue-style-loader": "~4.1.0"
145152
},
146153
"ava": {
147154
"require": [
148155
"./test/helpers/setup.js"
149156
]
157+
},
158+
"jest": {
159+
"moduleFileExtensions": [
160+
"js",
161+
"json",
162+
"vue"
163+
],
164+
"moduleNameMapper": {
165+
"^~/(.*)$": "<rootDir>/$1"
166+
},
167+
"transform": {
168+
".*\\.(vue)$": "vue-jest",
169+
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
170+
}
150171
}
151172
}

pages/contributions/edit/_slug.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<template>
22
<div class="columns">
3-
<div class=" column is-8 is-offset-2">
4-
<div class="card">
3+
<div class="column is-8 is-offset-2">
4+
<div class="card" :class="classes">
55
<section class="section">
6-
<!--<h1 class="title">Edit {{ title }}</h1>-->
7-
<contributions-form :data="form"></contributions-form>
6+
<contributions-form :data="form" v-on:input="editorText" @validate="onValidate" />
87
</section>
98
</div>
109
</div>
@@ -13,12 +12,28 @@
1312

1413
<script>
1514
import ContributionsForm from '~/components/Contributions/ContributionsForm.vue'
15+
import animatable from '~/components/mixins/animatable'
16+
import protectable from '~/components/mixins/protectable'
1617
1718
export default {
1819
middleware: ['verified', 'owner'],
20+
mixins: [animatable, protectable],
1921
components: {
2022
ContributionsForm
2123
},
24+
methods: {
25+
editorText (newText) {
26+
this.protectText(newText)
27+
},
28+
onValidate (success) {
29+
if (!success) {
30+
this.animate('shake')
31+
this.isSubmitting = false
32+
} else {
33+
this.isSubmitting = true
34+
}
35+
}
36+
},
2237
async asyncData ({app, params, error}) {
2338
try {
2439
let res = await app.$api.service('contributions').find({

0 commit comments

Comments
 (0)