diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-11-21 18:13:04 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-11-27 11:18:48 +0300 |
commit | 8ef51157950366f64cbd41ccf070e1facd104cae (patch) | |
tree | 2d90860267ccfb8737b903a296b4c6ca16259ce1 /app/assets | |
parent | 47fad3353f9ef510a11f2f690e8c2f6ae492fffd (diff) |
Replace convertPermissionToBoolean with parseBoolean
Diffstat (limited to 'app/assets')
14 files changed, 35 insertions, 38 deletions
diff --git a/app/assets/javascripts/behaviors/markdown/gfm_auto_complete.js b/app/assets/javascripts/behaviors/markdown/gfm_auto_complete.js index a303e504cc7..55c68139ded 100644 --- a/app/assets/javascripts/behaviors/markdown/gfm_auto_complete.js +++ b/app/assets/javascripts/behaviors/markdown/gfm_auto_complete.js @@ -1,11 +1,11 @@ import $ from 'jquery'; -import { convertPermissionToBoolean } from '~/lib/utils/common_utils'; +import { parseBoolean } from '~/lib/utils/common_utils'; import GfmAutoComplete from '~/gfm_auto_complete'; export default function initGFMInput() { $('.js-gfm-input:not(.js-vue-textarea)').each((i, el) => { const gfm = new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources); - const enableGFM = convertPermissionToBoolean(el.dataset.supportsAutocomplete); + const enableGFM = parseBoolean(el.dataset.supportsAutocomplete); gfm.setup($(el), { emojis: true, diff --git a/app/assets/javascripts/behaviors/secret_values.js b/app/assets/javascripts/behaviors/secret_values.js index f6bf62d734e..5b92608d536 100644 --- a/app/assets/javascripts/behaviors/secret_values.js +++ b/app/assets/javascripts/behaviors/secret_values.js @@ -1,5 +1,5 @@ import { n__ } from '../locale'; -import { convertPermissionToBoolean } from '../lib/utils/common_utils'; +import { parseBoolean } from '../lib/utils/common_utils'; export default class SecretValues { constructor({ @@ -16,7 +16,7 @@ export default class SecretValues { this.revealButton = this.container.querySelector('.js-secret-value-reveal-button'); if (this.revealButton) { - const isRevealed = convertPermissionToBoolean(this.revealButton.dataset.secretRevealStatus); + const isRevealed = parseBoolean(this.revealButton.dataset.secretRevealStatus); this.updateDom(isRevealed); this.revealButton.addEventListener('click', this.onRevealButtonClicked.bind(this)); @@ -24,9 +24,7 @@ export default class SecretValues { } onRevealButtonClicked() { - const previousIsRevealed = convertPermissionToBoolean( - this.revealButton.dataset.secretRevealStatus, - ); + const previousIsRevealed = parseBoolean(this.revealButton.dataset.secretRevealStatus); this.updateDom(!previousIsRevealed); } diff --git a/app/assets/javascripts/build_artifacts.js b/app/assets/javascripts/build_artifacts.js index 97a1645aa51..b2c88e8c14e 100644 --- a/app/assets/javascripts/build_artifacts.js +++ b/app/assets/javascripts/build_artifacts.js @@ -2,7 +2,7 @@ import $ from 'jquery'; import { visitUrl } from './lib/utils/url_utility'; -import { convertPermissionToBoolean } from './lib/utils/common_utils'; +import { parseBoolean } from './lib/utils/common_utils'; export default class BuildArtifacts { constructor() { @@ -22,7 +22,7 @@ export default class BuildArtifacts { // eslint-disable-next-line class-methods-use-this setupEntryClick() { return $('.tree-holder').on('click', 'tr[data-link]', function() { - visitUrl(this.dataset.link, convertPermissionToBoolean(this.dataset.externalLink)); + visitUrl(this.dataset.link, parseBoolean(this.dataset.externalLink)); }); } // eslint-disable-next-line class-methods-use-this diff --git a/app/assets/javascripts/ci_variable_list/ajax_variable_list.js b/app/assets/javascripts/ci_variable_list/ajax_variable_list.js index dffabbfe1b8..592e1fd1c31 100644 --- a/app/assets/javascripts/ci_variable_list/ajax_variable_list.js +++ b/app/assets/javascripts/ci_variable_list/ajax_variable_list.js @@ -2,7 +2,7 @@ import _ from 'underscore'; import axios from '../lib/utils/axios_utils'; import { s__ } from '../locale'; import Flash from '../flash'; -import { convertPermissionToBoolean } from '../lib/utils/common_utils'; +import { parseBoolean } from '../lib/utils/common_utils'; import statusCodes from '../lib/utils/http_status'; import VariableList from './ci_variable_list'; @@ -101,7 +101,7 @@ export default class AjaxVariableList { // If we submitted a row that was destroyed, remove it so we don't try // to destroy it again which would cause a BE error const destroyInput = row.querySelector('.js-ci-variable-input-destroy'); - if (convertPermissionToBoolean(destroyInput.value)) { + if (parseBoolean(destroyInput.value)) { row.remove(); // Update the ID input so any future edits and `_destroy` will apply on the BE } else { diff --git a/app/assets/javascripts/ci_variable_list/ci_variable_list.js b/app/assets/javascripts/ci_variable_list/ci_variable_list.js index 7bdc18ce03e..ee0f7cda189 100644 --- a/app/assets/javascripts/ci_variable_list/ci_variable_list.js +++ b/app/assets/javascripts/ci_variable_list/ci_variable_list.js @@ -1,5 +1,5 @@ import $ from 'jquery'; -import { convertPermissionToBoolean } from '../lib/utils/common_utils'; +import { parseBoolean } from '../lib/utils/common_utils'; import { s__ } from '../locale'; import setupToggleButtons from '../toggle_buttons'; import CreateItemDropdown from '../create_item_dropdown'; @@ -150,7 +150,7 @@ export default class VariableList { removeRow(row) { const $row = $(row); - const isPersisted = convertPermissionToBoolean($row.attr('data-is-persisted')); + const isPersisted = parseBoolean($row.attr('data-is-persisted')); if (isPersisted) { $row.hide(); diff --git a/app/assets/javascripts/diffs/components/tree_list.vue b/app/assets/javascripts/diffs/components/tree_list.vue index ec4a4aa1d6d..f40a7b25fde 100644 --- a/app/assets/javascripts/diffs/components/tree_list.vue +++ b/app/assets/javascripts/diffs/components/tree_list.vue @@ -1,7 +1,7 @@ <script> import { mapActions, mapGetters, mapState } from 'vuex'; import { GlTooltipDirective } from '@gitlab/ui'; -import { convertPermissionToBoolean } from '~/lib/utils/common_utils'; +import { parseBoolean } from '~/lib/utils/common_utils'; import Icon from '~/vue_shared/components/icon.vue'; import FileRow from '~/vue_shared/components/file_row.vue'; import FileRowStats from './file_row_stats.vue'; @@ -18,8 +18,7 @@ export default { }, data() { const treeListStored = localStorage.getItem(treeListStorageKey); - const renderTreeList = - treeListStored !== null ? convertPermissionToBoolean(treeListStored) : true; + const renderTreeList = treeListStored !== null ? parseBoolean(treeListStored) : true; return { search: '', diff --git a/app/assets/javascripts/environments/folder/environments_folder_bundle.js b/app/assets/javascripts/environments/folder/environments_folder_bundle.js index f044d31c776..3cf6e4ad14d 100644 --- a/app/assets/javascripts/environments/folder/environments_folder_bundle.js +++ b/app/assets/javascripts/environments/folder/environments_folder_bundle.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import environmentsFolderApp from './environments_folder_view.vue'; -import { convertPermissionToBoolean } from '../../lib/utils/common_utils'; +import { parseBoolean } from '../../lib/utils/common_utils'; import Translate from '../../vue_shared/translate'; Vue.use(Translate); @@ -18,8 +18,8 @@ export default () => endpoint: environmentsData.endpoint, folderName: environmentsData.folderName, cssContainerClass: environmentsData.cssClass, - canCreateDeployment: convertPermissionToBoolean(environmentsData.canCreateDeployment), - canReadEnvironment: convertPermissionToBoolean(environmentsData.canReadEnvironment), + canCreateDeployment: parseBoolean(environmentsData.canCreateDeployment), + canReadEnvironment: parseBoolean(environmentsData.canReadEnvironment), }; }, render(createElement) { diff --git a/app/assets/javascripts/environments/index.js b/app/assets/javascripts/environments/index.js index 5b6833fb15d..d366e7550b7 100644 --- a/app/assets/javascripts/environments/index.js +++ b/app/assets/javascripts/environments/index.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import environmentsComponent from './components/environments_app.vue'; -import { convertPermissionToBoolean } from '../lib/utils/common_utils'; +import { parseBoolean } from '../lib/utils/common_utils'; import Translate from '../vue_shared/translate'; Vue.use(Translate); @@ -19,9 +19,9 @@ export default () => newEnvironmentPath: environmentsData.newEnvironmentPath, helpPagePath: environmentsData.helpPagePath, cssContainerClass: environmentsData.cssClass, - canCreateEnvironment: convertPermissionToBoolean(environmentsData.canCreateEnvironment), - canCreateDeployment: convertPermissionToBoolean(environmentsData.canCreateDeployment), - canReadEnvironment: convertPermissionToBoolean(environmentsData.canReadEnvironment), + canCreateEnvironment: parseBoolean(environmentsData.canCreateEnvironment), + canCreateDeployment: parseBoolean(environmentsData.canCreateDeployment), + canReadEnvironment: parseBoolean(environmentsData.canReadEnvironment), }; }, render(createElement) { diff --git a/app/assets/javascripts/ide/index.js b/app/assets/javascripts/ide/index.js index 7a5a227db30..fbf944499d5 100644 --- a/app/assets/javascripts/ide/index.js +++ b/app/assets/javascripts/ide/index.js @@ -4,7 +4,7 @@ import Translate from '~/vue_shared/translate'; import ide from './components/ide.vue'; import store from './stores'; import router from './ide_router'; -import { convertPermissionToBoolean } from '../lib/utils/common_utils'; +import { parseBoolean } from '../lib/utils/common_utils'; Vue.use(Translate); @@ -40,7 +40,7 @@ export function initIde(el, options = {}) { webIDEHelpPagePath: el.dataset.webIdeHelpPagePath, }); this.setInitialData({ - clientsidePreviewEnabled: convertPermissionToBoolean(el.dataset.clientsidePreviewEnabled), + clientsidePreviewEnabled: parseBoolean(el.dataset.clientsidePreviewEnabled), ...extraInitialData(el), }); }, diff --git a/app/assets/javascripts/importer_status.js b/app/assets/javascripts/importer_status.js index f1beb1a8ea5..1ffd5c61282 100644 --- a/app/assets/javascripts/importer_status.js +++ b/app/assets/javascripts/importer_status.js @@ -3,7 +3,7 @@ import _ from 'underscore'; import { __, sprintf } from './locale'; import axios from './lib/utils/axios_utils'; import flash from './flash'; -import { convertPermissionToBoolean } from './lib/utils/common_utils'; +import { parseBoolean } from './lib/utils/common_utils'; class ImporterStatus { constructor({ jobsUrl, importUrl, ciCdOnly }) { @@ -141,7 +141,7 @@ function initImporterStatus() { return new ImporterStatus({ jobsUrl: data.jobsImportPath, importUrl: data.importPath, - ciCdOnly: convertPermissionToBoolean(data.ciCdOnly), + ciCdOnly: parseBoolean(data.ciCdOnly), }); } } diff --git a/app/assets/javascripts/monitoring/monitoring_bundle.js b/app/assets/javascripts/monitoring/monitoring_bundle.js index 41270e015d4..9d78b5ea110 100644 --- a/app/assets/javascripts/monitoring/monitoring_bundle.js +++ b/app/assets/javascripts/monitoring/monitoring_bundle.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import { convertPermissionToBoolean } from '~/lib/utils/common_utils'; +import { parseBoolean } from '~/lib/utils/common_utils'; import Dashboard from './components/dashboard.vue'; export default () => { @@ -13,7 +13,7 @@ export default () => { return createElement(Dashboard, { props: { ...el.dataset, - hasMetrics: convertPermissionToBoolean(el.dataset.hasMetrics), + hasMetrics: parseBoolean(el.dataset.hasMetrics), }, }); }, diff --git a/app/assets/javascripts/pages/projects/pipelines/index/index.js b/app/assets/javascripts/pages/projects/pipelines/index/index.js index fc337a7609b..fd72d2ddbe0 100644 --- a/app/assets/javascripts/pages/projects/pipelines/index/index.js +++ b/app/assets/javascripts/pages/projects/pipelines/index/index.js @@ -2,7 +2,7 @@ import Vue from 'vue'; import PipelinesStore from '../../../../pipelines/stores/pipelines_store'; import pipelinesComponent from '../../../../pipelines/components/pipelines.vue'; import Translate from '../../../../vue_shared/translate'; -import { convertPermissionToBoolean } from '../../../../lib/utils/common_utils'; +import { parseBoolean } from '../../../../lib/utils/common_utils'; Vue.use(Translate); @@ -33,8 +33,8 @@ document.addEventListener( noPipelinesSvgPath: this.dataset.noPipelinesSvgPath, autoDevopsPath: this.dataset.helpAutoDevopsPath, newPipelinePath: this.dataset.newPipelinePath, - canCreatePipeline: convertPermissionToBoolean(this.dataset.canCreatePipeline), - hasGitlabCi: convertPermissionToBoolean(this.dataset.hasGitlabCi), + canCreatePipeline: parseBoolean(this.dataset.canCreatePipeline), + hasGitlabCi: parseBoolean(this.dataset.hasGitlabCi), ciLintPath: this.dataset.ciLintPath, resetCachePath: this.dataset.resetCachePath, }, diff --git a/app/assets/javascripts/toggle_buttons.js b/app/assets/javascripts/toggle_buttons.js index d83ffc7e211..bcb44bf7acf 100644 --- a/app/assets/javascripts/toggle_buttons.js +++ b/app/assets/javascripts/toggle_buttons.js @@ -1,7 +1,7 @@ import $ from 'jquery'; import Flash from './flash'; import { __ } from './locale'; -import { convertPermissionToBoolean } from './lib/utils/common_utils'; +import { parseBoolean } from './lib/utils/common_utils'; /* example HAML: @@ -18,7 +18,7 @@ function updateToggle(toggle, isOn) { } function onToggleClicked(toggle, input, clickCallback) { - const previousIsOn = convertPermissionToBoolean(input.value); + const previousIsOn = parseBoolean(input.value); // Visually change the toggle and start loading updateToggle(toggle, !previousIsOn); @@ -51,7 +51,7 @@ export default function setupToggleButtons(container, clickCallback = () => {}) toggles.forEach(toggle => { const input = toggle.querySelector('.js-project-feature-toggle-input'); - const isOn = convertPermissionToBoolean(input.value); + const isOn = parseBoolean(input.value); // Get the visible toggle in sync with the hidden input updateToggle(toggle, isOn); diff --git a/app/assets/javascripts/usage_ping_consent.js b/app/assets/javascripts/usage_ping_consent.js index 05607f09a7e..d3d745a3c11 100644 --- a/app/assets/javascripts/usage_ping_consent.js +++ b/app/assets/javascripts/usage_ping_consent.js @@ -1,7 +1,7 @@ import $ from 'jquery'; import axios from './lib/utils/axios_utils'; import Flash, { hideFlash } from './flash'; -import { convertPermissionToBoolean } from './lib/utils/common_utils'; +import { parseBoolean } from './lib/utils/common_utils'; export default () => { $('body').on('click', '.js-usage-consent-action', e => { @@ -11,8 +11,8 @@ export default () => { const { url, checkEnabled, pingEnabled } = e.target.dataset; const data = { application_setting: { - version_check_enabled: convertPermissionToBoolean(checkEnabled), - usage_ping_enabled: convertPermissionToBoolean(pingEnabled), + version_check_enabled: parseBoolean(checkEnabled), + usage_ping_enabled: parseBoolean(pingEnabled), }, }; |