@bigbinary/neeto-themes-frontend 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -161,7 +161,7 @@ var useListThemes = function useListThemes(entityId) {
161
161
  };
162
162
  var useCreateTheme = function useCreateTheme() {
163
163
  return reactUtils.useMutationWithInvalidation(themesApi.create, {
164
- keysToInvalidate: [[useThemeUtils.QUERY_KEYS.THEMES_LIST], [useThemeUtils.QUERY_KEYS.GLOBAL_THEME_DETAILS]]
164
+ keysToInvalidate: [[useThemeUtils.QUERY_KEYS.THEMES_LIST], [useThemeUtils.QUERY_KEYS.THEME_ENTITY_DETAILS], [useThemeUtils.QUERY_KEYS.GLOBAL_THEME_DETAILS]]
165
165
  });
166
166
  };
167
167
  var useUpdateTheme = function useUpdateTheme(themeId) {
@@ -193,7 +193,7 @@ var useApplyTheme = function useApplyTheme(_ref) {
193
193
  };
194
194
  var useApplyGlobalTheme = function useApplyGlobalTheme() {
195
195
  return reactUtils.useMutationWithInvalidation(themesApi.applyGlobalTheme, {
196
- keysToInvalidate: [[useThemeUtils.QUERY_KEYS.GLOBAL_THEME_DETAILS]]
196
+ keysToInvalidate: [[useThemeUtils.QUERY_KEYS.GLOBAL_THEME_DETAILS], [useThemeUtils.QUERY_KEYS.THEMES_LIST], [useThemeUtils.QUERY_KEYS.THEME_ENTITY_DETAILS]]
197
197
  });
198
198
  };
199
199
 
@@ -1175,6 +1175,7 @@ var Customize = function Customize(_ref) {
1175
1175
  _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1176
1176
  globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
1177
1177
  var isThemeGlobalTheme = (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1178
+ var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
1178
1179
  var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1179
1180
  var submitBtnRef = react.useRef(null);
1180
1181
  var _useCreateTheme = useCreateTheme(),
@@ -1309,7 +1310,6 @@ var Customize = function Customize(_ref) {
1309
1310
  appendTo: function appendTo() {
1310
1311
  return document.body;
1311
1312
  },
1312
- disabled: isEditingCurrentlyAppliedTheme,
1313
1313
  position: "top",
1314
1314
  reference: submitBtnRef,
1315
1315
  trigger: "click",
@@ -1346,6 +1346,7 @@ var Customize = function Customize(_ref) {
1346
1346
  }
1347
1347
  })]
1348
1348
  }),
1349
+ disabled: isEditingCurrentlyAppliedTheme || isCurrentThemeAndGlobalThemeSame && values.shouldSetAsGlobalTheme,
1349
1350
  onMount: setPopoverInstance
1350
1351
  })]
1351
1352
  });
@@ -1661,6 +1662,7 @@ var Themes = function Themes(_ref) {
1661
1662
  thumbnail = _ref.thumbnail,
1662
1663
  themeBeingApplied = _ref.themeBeingApplied,
1663
1664
  onApplyTheme = _ref.onApplyTheme,
1665
+ onApplyGlobalThemeSuccess = _ref.onApplyGlobalThemeSuccess,
1664
1666
  isApplyingTheme = _ref.isApplyingTheme;
1665
1667
  var _useTranslation = reactI18next.useTranslation(),
1666
1668
  t = _useTranslation.t;
@@ -1729,6 +1731,10 @@ var Themes = function Themes(_ref) {
1729
1731
  applyGlobalTheme({
1730
1732
  themeId: themeId,
1731
1733
  payload: payload
1734
+ }, {
1735
+ onSuccess: function onSuccess() {
1736
+ onApplyGlobalThemeSuccess === null || onApplyGlobalThemeSuccess === void 0 ? void 0 : onApplyGlobalThemeSuccess();
1737
+ }
1732
1738
  });
1733
1739
  };
1734
1740
  if (isLoading || isCurrentThemeLoading || isLoadingGlobalTheme) {
@@ -1884,7 +1890,8 @@ var Sidebar = function Sidebar(_ref) {
1884
1890
  var thumbnail = _ref.thumbnail,
1885
1891
  onPropertiesChange = _ref.onPropertiesChange,
1886
1892
  onApplyThemeSuccess = _ref.onApplyThemeSuccess,
1887
- onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
1893
+ onUpdateThemeSuccess = _ref.onUpdateThemeSuccess,
1894
+ onApplyGlobalThemeSuccess = _ref.onApplyGlobalThemeSuccess;
1888
1895
  var _useState = react.useState(DESIGN_SCREENS.THEMES),
1889
1896
  _useState2 = _slicedToArray(_useState, 2),
1890
1897
  currentScreen = _useState2[0],
@@ -2055,6 +2062,7 @@ var Sidebar = function Sidebar(_ref) {
2055
2062
  highlightTheme: highlightTheme,
2056
2063
  isApplyingTheme: isApplyingTheme,
2057
2064
  isCurrentThemeLoading: isCurrentThemeLoading,
2065
+ onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2058
2066
  onApplyTheme: onApplyTheme,
2059
2067
  themeBeingApplied: themeBeingApplied,
2060
2068
  themeToHighlight: themeToHighlight,
@@ -2110,7 +2118,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2110
2118
  _ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
2111
2119
  onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? neetoCist.noop : _ref$onApplyThemeSucc,
2112
2120
  _ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
2113
- onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? neetoCist.noop : _ref$onUpdateThemeSuc;
2121
+ onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? neetoCist.noop : _ref$onUpdateThemeSuc,
2122
+ _ref$onApplyGlobalThe = _ref.onApplyGlobalThemeSuccess,
2123
+ onApplyGlobalThemeSuccess = _ref$onApplyGlobalThe === void 0 ? neetoCist.noop : _ref$onApplyGlobalThe;
2114
2124
  var _useThemeStore = useThemeUtils.useThemeStore(function (store) {
2115
2125
  return {
2116
2126
  setThemeState: store["setThemeState"]
@@ -2146,7 +2156,7 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2146
2156
  previewingTheme: currentTheme
2147
2157
  });
2148
2158
  setTheme(currentTheme);
2149
- }, [isLoading, entityId]);
2159
+ }, [isLoading, entityId, currentTheme]);
2150
2160
  react.useEffect(function () {
2151
2161
  if (neetoCist.isNotPresent(currentTheme)) return;
2152
2162
  setThemeState({
@@ -2157,6 +2167,7 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2157
2167
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2158
2168
  className: "neeto-themes__wrapper",
2159
2169
  children: [/*#__PURE__*/jsxRuntime.jsx(Sidebar, {
2170
+ onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2160
2171
  onApplyThemeSuccess: onApplyThemeSuccess,
2161
2172
  onPropertiesChange: onPropertiesChange,
2162
2173
  onUpdateThemeSuccess: onUpdateThemeSuccess,