This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display pending requests to join (#250)
* Display pending requests to join * Add time restriction for display * Review copy * Upgrade cp-translations
- Loading branch information
1 parent
de53de3
commit 3dfc15c
Showing
8 changed files
with
289 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
<div class="cd-dashboard-pending-requests"> | ||
<div :class="[index === (dojos.length -1) && infoIsDisplayed ? 'cd-dashboard-pending-requests__request--last': '', 'cd-dashboard-pending-requests__request']" v-for="(dojo, index) in dojos"> | ||
<i class="fa fa-hourglass-half"></i> | ||
<h4 class="cd-dashboard-pending-requests__request-title" v-html="$t('You have a pending join request for <a href=\'/dojos/{slug}\'>{name}</a>.', { name: dojo.name, slug: dojo.urlSlug })"/> | ||
<p>{{ $t('If the Dojo does not reply/accept within a few days, we suggest you try another club or contacting support.') }}</p> | ||
</div> | ||
<div class="cd-dashboard-pending-requests__info" v-if="infoIsDisplayed"> | ||
{{ $t('In the meantime, we recommend that you complete some of the following.') }} | ||
<ul class="cd-dashboard-pending-requests__info-recommendations"> | ||
<li><a href="https://www.raspberrypi.org/safeguarding/e-learning-module/">{{ $t('Do our safeguarding module') }}</a></li> | ||
<li><a href="https://help.coderdojo.com/hc/en-us/articles/360000674903-Setting-up-and-running-a-Dojo-a-CoderDojo-guide">{{ $t('Look at our guide to mentoring') }}</a></li> | ||
<li><a href="https://projects.raspberrypi.org/org/coderdojo">{{ $t('Check out some projects you might like') }}</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import moment from 'moment'; | ||
import DojosService from '@/dojos/service'; | ||
export default { | ||
name: 'cd-dashboard-pending-requests', | ||
props: ['requestsToJoin', 'userIsNew'], | ||
data() { | ||
return { | ||
dojos: [], | ||
}; | ||
}, | ||
computed: { | ||
recentRequestsToJoin() { | ||
return this.requestsToJoin.filter(r => moment().diff(r.timestamp, 'days') < 30); | ||
}, | ||
infoIsDisplayed() { | ||
return this.userIsNew && this.recentRequestsToJoin.length > 0; | ||
}, | ||
}, | ||
async created() { | ||
this.dojos = (await DojosService.getDojos({ | ||
id: { | ||
in$: this.recentRequestsToJoin.map(r => r.dojoId), | ||
}, | ||
})).body; | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="less"> | ||
@import "~@coderdojo/cd-common/common/_colors"; | ||
@import "../common/variables"; | ||
.cd-dashboard-pending-requests { | ||
margin: 32px 0; | ||
display: flex; | ||
flex-direction: column; | ||
&__request, &__info { | ||
background: @cd-white; | ||
padding: 20px; | ||
} | ||
&__info { | ||
&-recommendations { | ||
padding-top: 1em; | ||
} | ||
} | ||
&__request { | ||
margin: @margin 0; | ||
& > .fa { | ||
padding-right: @margin; | ||
font-size: 1.2em; | ||
} | ||
&-title { | ||
display: inline-block; | ||
} | ||
&--last { | ||
margin: 0; | ||
border-bottom: @cd-very-light-grey 10px solid; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
test/unit/specs/dashboard/cd-dashboard-pending-volunteering.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import vueUnitHelper from 'vue-unit-helper'; | ||
import moment from 'moment'; | ||
import DashboardHeaderComponent from '!!vue-loader?inject!@/dashboard/cd-dashboard-pending-volunteering'; | ||
|
||
describe('Dashboard pending volunteering component', () => { | ||
let sandbox; | ||
let vm; | ||
let MockDojosService; | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.sandbox.create(); | ||
MockDojosService = { | ||
getDojos: sandbox.stub(), | ||
}; | ||
vm = vueUnitHelper(DashboardHeaderComponent({ | ||
'@/dojos/service': MockDojosService, | ||
})); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
|
||
describe('computed', () => { | ||
describe('recentRequestsToJoin', () => { | ||
it('should filter any requests to join which are 30 days older', () => { | ||
const oldDay = moment().add(-31, 'days'); | ||
const now = new Date(); | ||
// ARRANGE | ||
vm.requestsToJoin = [{ id: 'rq1', timestamp: oldDay }, { id: 'rq2', timestamp: now }]; | ||
|
||
// ASSERT | ||
expect(vm.recentRequestsToJoin).to.eql([{ id: 'rq2', timestamp: now }]); | ||
}); | ||
}); | ||
describe('infoIsDisplayed', () => { | ||
it('should return true if there are valid requests to join and the user is new', () => { | ||
// ARRANGE | ||
vm.recentRequestsToJoin = [{ id: 'rq1' }]; | ||
vm.userIsNew = true; | ||
|
||
// ASSERT | ||
expect(vm.infoIsDisplayed).to.be.true; | ||
}); | ||
it('should return false if the user has no leads', () => { | ||
// ARRANGE | ||
vm.recentRequestsToJoin = []; | ||
vm.userIsNew = true; | ||
|
||
// ASSERT | ||
expect(vm.infoIsDisplayed).to.be.false; | ||
}); | ||
it('should return false if the user is not new', () => { | ||
// ARRANGE | ||
vm.recentRequestsToJoin = [{ id: 'rq1' }]; | ||
vm.userIsNew = false; | ||
|
||
// ASSERT | ||
expect(vm.infoIsDisplayed).to.be.false; | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters