Fixed layout settings badge creation.
Hide sponsorship if no paypal email is configured.
This commit is contained in:
parent
e9e3cb809d
commit
8a6df3ef10
@ -34,4 +34,5 @@ exports.publicValues = {
|
|||||||
googleClientId,
|
googleClientId,
|
||||||
googleApiKey,
|
googleApiKey,
|
||||||
wordpressClientId,
|
wordpressClientId,
|
||||||
|
allowSponsorship: !!paypalReceiverEmail,
|
||||||
};
|
};
|
||||||
|
@ -105,6 +105,9 @@ exports.paypalIpn = (req, res, next) => Promise.resolve()
|
|||||||
.catch(next);
|
.catch(next);
|
||||||
|
|
||||||
exports.checkSponsor = (idToken) => {
|
exports.checkSponsor = (idToken) => {
|
||||||
|
if (!conf.publicValues.allowSponsorship) {
|
||||||
|
return Promise.resolve(true);
|
||||||
|
}
|
||||||
if (!idToken) {
|
if (!idToken) {
|
||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
@ -58,18 +58,14 @@ export default {
|
|||||||
store.dispatch('modal/open', {
|
store.dispatch('modal/open', {
|
||||||
type: 'couchdbWorkspace',
|
type: 'couchdbWorkspace',
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) { /* Cancel */ }
|
||||||
// Cancel
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async addGithubWorkspace() {
|
async addGithubWorkspace() {
|
||||||
try {
|
try {
|
||||||
store.dispatch('modal/open', {
|
store.dispatch('modal/open', {
|
||||||
type: 'githubWorkspace',
|
type: 'githubWorkspace',
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) { /* Cancel */ }
|
||||||
// Cancel
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async addGitlabWorkspace() {
|
async addGitlabWorkspace() {
|
||||||
try {
|
try {
|
||||||
@ -79,9 +75,7 @@ export default {
|
|||||||
type: 'gitlabWorkspace',
|
type: 'gitlabWorkspace',
|
||||||
token,
|
token,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) { /* Cancel */ }
|
||||||
// Cancel
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async addGoogleDriveWorkspace() {
|
async addGoogleDriveWorkspace() {
|
||||||
try {
|
try {
|
||||||
@ -90,12 +84,12 @@ export default {
|
|||||||
type: 'googleDriveWorkspace',
|
type: 'googleDriveWorkspace',
|
||||||
token,
|
token,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) { /* Cancel */ }
|
||||||
// Cancel
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
manageWorkspaces() {
|
manageWorkspaces() {
|
||||||
store.dispatch('modal/open', 'workspaceManagement');
|
try {
|
||||||
|
store.dispatch('modal/open', 'workspaceManagement');
|
||||||
|
} catch (e) { /* Cancel */ }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -64,21 +64,26 @@ const patcher = id => ({ state, commit }, data) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// For layoutSettings
|
// For layoutSettings
|
||||||
const layoutSettingsToggler = (propertyName, featureId) => ({ getters, dispatch }, value) => {
|
const toggleLayoutSetting = (name, value, featureId, getters, dispatch) => {
|
||||||
dispatch('patchLayoutSettings', {
|
const currentValue = getters.layoutSettings[name];
|
||||||
[propertyName]: value === undefined ? !getters.layoutSettings[propertyName] : value,
|
const patch = {
|
||||||
});
|
[name]: value === undefined ? !currentValue : !!value,
|
||||||
badgeSvc.addBadge(featureId);
|
};
|
||||||
|
if (patch[name] !== currentValue) {
|
||||||
|
dispatch('patchLayoutSettings', patch);
|
||||||
|
badgeSvc.addBadge(featureId);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const notEnoughSpace = (getters) => {
|
|
||||||
const layoutConstants = getters['layout/constants'];
|
const layoutSettingsToggler = (propertyName, featureId) => ({ getters, dispatch }, value) =>
|
||||||
const showGutter = getters['discussion/currentDiscussion'];
|
toggleLayoutSetting(propertyName, value, featureId, getters, dispatch);
|
||||||
return document.body.clientWidth < layoutConstants.editorMinWidth +
|
|
||||||
|
const notEnoughSpace = (layoutConstants, showGutter) =>
|
||||||
|
document.body.clientWidth < layoutConstants.editorMinWidth +
|
||||||
layoutConstants.explorerWidth +
|
layoutConstants.explorerWidth +
|
||||||
layoutConstants.sideBarWidth +
|
layoutConstants.sideBarWidth +
|
||||||
layoutConstants.buttonBarWidth +
|
layoutConstants.buttonBarWidth +
|
||||||
(showGutter ? layoutConstants.gutterWidth : 0);
|
(showGutter ? layoutConstants.gutterWidth : 0);
|
||||||
};
|
|
||||||
|
|
||||||
// For templates
|
// For templates
|
||||||
const makeAdditionalTemplate = (name, value, helpers = '\n') => ({
|
const makeAdditionalTemplate = (name, value, helpers = '\n') => ({
|
||||||
@ -239,26 +244,30 @@ export default {
|
|||||||
// Reset side bar
|
// Reset side bar
|
||||||
dispatch('setSideBarPanel');
|
dispatch('setSideBarPanel');
|
||||||
|
|
||||||
|
// Toggle it
|
||||||
|
toggleLayoutSetting('showSideBar', value, 'toggleSideBar', getters, dispatch);
|
||||||
|
|
||||||
// Close explorer if not enough space
|
// Close explorer if not enough space
|
||||||
const patch = {
|
if (getters.layoutSettings.showSideBar &&
|
||||||
showSideBar: value === undefined ? !getters.layoutSettings.showSideBar : value,
|
notEnoughSpace(rootGetters['layout/constants'], rootGetters['discussion/currentDiscussion'])
|
||||||
};
|
) {
|
||||||
if (patch.showSideBar && notEnoughSpace(rootGetters)) {
|
dispatch('patchLayoutSettings', {
|
||||||
patch.showExplorer = false;
|
showExplorer: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
dispatch('patchLayoutSettings', patch);
|
|
||||||
badgeSvc.addBadge('toggleSideBar');
|
|
||||||
},
|
},
|
||||||
toggleExplorer: ({ getters, dispatch, rootGetters }, value) => {
|
toggleExplorer: ({ getters, dispatch, rootGetters }, value) => {
|
||||||
|
// Toggle explorer
|
||||||
|
toggleLayoutSetting('showExplorer', value, 'toggleExplorer', getters, dispatch);
|
||||||
|
|
||||||
// Close side bar if not enough space
|
// Close side bar if not enough space
|
||||||
const patch = {
|
if (getters.layoutSettings.showExplorer &&
|
||||||
showExplorer: value === undefined ? !getters.layoutSettings.showExplorer : value,
|
notEnoughSpace(rootGetters['layout/constants'], rootGetters['discussion/currentDiscussion'])
|
||||||
};
|
) {
|
||||||
if (patch.showExplorer && notEnoughSpace(rootGetters)) {
|
dispatch('patchLayoutSettings', {
|
||||||
patch.showSideBar = false;
|
showSideBar: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
dispatch('patchLayoutSettings', patch);
|
|
||||||
badgeSvc.addBadge('toggleExplorer');
|
|
||||||
},
|
},
|
||||||
setSideBarPanel: ({ dispatch }, value) => dispatch('patchLayoutSettings', {
|
setSideBarPanel: ({ dispatch }, value) => dispatch('patchLayoutSettings', {
|
||||||
sideBarPanel: value === undefined ? 'menu' : value,
|
sideBarPanel: value === undefined ? 'menu' : value,
|
||||||
|
@ -155,8 +155,14 @@ const store = new Vuex.Store({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
isSponsor: ({ light }, getters) => {
|
isSponsor: ({ light }, getters) => {
|
||||||
|
if (light) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!getters['data/serverConf'].allowSponsorship) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const sponsorToken = getters['workspace/sponsorToken'];
|
const sponsorToken = getters['workspace/sponsorToken'];
|
||||||
return light || (sponsorToken && sponsorToken.isSponsor);
|
return sponsorToken ? sponsorToken.isSponsor : false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
Loading…
Reference in New Issue
Block a user