@bigbinary/neeto-themes-frontend 3.0.1 → 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.
@@ -63,7 +63,7 @@
63
63
  "delete": "Delete",
64
64
  "setAsGlobalTheme": {
65
65
  "label": "Set as global theme",
66
- "helpText": "Enabling this will set this theme as the default theme, automatically applying it to all your future {{entityType}}s.",
66
+ "helpText": "Enabling this will set this theme as the default theme, automatically applying it to all your future {{entityType}}s. This theme will also be applied to the {{entityType}}s that uses the previous global theme.",
67
67
  "tooltipContent": "This theme is currently set as the global theme. Select another theme to change it."
68
68
  }
69
69
  },
@@ -140,7 +140,7 @@ var useListThemes = function useListThemes(entityId) {
140
140
  };
141
141
  var useCreateTheme = function useCreateTheme() {
142
142
  return useMutationWithInvalidation(themesApi.create, {
143
- keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.GLOBAL_THEME_DETAILS]]
143
+ keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.GLOBAL_THEME_DETAILS]]
144
144
  });
145
145
  };
146
146
  var useUpdateTheme = function useUpdateTheme(themeId) {
@@ -172,7 +172,7 @@ var useApplyTheme = function useApplyTheme(_ref) {
172
172
  };
173
173
  var useApplyGlobalTheme = function useApplyGlobalTheme() {
174
174
  return useMutationWithInvalidation(themesApi.applyGlobalTheme, {
175
- keysToInvalidate: [[QUERY_KEYS.GLOBAL_THEME_DETAILS]]
175
+ keysToInvalidate: [[QUERY_KEYS.GLOBAL_THEME_DETAILS], [QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS]]
176
176
  });
177
177
  };
178
178
 
@@ -1146,13 +1146,15 @@ var Customize = function Customize(_ref) {
1146
1146
  themePropertiesSchema = _useConfigStore.themePropertiesSchema,
1147
1147
  entityType = _useConfigStore.entityType;
1148
1148
  var _useThemeUtils = useThemeUtils(),
1149
- currentTheme = _useThemeUtils.currentTheme;
1149
+ currentTheme = _useThemeUtils.currentTheme,
1150
+ setThemeState = _useThemeUtils.setThemeState;
1150
1151
  var _useShowGlobalTheme = useShowGlobalTheme(entityType),
1151
1152
  _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1152
1153
  _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
1153
1154
  _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1154
1155
  globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
1155
1156
  var isThemeGlobalTheme = (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1157
+ var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
1156
1158
  var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1157
1159
  var submitBtnRef = useRef(null);
1158
1160
  var _useCreateTheme = useCreateTheme(),
@@ -1187,11 +1189,15 @@ var Customize = function Customize(_ref) {
1187
1189
  });
1188
1190
  }
1189
1191
  return updateTheme(themeToSave, {
1190
- onSuccess: function onSuccess() {
1192
+ onSuccess: function onSuccess(_ref4) {
1193
+ var theme = _ref4.theme;
1194
+ onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(theme);
1195
+ setThemeState({
1196
+ previewingTheme: theme
1197
+ });
1191
1198
  resetForm({
1192
- values: values
1199
+ values: theme
1193
1200
  });
1194
- onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(values);
1195
1201
  }
1196
1202
  });
1197
1203
  };
@@ -1205,10 +1211,10 @@ var Customize = function Customize(_ref) {
1205
1211
  enableReinitialize: true,
1206
1212
  onSubmit: onSubmit
1207
1213
  },
1208
- children: function children(_ref4) {
1209
- var dirty = _ref4.dirty,
1210
- values = _ref4.values,
1211
- setFieldValue = _ref4.setFieldValue;
1214
+ children: function children(_ref5) {
1215
+ var dirty = _ref5.dirty,
1216
+ values = _ref5.values,
1217
+ setFieldValue = _ref5.setFieldValue;
1212
1218
  return /*#__PURE__*/jsxs("div", {
1213
1219
  className: "neeto-themes-sidebar__scroll",
1214
1220
  children: [/*#__PURE__*/jsxs("div", {
@@ -1228,8 +1234,8 @@ var Customize = function Customize(_ref) {
1228
1234
  })
1229
1235
  }), filterBy({
1230
1236
  kind: "image"
1231
- }, themePropertiesSchema).map(function (_ref5) {
1232
- var key = _ref5.key;
1237
+ }, themePropertiesSchema).map(function (_ref6) {
1238
+ var key = _ref6.key;
1233
1239
  return /*#__PURE__*/createElement(Images, {
1234
1240
  onPropertiesChange: onPropertiesChange,
1235
1241
  attribute: key,
@@ -1283,7 +1289,6 @@ var Customize = function Customize(_ref) {
1283
1289
  appendTo: function appendTo() {
1284
1290
  return document.body;
1285
1291
  },
1286
- disabled: isEditingCurrentlyAppliedTheme,
1287
1292
  position: "top",
1288
1293
  reference: submitBtnRef,
1289
1294
  trigger: "click",
@@ -1320,6 +1325,7 @@ var Customize = function Customize(_ref) {
1320
1325
  }
1321
1326
  })]
1322
1327
  }),
1328
+ disabled: isEditingCurrentlyAppliedTheme || isCurrentThemeAndGlobalThemeSame && values.shouldSetAsGlobalTheme,
1323
1329
  onMount: setPopoverInstance
1324
1330
  })]
1325
1331
  });
