Skip to content

Commit

Permalink
Merge branch 'release/0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexschiller committed May 30, 2018
2 parents eb16bcd + dd8519d commit 26da70d
Show file tree
Hide file tree
Showing 39 changed files with 1,825 additions and 29 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.6.0] - 2018-05-29
### Added
- Moderator management page
- Moderator notification management page

### Fixed
- Prevent whitespace under banners

## [0.5.1] - 2018-04-24
### Changed
- Back to pinned osf-style commit
Expand Down
1 change: 1 addition & 0 deletions app/components/loading-btn-indicator/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<i class="fa fa-circle-o-notch fa-spin"></i>
10 changes: 9 additions & 1 deletion app/components/moderation-base/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ export default Component.extend({
tabs: computed('theme.reviewableStatusCounts.pending', function() {
return [
{
nameKey: 'global.moderation',
nameKey: 'global.submissions',
route: 'preprints.provider.moderation',
hasCount: true,
count: this.get('theme.reviewableStatusCounts.pending'),
},
{
nameKey: 'global.moderators',
route: 'preprints.provider.moderators',
},
{
nameKey: 'global.notifications',
route: 'preprints.provider.notifications',
},
{
nameKey: 'global.settings',
route: 'preprints.provider.settings',
Expand Down
21 changes: 13 additions & 8 deletions app/components/moderation-base/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#tabTitle .nav > li > a {
border-radius: 0;
font-size: 24px;
padding: 15px 20px;
padding: 10px 15px;
}

#tabTitle .nav > li > a:hover {
Expand All @@ -53,27 +53,32 @@ li.active > a {

@media screen and (max-width: $screen-small-tablet) {
.dark-header {
height: 190px;
height: 170px;
.provider-title {
font-size: 32px;
font-size: 26px;
}
.breadcrumbs {
padding-bottom: 15px;
}
}
#tabTitle .nav > li > a {
font-size: 20px;
font-size: 14px;
padding: 8px 12px;
}
}

@media screen and (max-width: $screen-medium-small) {
.dark-header {
height: 170px;
height: 150px;
.provider-title {
font-size: 25px;
font-size: 22px;
}
.breadcrumbs {
padding-bottom: 20px;
padding-bottom: 10px;
}
}
#tabTitle .nav > li > a {
font-size: 15px;
font-size: 10px;
padding: 5px 10px;
}
}
125 changes: 125 additions & 0 deletions app/components/moderator-list-add/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import Component from '@ember/component';

import { task, timeout } from 'ember-concurrency';
import { validator, buildValidations } from 'ember-cp-validations';


const DEBOUNCE_MS = 250;

/* Validations for adding unregistered contributor form.
* fullName must be present and have at least three characters but not more than 255
* username (email) must be present and of appropriate format.
*/
const Validations = buildValidations({
fullName: {
description: 'Full name',
validators: [
validator('presence', true),
validator('length', {
min: 3,
max: 255,
}),
],
},
email: {
description: 'Email',
validators: [
validator('presence', true),
validator('format', {
type: 'email',
regex: /^[-a-z0-9~!$%^&*_=+}{'?]+(\.[-a-z0-9~!$%^&*_=+}{'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i,
}),
],
},
});

export default Component.extend(Validations, {
i18n: service(),
store: service(),
theme: service(),

selectedUser: '',
unregisteredUserName: '',
unregisteredUserEmail: '',
selectedUnregisteredUser: false,
role: '',

isFormValid: computed.alias('validations.isValid'),

roleLabel: computed('role', function() {
const roleOption = this.get('roleOptions').findBy('role', this.get('role'));
return roleOption ? roleOption.label : 'Role';
}),

selectedUserId: computed('selectedUser', 'unregisteredUserEmail', function() {
return this.get('selectedUser.id') || this.get('unregisteredUserEmail');
}),

disableSave: computed('role', 'selectedUser', 'unregisteredUserName', function() {
return !this.get('role') || (!this.get('selectedUser') && !this.get('unregisteredUserName'));
}),

showInviteForm: computed('selectedUser', 'selectedUnregisteredUser', function() {
return !this.get('selectedUser') && !this.get('selectedUnregisteredUser');
}),

actions: {
roleChanged(role) {
this.set('role', role);
},
cancel() {
this.setProperties({
editingModerator: false,
addingNewModerator: false,
role: '',
selectedUser: '',
});
},
resetInviteForm() {
this.$('#toggle-form').click();
this.setProperties({
unregisteredUserName: '',
unregisteredUserEmail: '',
});
},
selectUnregistered() {
if (this.get('isFormValid')) {
this.$('#toggle-form').click();
this.set('selectedUnregisteredUser', true);
}
},
},

searchUsers: task(function* (query) {
yield timeout(DEBOUNCE_MS);

try {
const users = yield this.get('store').query('user', {
filter: {
'full_name,given_name,middle_names,family_name': query,
},
page: {
size: 15,
},
});

const usersFullNames = users.content.map((user) => {
const userData = {
fullName: user.__data.fullName,
profileImage: user.__data.links.profile_image,
id: user.id,
};
if (this.get('moderatorIds').includes(user.id)) {
userData.disabled = true;
}
return userData;
});

return usersFullNames;
} catch (e) {
this.get('toast').error(this.get('i18n').t('components.moderatorListAdd.userSearchError'));
}
}).restartable(),
});
87 changes: 87 additions & 0 deletions app/components/moderator-list-add/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.ember-power-select-selected-item {
margin-left: 0;
}

.moderators-add-row-container {
display: inline-grid;
grid-template-columns: 2fr 1fr 1fr;
grid-template-rows: 1;
align-items: center;
justify-items: start;
width: 100%;
min-height: 60px;
}

.moderator-name {
width: 100%;
display: inline-flex;
align-items: center;
flex-wrap: wrap;

.ember-power-select-trigger {
min-width: 200px;
background-color: transparent;
}
}

@media (max-width: 700px) {
.moderators-add-row-container {
display: inline-grid;
grid-template-columns: 2fr 2fr;
grid-template-rows: 1fr 1fr;
align-items: center;
justify-items: start;
width: 100%;
min-height: 60px;
}

.moderator-name {
grid-column-start: 1;
grid-column-end: 3;
}
}

.dropdown-link {
color: $brand-primary;
border: none;
background-color: transparent;
padding: 2px 2px;
margin: 0 3px;

:hover {
background-color: none;
border-color: none;
}
}

.open > .dropdown-link {
box-shadow: 0 0 3px;
}

.role-dropdown {
.dropdown-button {
min-width: 115px;
display: flex;
justify-content: space-between;
align-items: center;
}
.invite-dropdown {
background-color: $color-white;
}
}

.row-controls {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
justify-self: flex-end;
}

.unregistered-dropdown {
background-color: $color-white;
width: 275px;
}

.unregistered-form {
padding: 10px;
}
92 changes: 92 additions & 0 deletions app/components/moderator-list-add/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<div class="moderators-add-row-container p-h-md p-v-sm">
<div class="moderator-name">
{{#if (not selectedUnregisteredUser)}}
{{#power-select
disabled=loadingModerators
options=users
search=(perform searchUsers)
placeholder='Search by name'
selected=selectedUser
onchange=(action (mut selectedUser)) as |user|}}
<div style="display: flex; align-items: center;">
<img class="m-xs" src="{{user.profileImage}}" height=25 width=25 alt="{{user.fullName}} gravatar">
<div>{{user.fullName}}</div>
</div>
{{/power-select}}
{{else}}
<i>{{unregisteredUserName}}</i>
{{/if}}
{{#if showInviteForm}}
<span class="p-l-xs">or</span>
{{#bs-dropdown classNames="invite-dropdown" closeOnMenuClick=false as |dd|}}
{{#dd.toggle id="toggle-form" classNames="btn dropdown-link"}}
{{t 'components.moderatorListAdd.inviteText'}}
{{/dd.toggle}}
{{#dd.menu classNames="unregistered-dropdown" tagName="div" as |menu|}}
{{#menu.item classNames="unregistered-form" tagName="form"}}
<div>
<label>{{t "components.unregisteredContributorForm.fullNameLabel"}}</label>
<form>
{{validated-input
model=this
valuePath='fullName'
placeholder=(t "components.unregisteredContributorForm.fullNameLabel")
value=unregisteredUserName}}
</form>
</div>
<div>
<label>{{t "components.unregisteredContributorForm.emailLabel"}}</label>
<form>
{{validated-input
model=this
valuePath='email'
placeholder=(t "components.unregisteredContributorForm.emailLabel")
value=unregisteredUserEmail}}
</form>
</div>
<p class="text-muted">
{{t "components.unregisteredContributorForm.notifyMessage"}}
</p>
<div class="pull-right p-t-xs p-b-sm">
<button type="button" class="btn btn-default btn-small" {{action 'resetInviteForm'}}>
{{t "global.cancel"}}
</button>
<button type="submit" class="btn btn-success btn-small m-l-xs" {{action 'selectUnregistered'}} disabled={{not isFormValid}}>
{{t "global.add"}}
</button>
</div>
{{/menu.item}}
{{/dd.menu}}
{{/bs-dropdown}}
{{/if}}
</div>
{{#bs-dropdown classNames="role-dropdown" as |dd|}}
{{#dd.button classNames="btn btn-default dropdown-button"}}
{{roleLabel}}
<span class="fa fa-caret-down p-l-xs"></span>
{{/dd.button}}
{{#dd.menu classNames="moderator-dropdown-menu" as |menu|}}
{{#each roleOptions as |roleOption|}}
{{#menu.item}}
<button class="btn" {{action 'roleChanged' roleOption.role}}>
{{roleOption.label}}
<i class='{{if (eq role roleOption.role) 'fa fa-check selected' 'not-selected'}}'></i>
</button>
{{/menu.item}}
{{/each}}
{{/dd.menu}}
{{/bs-dropdown}}
<div class="row-controls">
<button class="btn btn-default" {{action 'cancel'}} disabled={{addModerator.isRunning}}>
{{t 'global.cancel'}}
</button>
<button class="btn btn-success m-l-xs" disabled={{disableSave}} onclick={{perform addModerator selectedUserId role unregisteredUserName}}>
{{#if addModerator.isRunning}}
{{loading-btn-indicator}}
{{else}}
{{t 'global.save'}}
{{/if}}
</button>
</div>
</div>
<div class="moderators-row-border"></div>
Loading

0 comments on commit 26da70d

Please sign in to comment.