@bigbinary/neeto-themes-frontend 1.2.4 → 1.2.6

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.
package/dist/index.js CHANGED
@@ -42,7 +42,9 @@ var useConfigStore = create$1(withImmutableActions(function (set) {
42
42
  entityType: "",
43
43
  entityId: "",
44
44
  variableNamesMap: {},
45
+ defaultThemeName: "Plain blue",
45
46
  isFetchingSchema: true,
47
+ isTemplateThemesEnabled: false,
46
48
  setConfigState: set
47
49
  };
48
50
  }));
@@ -148,8 +150,12 @@ var useShowThemeEntity = function useShowThemeEntity(entityId) {
148
150
  };
149
151
 
150
152
  var _excluded$1 = ["themeId"];
151
- var list$1 = function list() {
152
- return axios.get("".concat(BASE_URL, "/api/v1/themes"));
153
+ var list$1 = function list(entityId) {
154
+ return axios.get("".concat(BASE_URL, "/api/v1/themes"), {
155
+ params: {
156
+ entity_id: entityId
157
+ }
158
+ });
153
159
  };
154
160
  var show = function show(id) {
155
161
  return axios.get("".concat(BASE_URL, "/api/v1/themes/").concat(id));
@@ -189,8 +195,17 @@ var themesApi = {
189
195
  apply: apply
190
196
  };
191
197
 
192
- var useListThemes = function useListThemes() {
193
- return useQuery(QUERY_KEYS.THEMES_LIST, themesApi.list);
198
+ var useListThemes = function useListThemes(entityId) {
199
+ var _useConfigStore = useConfigStore(function (store) {
200
+ return {
201
+ isTemplateThemesEnabled: store["isTemplateThemesEnabled"]
202
+ };
203
+ }, shallow),
204
+ isTemplateThemesEnabled = _useConfigStore.isTemplateThemesEnabled;
205
+ var queryKey = isTemplateThemesEnabled ? [QUERY_KEYS.THEMES_LIST, entityId] : [QUERY_KEYS.THEMES_LIST];
206
+ return useQuery(queryKey, function () {
207
+ return themesApi.list(entityId);
208
+ });
194
209
  };
195
210
  var useCreateTheme = function useCreateTheme() {
196
211
  return useMutationWithInvalidation(themesApi.create, {
@@ -286,10 +301,13 @@ var useThemeUtils = function useThemeUtils() {
286
301
  var _ref$schema = _ref.schema,
287
302
  themePropertiesSchema = _ref$schema === void 0 ? [] : _ref$schema,
288
303
  _ref$variableNamesMap = _ref.variableNamesMap,
289
- variableNamesMap = _ref$variableNamesMap === void 0 ? {} : _ref$variableNamesMap;
304
+ variableNamesMap = _ref$variableNamesMap === void 0 ? {} : _ref$variableNamesMap,
305
+ _ref$defaultThemeName = _ref.defaultThemeName,
306
+ defaultThemeName = _ref$defaultThemeName === void 0 ? "" : _ref$defaultThemeName;
290
307
  return setConfigState({
291
308
  themePropertiesSchema: themePropertiesSchema,
292
- variableNamesMap: variableNamesMap
309
+ variableNamesMap: variableNamesMap,
310
+ defaultThemeName: defaultThemeName
293
311
  });
294
312
  }
295
313
  }),
@@ -1635,7 +1653,7 @@ var TitleBar = function TitleBar(_ref) {
1635
1653
 
1636
1654
  var MemoizedAlert = /*#__PURE__*/memo(Alert);
1637
1655
  var Sidebar = function Sidebar(_ref) {
1638
- var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3;
1656
+ var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
1639
1657
  var thumbnail = _ref.thumbnail,
1640
1658
  onPropertiesChange = _ref.onPropertiesChange;
1641
1659
  var _useState = useState(DESIGN_SCREENS.THEMES),
@@ -1658,12 +1676,14 @@ var Sidebar = function Sidebar(_ref) {
1658
1676
  return {
1659
1677
  entityType: store["entityType"],
1660
1678
  entityId: store["entityId"],
1661
- isFetchingSchema: store["isFetchingSchema"]
1679
+ isFetchingSchema: store["isFetchingSchema"],
1680
+ defaultThemeName: store["defaultThemeName"]
1662
1681
  };
1663
1682
  }, shallow),
1664
1683
  entityType = _useConfigStore.entityType,
1665
1684
  entityId = _useConfigStore.entityId,
1666
- isFetchingSchema = _useConfigStore.isFetchingSchema;
1685
+ isFetchingSchema = _useConfigStore.isFetchingSchema,
1686
+ defaultThemeName = _useConfigStore.defaultThemeName;
1667
1687
  var _useThemeStore = useThemeStore(function (store) {
1668
1688
  return {
1669
1689
  setThemeState: store["setThemeState"]
@@ -1675,7 +1695,7 @@ var Sidebar = function Sidebar(_ref) {
1675
1695
  t = _useTranslation.t;
1676
1696
  var _useThemeUtils = useThemeUtils(),
1677
1697
  setTheme = _useThemeUtils.setTheme;
1678
- var _useListThemes = useListThemes(),
1698
+ var _useListThemes = useListThemes(entityId),
1679
1699
  _useListThemes$data = _useListThemes.data,
1680
1700
  _useListThemes$data2 = _useListThemes$data === void 0 ? {} : _useListThemes$data,
1681
1701
  _useListThemes$data2$ = _useListThemes$data2.themes,
@@ -1815,7 +1835,10 @@ var Sidebar = function Sidebar(_ref) {
1815
1835
  message: t("neetoThemes.alerts.message.deleteTheme", {
1816
1836
  name: (_themeToDelete$curren2 = themeToDelete.current) === null || _themeToDelete$curren2 === void 0 ? void 0 : _themeToDelete$curren2.name,
1817
1837
  count: (_themeToDelete$curren3 = themeToDelete.current) === null || _themeToDelete$curren3 === void 0 ? void 0 : _themeToDelete$curren3.appliedCount,
1818
- entityType: entityType
1838
+ defaultThemeName: defaultThemeName,
1839
+ entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()), {
1840
+ count: (_themeToDelete$curren4 = themeToDelete.current) === null || _themeToDelete$curren4 === void 0 ? void 0 : _themeToDelete$curren4.appliedCount
1841
+ })
1819
1842
  }),
1820
1843
  onClose: handleCloseDeleteAlert,
1821
1844
  onSubmit: handleDeleteTheme
@@ -1828,7 +1851,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
1828
1851
  entityType = _ref.entityType,
1829
1852
  entityId = _ref.entityId,
1830
1853
  thumbnail = _ref.thumbnail,
1831
- onPropertiesChange = _ref.onPropertiesChange;
1854
+ onPropertiesChange = _ref.onPropertiesChange,
1855
+ _ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
1856
+ isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes;
1832
1857
  var _useThemeStore = useThemeStore(function (store) {
1833
1858
  return {
1834
1859
  isCurrentThemeLoading: store["isCurrentThemeLoading"]
@@ -1844,7 +1869,8 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
1844
1869
  useEffect(function () {
1845
1870
  setConfigState({
1846
1871
  entityType: entityType,
1847
- entityId: entityId
1872
+ entityId: entityId,
1873
+ isTemplateThemesEnabled: isTemplateThemesEnabled
1848
1874
  });
1849
1875
  }, []);
1850
1876
  return /*#__PURE__*/jsxs("div", {