@@ -1635,6 +1641,7 @@ var Themes = function Themes(_ref) {
1635
1641
  thumbnail = _ref.thumbnail,
1636
1642
  themeBeingApplied = _ref.themeBeingApplied,
1637
1643
  onApplyTheme = _ref.onApplyTheme,
1644
+ onApplyGlobalThemeSuccess = _ref.onApplyGlobalThemeSuccess,
1638
1645
  isApplyingTheme = _ref.isApplyingTheme;
1639
1646
  var _useTranslation = useTranslation(),
1640
1647
  t = _useTranslation.t;
@@ -1703,6 +1710,10 @@ var Themes = function Themes(_ref) {
1703
1710
  applyGlobalTheme({
1704
1711
  themeId: themeId,
1705
1712
  payload: payload
1713
+ }, {
1714
+ onSuccess: function onSuccess() {
1715
+ onApplyGlobalThemeSuccess === null || onApplyGlobalThemeSuccess === void 0 ? void 0 : onApplyGlobalThemeSuccess();
1716
+ }
1706
1717
  });
1707
1718
  };
1708
1719
  if (isLoading || isCurrentThemeLoading || isLoadingGlobalTheme) {
@@ -1858,7 +1869,8 @@ var Sidebar = function Sidebar(_ref) {
1858
1869
  var thumbnail = _ref.thumbnail,
1859
1870
  onPropertiesChange = _ref.onPropertiesChange,
1860
1871
  onApplyThemeSuccess = _ref.onApplyThemeSuccess,
1861
- onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
1872
+ onUpdateThemeSuccess = _ref.onUpdateThemeSuccess,
1873
+ onApplyGlobalThemeSuccess = _ref.onApplyGlobalThemeSuccess;
1862
1874
  var _useState = useState(DESIGN_SCREENS.THEMES),
1863
1875
  _useState2 = _slicedToArray(_useState, 2),
1864
1876
  currentScreen = _useState2[0],
@@ -2029,6 +2041,7 @@ var Sidebar = function Sidebar(_ref) {
2029
2041
  highlightTheme: highlightTheme,
2030
2042
  isApplyingTheme: isApplyingTheme,
2031
2043
  isCurrentThemeLoading: isCurrentThemeLoading,
2044
+ onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2032
2045
  onApplyTheme: onApplyTheme,
2033
2046
  themeBeingApplied: themeBeingApplied,
2034
2047
  themeToHighlight: themeToHighlight,
@@ -2084,7 +2097,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2084
2097
  _ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
2085
2098
  onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? noop : _ref$onApplyThemeSucc,
2086
2099
  _ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
2087
- onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? noop : _ref$onUpdateThemeSuc;
2100
+ onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? noop : _ref$onUpdateThemeSuc,
2101
+ _ref$onApplyGlobalThe = _ref.onApplyGlobalThemeSuccess,
2102
+ onApplyGlobalThemeSuccess = _ref$onApplyGlobalThe === void 0 ? noop : _ref$onApplyGlobalThe;
2088
2103
  var _useThemeStore = useThemeStore(function (store) {
2089
2104
  return {
2090
2105
  setThemeState: store["setThemeState"]
@@ -2120,7 +2135,7 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2120
2135
  previewingTheme: currentTheme
2121
2136
  });
2122
2137
  setTheme(currentTheme);
2123
- }, [isLoading, entityId]);
2138
+ }, [isLoading, entityId, currentTheme]);
2124
2139
  useEffect(function () {
2125
2140
  if (isNotPresent(currentTheme)) return;
2126
2141
  setThemeState({
@@ -2131,6 +2146,7 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2131
2146
  return /*#__PURE__*/jsxs("div", {
2132
2147
  className: "neeto-themes__wrapper",
2133
2148
  children: [/*#__PURE__*/jsx(Sidebar, {
2149
+ onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2134
2150
  onApplyThemeSuccess: onApplyThemeSuccess,
2135
2151
  onPropertiesChange: onPropertiesChange,
2136
2152
  onUpdateThemeSuccess: onUpdateThemeSuccess,