Add new config option allowVisibleSource#1599
Add new config option allowVisibleSource#1599roman-yatsenko wants to merge 33 commits intohackmdio:developfrom
Conversation
…ными Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
…create disable\enabel fn's Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
b918582 to
b7bc124
Compare
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
lib/config/default.js
Outdated
| allowAnonymousEdits: true, | ||
| allowAnonymousViews: true, | ||
| allowFreeURL: false, | ||
| allowVisibleSource: true, |
There was a problem hiding this comment.
To prevent broken current behavior, set the default value to false
There was a problem hiding this comment.
With the default value true user can see note source (edit and both modes are enabled for view to user without edit rights). The true value is an usual CodiMD behavior for now.
P.S. But we've refactored as you wish :-)
lib/config/environment.js
Outdated
| allowAnonymousEdits: toBooleanConfig(process.env.CMD_ALLOW_ANONYMOUS_EDITS), | ||
| allowAnonymousViews: toBooleanConfig(process.env.CMD_ALLOW_ANONYMOUS_VIEWS), | ||
| allowFreeURL: toBooleanConfig(process.env.CMD_ALLOW_FREEURL), | ||
| allowVisibleSource: toBooleanConfig(process.env.CMD_VISIBLE_SOURCE), |
There was a problem hiding this comment.
following coding convention,
change the environment variable name to CMD_ALLOW_VISIBLE_SOURCE
public/js/index.js
Outdated
|
|
||
| function checkParametr (isLogin, permission) { | ||
| if (typeof isLogin !== 'boolean' || !permission) { | ||
| throw new Error('one or more parametr is incorrect') |
There was a problem hiding this comment.
| throw new Error('one or more parametr is incorrect') | |
| throw new Error('one or more parameter is incorrect') |
public/js/index.js
Outdated
| function checkParametr (isLogin, permission) { | ||
| if (typeof isLogin !== 'boolean' || !permission) { | ||
| throw new Error('one or more parametr is incorrect') | ||
| } else return allowVisibleSource(isLogin, permission) |
There was a problem hiding this comment.
| } else return allowVisibleSource(isLogin, permission) | |
| } | |
| return allowVisibleSource(isLogin, permission) |
public/js/index.js
Outdated
| } | ||
| } | ||
|
|
||
| function disableControls () { |
There was a problem hiding this comment.
Using more precise function name here.
Maybe can change disableControlsto disableModeChangeControls and
enableControls to enableModeChangeControls
public/js/index.js
Outdated
| // setNeedRefresh(); | ||
| }) | ||
|
|
||
| function checkParametr (isLogin, permission) { |
There was a problem hiding this comment.
| function checkParametr (isLogin, permission) { | |
| function checkParameter (isLogin, permission) { |
public/js/index.js
Outdated
| } else return allowVisibleSource(isLogin, permission) | ||
| } | ||
|
|
||
| function replaceUrl (url) { |
There was a problem hiding this comment.
replaceUrl -> replaceUrlToViewMode
public/js/index.js
Outdated
| } | ||
|
|
||
| function userIsLogin (userPersonalInfo) { | ||
| if (Object.prototype.hasOwnProperty.call(userPersonalInfo, 'login')) { |
There was a problem hiding this comment.
function userIsLogin (userPersonalInfo) {
return !!userPersonalInfo && !!userPersonalInfo.login
}| @@ -1567,10 +1638,14 @@ function importFromUrl (url) { | |||
|
|
|||
| // mode | |||
| ui.toolbar.mode.click(function () { | |||
There was a problem hiding this comment.
introduce a function isAllowUserChangeMode
function isAllowUserChangeMode () {
const isOwner = personalInfo.userid && window.owner && personalInfo.userid === window.owner
return isOwner || !blockSourceView
}and mode select logic would be
if (isAllowUserChangeMode()) {
return toggleMode()
}
a60814billy
left a comment
There was a problem hiding this comment.
Hi @roman-yatsenko, thanks for your contribution, It's a good feature.
But we need some refactoring to meet project coding conventions before merge.
|
By the way, please sign DCO |
Signed-off-by: JamesHow1ett <mopis101@gmail.com>
We have a git problems with DCO commit signs (Can't sign done commits). Can we accept the pull request without DCO? Or we can create a new pull request with one signed commit with all code. |
|
Hi, @roman-yatsenko |
|
Recreated at #1621 |
Add new config option allowVisibleSource to the project. The default value for this option is true. The false value will block Edit and Both editor modes for users that have no rights to edit a note.
Pull request adds: