瀏覽代碼

HUE-8727 [frontend] Consolidate Chrome autofill prevention attributes into a global variable

Johan Ahlen 6 年之前
父節點
當前提交
fb9a5c557a

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/components/ko.queryHistory.js

@@ -51,7 +51,7 @@ const TEMPLATE = `
 
 <div class="snippet-tab-actions">
   <form autocomplete="off" class="inline-block">
-    <input class="input-small search-input" type="text" autocorrect="off" autocomplete="do-not-autocomplete" autocapitalize="off" spellcheck="false" placeholder="${ I18n('Search...') }" data-bind="
+    <input class="input-small search-input" type="text" ${ window.PREVENT_AUTOFILL_INPUT_ATTRS } placeholder="${ I18n('Search...') }" data-bind="
         textInput: historyFilter,
         clearable: historyFilter
       "/>

+ 2 - 0
desktop/core/src/desktop/js/jest/jest.init.js

@@ -39,6 +39,8 @@ const globalVars = {
   },
   LOGGED_USERNAME: 'foo',
   LOGGED_USER_ID: 'bar',
+  PREVENT_AUTOFILL_INPUT_ATTRS:
+    'autocorrect="off" autocomplete="do-not-autocomplete" autocapitalize="off" spellcheck="false"',
   STATIC_URLS: {
     'impala/art/icon_impala_48.png': 'impala/art/icon_impala_48.png',
     'beeswax/art/icon_beeswax_48.png': 'beeswax/art/icon_beeswax_48.png'

+ 2 - 1
desktop/core/src/desktop/js/ko/components/assist/ko.assistDocumentsPanel.js

@@ -24,6 +24,7 @@ import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
 import { DOCUMENT_TYPES } from 'doc/docSupport';
 
+// prettier-ignore
 const TEMPLATE = `
   <script type="text/html" id="document-context-items">
     <!-- ko if: definition().type === 'directory' -->
@@ -178,7 +179,7 @@ const TEMPLATE = `
   <div class="assist-flex-search">
     <div class="assist-filter">
       <form autocomplete="off">
-        <input class="clearable" type="text" autocorrect="off" autocomplete="do-not-autocomplete" spellcheck="false" placeholder="${I18n(
+        <input class="clearable" type="text" ${ window.PREVENT_AUTOFILL_INPUT_ATTRS } placeholder="${I18n(
           'Filter...'
         )}" data-bind="clearable: filter, value: filter, valueUpdate: 'afterkeydown'"/>
       </form>

+ 2 - 1
desktop/core/src/desktop/js/ko/components/assist/ko.assistFunctionsPanel.js

@@ -22,6 +22,7 @@ import huePubSub from 'utils/huePubSub';
 import { PigFunctions, SqlFunctions } from 'sql/sqlFunctions';
 import I18n from 'utils/i18n';
 
+// prettier-ignore
 const TEMPLATE = `
   <div class="assist-inner-panel">
     <div class="assist-flex-panel">
@@ -35,7 +36,7 @@ const TEMPLATE = `
       <div class="assist-flex-search">
         <div class="assist-filter">
           <form autocomplete="off">
-            <input class="clearable" type="text" autocorrect="off" autocomplete="do-not-autocomplete" spellcheck="false" placeholder="Filter..." data-bind="clearable: query, value: query, valueUpdate: 'afterkeydown'">
+            <input class="clearable" type="text" ${ window.PREVENT_AUTOFILL_INPUT_ATTRS } placeholder="Filter..." data-bind="clearable: query, value: query, valueUpdate: 'afterkeydown'">
           </form>
         </div>
       </div>

+ 2 - 1
desktop/core/src/desktop/js/ko/components/assist/ko.assistLangRefPanel.js

@@ -22,6 +22,7 @@ import componentUtils from 'ko/components/componentUtils';
 import huePubSub from 'utils/huePubSub';
 import I18n from 'utils/i18n';
 
+// prettier-ignore
 const TEMPLATE = `
   <script type="text/html" id="language-reference-topic-tree">
     <!-- ko if: $data.length -->
@@ -51,7 +52,7 @@ const TEMPLATE = `
       <div class="assist-flex-search">
         <div class="assist-filter">
           <form autocomplete="off">
-            <input class="clearable" type="text" autocorrect="off" autocomplete="do-not-autocomplete" spellcheck="false" placeholder="Filter..." data-bind="clearable: query, value: query, valueUpdate: 'afterkeydown'">
+            <input class="clearable" type="text" ${ window.PREVENT_AUTOFILL_INPUT_ATTRS } placeholder="Filter..." data-bind="clearable: query, value: query, valueUpdate: 'afterkeydown'">
           </form>
         </div>
       </div>

+ 2 - 1
desktop/core/src/desktop/js/ko/components/assist/ko.assistStoragePanel.js

@@ -22,6 +22,7 @@ import componentUtils from 'ko/components/componentUtils';
 import huePubSub from '../../../utils/huePubSub';
 import I18n from 'utils/i18n';
 
+// prettier-ignore
 const TEMPLATE = `
   <script type="text/html" id="storage-context-items">
     <li><a href="javascript:void(0);" data-bind="click: function (data) { showContextPopover(data, { target: $parentContext.$contextSourceElement }, { left: -15, top: 2 }); }"><i class="fa fa-fw fa-info"></i> ${I18n(
@@ -127,7 +128,7 @@ const TEMPLATE = `
       <form autocomplete="off">
         <input class="clearable" type="text" placeholder="${I18n(
           'Filter...'
-        )}" autocorrect="off" autocomplete="do-not-autocomplete" autocapitalize="off" spellcheck="false"
+        )}" ${ window.PREVENT_AUTOFILL_INPUT_ATTRS }
         data-bind="clearable: filter, value: filter, valueUpdate: 'afterkeydown'"/>
       </form>
     </div>

+ 2 - 1
desktop/core/src/desktop/js/ko/components/ko.inlineAutocomplete.js

@@ -24,6 +24,7 @@ import I18n from 'utils/i18n';
 
 export const NAME = 'inline-autocomplete';
 
+// prettier-ignore
 const TEMPLATE = `
   <div class="inline-autocomp-container">
     <div>
@@ -36,7 +37,7 @@ const TEMPLATE = `
         <!-- /ko -->
       <!-- /ko-->
       <form autocomplete="off">
-        <input class="inline-autocomp-input" autocorrect="off" autocomplete="do-not-autocomplete" autocapitalize="off" spellcheck="false" type="text" data-bind="
+        <input class="inline-autocomp-input" ${ window.PREVENT_AUTOFILL_INPUT_ATTRS } type="text" data-bind="
           attr: { 'placeHolder' : hasFocus() ? '' : placeHolder },
           textInput: searchInput,
           hasFocus: hasFocus,

+ 2 - 0
desktop/core/src/desktop/templates/global_js_constants.mako

@@ -58,6 +58,8 @@
     window.CSRF_TOKEN = '';
   %endif
 
+  window.PREVENT_AUTOFILL_INPUT_ATTRS = 'autocorrect="off" autocomplete="do-not-autocomplete" autocapitalize="off" spellcheck="false"';
+
   window.APP_SWITCHER_ALTUS_BASE_URL = '${ APP_SWITCHER_ALTUS_BASE_URL.get() }';
   window.APP_SWITCHER_MOW_BASE_URL = '${ APP_SWITCHER_MOW_BASE_URL.get() }';
   window.DISPLAY_APP_SWITCHER = '${ DISPLAY_APP_SWITCHER.get() }' === 'True';