cluster_check_popup.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. /**
  20. * popup to display requirements that are not met
  21. * for current action
  22. * @param data
  23. * @param popup
  24. * @param configs
  25. * @param upgradeVersion
  26. * @returns {*|void}
  27. */
  28. App.showClusterCheckPopup = function (data, popup, configs, upgradeVersion) {
  29. var fails = data.items.filterProperty('UpgradeChecks.status', 'FAIL'),
  30. warnings = data.items.filterProperty('UpgradeChecks.status', 'WARNING'),
  31. bypass = data.items.filterProperty('UpgradeChecks.status', 'BYPASS'),
  32. hasConfigsMergeConflicts = !!(configs && configs.length),
  33. primary,
  34. secondary,
  35. popupBody;
  36. popup = popup || {};
  37. primary = Em.isNone(popup.primary) ?
  38. (fails.length ? Em.I18n.t('common.dismiss') : Em.I18n.t('common.proceedAnyway')) : popup.primary;
  39. secondary = Em.isNone(popup.secondary) ? (fails.length ? false : Em.I18n.t('common.cancel')) : popup.secondary;
  40. popupBody = {
  41. failTitle: popup.failTitle,
  42. failAlert: popup.failAlert,
  43. warningTitle: popup.warningTitle,
  44. warningAlert: popup.warningAlert,
  45. templateName: require('templates/common/modal_popups/cluster_check_dialog'),
  46. fails: fails,
  47. bypass: bypass, // errors that can be bypassed
  48. warnings: warnings,
  49. hasConfigsMergeConflicts: hasConfigsMergeConflicts,
  50. isAllPassed: !fails.length && !warnings.length && !bypass.length && !hasConfigsMergeConflicts
  51. };
  52. if (hasConfigsMergeConflicts) {
  53. popupBody.configsMergeTable = Em.View.extend({
  54. templateName: require('templates/main/admin/stack_upgrade/upgrade_configs_merge_table'),
  55. configs: configs,
  56. didInsertElement: function () {
  57. App.tooltip($('.recommended-value'), {
  58. title: upgradeVersion
  59. });
  60. }
  61. });
  62. }
  63. return App.ModalPopup.show({
  64. primary: primary,
  65. secondary: secondary,
  66. header: popup.header,
  67. classNames: ['cluster-check-popup'],
  68. bodyClass: Em.View.extend(popupBody),
  69. onPrimary: function () {
  70. this._super();
  71. if (!popup.noCallbackCondition && popup.callback) {
  72. popup.callback();
  73. }
  74. },
  75. didInsertElement: function () {
  76. this._super();
  77. this.fitHeight();
  78. }
  79. });
  80. };