TabIconUpgrade.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /*
  6. *+------------------------------------------------------------------------+
  7. *| Licensed Materials - Property of IBM
  8. *| IBM Cognos Products: BI Dashboard
  9. *| (C) Copyright IBM Corp. 2020
  10. *|
  11. *| US Government Users Restricted Rights - Use, duplication or disclosure
  12. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  13. *+------------------------------------------------------------------------+
  14. */
  15. define(['../../../lib/@waca/upgrades/UpgradeBase'], function (UpgradeBase) {
  16. var icon_map = {
  17. 'announcement_16_v4': 'bullhorn',
  18. 'api_16_v4': 'api',
  19. 'archive_16_v4': 'archive',
  20. 'asset_16_v4': 'microphone',
  21. 'attachment_16_v4': 'attachment',
  22. 'audio_16_v4': 'audio',
  23. 'bee_16_v4': 'bee',
  24. 'blog_16_v4': 'blog',
  25. 'bookmark_16_v4': 'bookmark',
  26. 'calendar_16_v4': 'calendar',
  27. 'camera_16_v4': 'camera',
  28. 'capability_16_v4': 'capability',
  29. 'catalog_16_v4': 'catalog',
  30. 'chat-message_16_v4': 'message',
  31. 'checkout-cart_16_v4': 'checkout',
  32. 'client_16_v4': 'client',
  33. 'clock_24_v4': 'clock',
  34. 'cloud_16_v4': 'cloud',
  35. 'code_16_v4': 'code',
  36. 'data-quality_16_v4': 'data-quality',
  37. 'folder_16_v5': 'folder',
  38. 'forum_16_v4': 'forum',
  39. 'glasses_16_v4': 'glasses',
  40. 'group_16_v5': 'group',
  41. 'hat_16_v4': 'hat',
  42. 'headphones_16_v4': 'headphones',
  43. 'hills_24_v4': 'hills',
  44. 'home_16_v4': 'home',
  45. 'idea_16_v4': 'idea',
  46. 'image-file_32_v4': 'image',
  47. 'inventory_24_v4': 'inventory',
  48. 'like_16_v4': 'like',
  49. 'link_16_v5': 'link',
  50. 'location_16_v5': 'location',
  51. 'manage_16_v4': 'settings',
  52. 'markup-pen_16_v4': 'pen',
  53. 'mobile-phone_16_v4': 'mobile',
  54. 'music_16_v4': 'music',
  55. 'notifications_16_v4': 'notifications',
  56. 'paint_24_v4': 'paint',
  57. 'payment-card_16_v4': 'payment',
  58. 'password-key_32_v4': 'password-key',
  59. 'people_16_v4': 'people',
  60. 'person_16_v4': 'person',
  61. 'phone-call_16_v4': 'phone',
  62. 'pin_16_v4': 'pin',
  63. 'print_16_v4': 'print',
  64. 'recording_16_v4': 'recording',
  65. 'repository_16_v5': 'repository',
  66. 'role_16_v4': 'role',
  67. 'search_16_v5': 'search',
  68. 'settings_16_v4': 'settings',
  69. 'speaker_16_v4': 'speaker',
  70. 'star-rating_16_v4': 'star',
  71. 'tag_16_v4': 'tag',
  72. 'thumbs-up_16_v4': 'thumbs-up',
  73. 'thumbs-down_16_v4': 'thumbs-down',
  74. 'tools_16_v4': 'tools',
  75. 'traffic_16_v4': 'traffic',
  76. 'trash_16_v4': 'trash',
  77. 'twitter_16_v4': 'twitter',
  78. 'unknown_16_v4': 'unknown',
  79. 'user_16_v4': 'user',
  80. 'venn-diagram_16_v4': 'venn-diagram',
  81. 'video_16_v4': 'video',
  82. 'view_16_v4': 'view',
  83. 'warn_16_v5': 'warning',
  84. 'watch_24_v4': 'watch',
  85. 'watson_24_v4': 'watson',
  86. 'wikis_16_v4': 'wikis',
  87. 'workspace_16_v4': 'workspace',
  88. 'world_16_v4': 'world'
  89. };
  90. var TabIconUpgrade = function (_UpgradeBase) {
  91. _inherits(TabIconUpgrade, _UpgradeBase);
  92. function TabIconUpgrade() {
  93. _classCallCheck(this, TabIconUpgrade);
  94. var _this = _possibleConstructorReturn(this, _UpgradeBase.call(this));
  95. _this.VERSION = 1600;
  96. return _this;
  97. }
  98. /**
  99. * Perform upgrade to the tabIcon portion of the spec to replace what is
  100. * there with an alias that is mapped to the correct icon.
  101. *
  102. *
  103. * @param {object} spec - The widget spec that the upgrade is performed on
  104. *
  105. * @return {Promise} Promise to be resolved with upgrade performed.
  106. */
  107. TabIconUpgrade.prototype.up = function up(spec) {
  108. if (!spec) {
  109. return Promise.resolve(spec);
  110. }
  111. return this._upgradeWidgets(spec);
  112. };
  113. TabIconUpgrade.prototype._upgradeWidgets = function _upgradeWidgets(spec) {
  114. var _this2 = this;
  115. if (spec.layout.type === 'tab') {
  116. spec.layout.items.forEach(function (tab) {
  117. if (tab.tabIcon) {
  118. var newIcon = icon_map[tab.tabIcon.value];
  119. if (newIcon !== undefined) {
  120. tab.tabIcon = newIcon;
  121. } else {
  122. if (_this2.data && _this2.data.logger) {
  123. _this2.data.logger.warn('Unable to upgrade tab icon ' + tab.tabIcon.value + ' - replacing with default value');
  124. }
  125. delete tab.tabIcon;
  126. }
  127. }
  128. });
  129. }
  130. return Promise.resolve(spec);
  131. };
  132. return TabIconUpgrade;
  133. }(UpgradeBase);
  134. return new TabIconUpgrade();
  135. });
  136. //# sourceMappingURL=TabIconUpgrade.js.map