Force signin before commenting

This commit is contained in:
benweet 2017-11-17 20:33:49 +00:00
parent fdfafc9519
commit 217b17c279
6 changed files with 21 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import editorSvc from '../../services/editorSvc';
export default {
data: () => ({
selection: null,
coordinates: null,
}),
methods: {

View File

@ -10,6 +10,7 @@ import editorSvc from '../../services/editorSvc';
export default {
data: () => ({
selection: null,
coordinates: null,
}),
methods: {

View File

@ -70,7 +70,7 @@ export default {
color: darken($error-color, 10%);
background-color: transparentize($error-color, 0.85);
border-radius: $border-radius-base;
padding: 1em 1.5em;
padding: 0.75em 1.5em;
margin-bottom: 1.2em;
}
</style>

View File

@ -210,7 +210,7 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
this.$emit('previewText', this.previewText);
// Debounce if sections have already been mesured
this.measureSectionDimensions(!!this.sectionDescMeasuredList);
this.makeTextToPreviewDiffs(true);
this.makeTextToPreviewDiffs();
});
},

View File

@ -1,4 +1,6 @@
import utils from '../services/utils';
import googleHelper from '../services/providers/helpers/googleHelper';
import syncSvc from '../services/syncSvc';
const idShifter = offset => (state, getters) => {
const ids = Object.keys(getters.currentFileDiscussions);
@ -115,8 +117,15 @@ export default {
getters.currentDiscussionComments[getters.currentDiscussionLastCommentId],
},
actions: {
createNewDiscussion({ commit, rootGetters }, selection) {
if (selection) {
createNewDiscussion({ commit, dispatch, rootGetters }, selection) {
const loginToken = rootGetters['data/loginToken'];
if (!loginToken) {
dispatch('modal/signInForComment', null, { root: true })
.then(() => googleHelper.signin())
.then(() => syncSvc.requestSync())
.then(() => dispatch('createNewDiscussion', selection))
.catch(() => { }); // Cancel
} else if (selection) {
let text = rootGetters['content/current'].text.slice(selection.start, selection.end).trim();
const maxLength = 80;
if (text.length > maxLength) {

View File

@ -88,6 +88,12 @@ export default {
resolveText: 'Ok, sign in',
rejectText: 'Cancel',
}),
signInForComment: ({ dispatch }) => dispatch('open', {
content: `<p>You have to sign in with <b>Google</b> to start commenting.</p>
<div class="modal__info"><b>Note:</b> This will sync all your files and settings.</div>`,
resolveText: 'Ok, sign in',
rejectText: 'Cancel',
}),
sponsorOnly: ({ dispatch }) => dispatch('open', {
content: '<p>This feature is restricted to <b>sponsor users</b> as it relies on server resources.</p>',
resolveText: 'Ok, I understand',