diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-11-21 18:10:45 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-11-27 11:18:48 +0300 |
commit | 47fad3353f9ef510a11f2f690e8c2f6ae492fffd (patch) | |
tree | 7311b43ef5e9930ce7d2887509bf94054420bf1d /app/assets | |
parent | ea8f0f3bcc02e26f6dbb7f40b3575bbaac852328 (diff) |
Add parseBoolean helper function
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 3186ae9c133..040d0bc659e 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -421,12 +421,28 @@ export const historyPushState = newUrl => { }; /** + * Returns true for a String "true" and false otherwise. + * This is the opposite of Boolean(...).toString() + * + * @param {String} value + * @returns {Boolean} + */ +export const parseBoolean = value => value === 'true'; + +/** * Converts permission provided as strings to booleans. * * @param {String} string * @returns {Boolean} */ -export const convertPermissionToBoolean = permission => permission === 'true'; +export const convertPermissionToBoolean = permission => { + if (process.env.NODE_ENV !== 'production') { + // eslint-disable-next-line no-console + console.warn('convertPermissionToBoolean is deprecated! Please use parseBoolean instead.'); + } + + return parseBoolean(permission); +}; /** * Back Off exponential algorithm |