@bigbinary/neeto-themes-frontend 3.0.4 → 3.1.1

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.
@@ -6,31 +6,34 @@ var i18next = require('i18next');
6
6
  var neetoCist = require('@bigbinary/neeto-cist');
7
7
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
8
8
  var Spinner = require('@bigbinary/neetoui/Spinner');
9
+ var utils = require('../index-BvWiXoC1.js');
9
10
  var reactQuery = require('@tanstack/react-query');
10
11
  var axios = require('axios');
11
- var utils = require('../index-D6l2IgrM.js');
12
- var useThemeUtils = require('../useThemeUtils-P5tn1h2B.js');
12
+ var useThemeUtils = require('../useThemeUtils-DrdkjWvi.js');
13
13
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
14
14
  var classnames = require('classnames');
15
+ var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
15
16
  var Collapse = require('@bigbinary/neeto-icons/Collapse');
16
17
  var Alert = require('@bigbinary/neetoui/Alert');
17
18
  var Button = require('@bigbinary/neetoui/Button');
18
19
  var reactI18next = require('react-i18next');
19
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
20
+ var reactRouterDom = require('react-router-dom');
20
21
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
22
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
21
23
  var Close = require('@bigbinary/neeto-icons/Close');
24
+ var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
22
25
  var Popover = require('@bigbinary/neetoui/Popover');
23
26
  var Typography = require('@bigbinary/neetoui/Typography');
24
27
  var Switch = require('@bigbinary/neetoui/Switch');
25
28
  var Tooltip = require('@bigbinary/neetoui/Tooltip');
26
29
  var Form = require('@bigbinary/neetoui/formik/Form');
30
+ var BlockNavigation = require('@bigbinary/neetoui/formik/BlockNavigation');
31
+ var ramda = require('ramda');
27
32
  var yup = require('yup');
28
33
  var Editor = require('@monaco-editor/react');
29
34
  var formik = require('formik');
30
35
  var Down = require('@bigbinary/neeto-icons/Down');
31
36
  var jsxRuntime = require('react/jsx-runtime');
32
- var ramda = require('ramda');
33
- var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
34
37
  var CenterAlign = require('@bigbinary/neeto-icons/CenterAlign');
35
38
  var LeftAlign = require('@bigbinary/neeto-icons/LeftAlign');
36
39
  var ColorPicker = require('@bigbinary/neetoui/ColorPicker');
@@ -144,6 +147,8 @@ var themesApi = {
144
147
  applyGlobalTheme: applyGlobalTheme
145
148
  };
146
149
 
150
+ function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
151
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
147
152
  var useListThemes = function useListThemes(entityId) {
148
153
  var _useConfigStore = useThemeUtils.useConfigStore(function (store) {
149
154
  return {
@@ -159,19 +164,32 @@ var useListThemes = function useListThemes(entityId) {
159
164
  }
160
165
  });
161
166
  };
167
+ var useFetchTheme = function useFetchTheme(themeId, options) {
168
+ return reactQuery.useQuery(_objectSpread$6({
169
+ queryKey: [useThemeUtils.QUERY_KEYS.THEME_DETAILS, themeId],
170
+ queryFn: function queryFn() {
171
+ return themesApi.show(themeId);
172
+ }
173
+ }, options));
174
+ };
162
175
  var useCreateTheme = function useCreateTheme() {
163
176
  return reactUtils.useMutationWithInvalidation(themesApi.create, {
164
177
  keysToInvalidate: [[useThemeUtils.QUERY_KEYS.THEMES_LIST], [useThemeUtils.QUERY_KEYS.THEME_ENTITY_DETAILS], [useThemeUtils.QUERY_KEYS.GLOBAL_THEME_DETAILS]]
165
178
  });
166
179
  };
167
180
  var useUpdateTheme = function useUpdateTheme(themeId) {
181
+ var queryClient = reactQuery.useQueryClient();
168
182
  return reactUtils.useMutationWithInvalidation(function (payload) {
169
183
  return themesApi.update({
170
184
  id: themeId,
171
185
  payload: payload
172
186
  });
173
187
  }, {
174
- keysToInvalidate: [[useThemeUtils.QUERY_KEYS.THEMES_LIST], [useThemeUtils.QUERY_KEYS.THEME_ENTITY_DETAILS], [useThemeUtils.QUERY_KEYS.THEME_DETAILS, themeId], [useThemeUtils.QUERY_KEYS.GLOBAL_THEME_DETAILS]]
188
+ keysToInvalidate: [[useThemeUtils.QUERY_KEYS.THEMES_LIST], [useThemeUtils.QUERY_KEYS.THEME_ENTITY_DETAILS], [useThemeUtils.QUERY_KEYS.THEME_DETAILS, themeId], [useThemeUtils.QUERY_KEYS.GLOBAL_THEME_DETAILS]],
189
+ onSuccess: function onSuccess(_ref) {
190
+ var theme = _ref.theme;
191
+ queryClient.setQueryData([useThemeUtils.QUERY_KEYS.THEME_DETAILS, themeId], theme);
192
+ }
175
193
  });
176
194
  };
177
195
  var useDeleteTheme = function useDeleteTheme() {
@@ -184,8 +202,8 @@ var useCloneTheme = function useCloneTheme() {
184
202
  keysToInvalidate: [useThemeUtils.QUERY_KEYS.THEMES_LIST]
185
203
  });
186
204
  };
187
- var useApplyTheme = function useApplyTheme(_ref) {
188
- var onSuccess = _ref.onSuccess;
205
+ var useApplyTheme = function useApplyTheme(_ref2) {
206
+ var onSuccess = _ref2.onSuccess;
189
207
  return reactUtils.useMutationWithInvalidation(themesApi.apply, {
190
208
  keysToInvalidate: [[useThemeUtils.QUERY_KEYS.THEMES_LIST], [useThemeUtils.QUERY_KEYS.THEME_ENTITY_DETAILS]],
191
209
  onSuccess: onSuccess
@@ -197,6 +215,14 @@ var useApplyGlobalTheme = function useApplyGlobalTheme() {
197
215
  });
198
216
  };
199
217
 
218
+ var routes = {
219
+ themes: {
220
+ index: "/themes",
221
+ edit: "/themes/:themeId/edit",
222
+ "new": "/themes/new"
223
+ }
224
+ };
225
+
200
226
  var show = function show(entityType) {
201
227
  return axios.get("".concat(utils.BASE_URL, "/api/v1/global_theme"), {
202
228
  params: {
@@ -361,9 +387,34 @@ var Card$2 = function Card(_ref) {
361
387
  });
362
388
  };
363
389
 
390
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
391
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
392
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
364
393
  var isScreenCustomCSS = function isScreenCustomCSS(screen) {
365
394
  return screen === DESIGN_SCREENS.CustomCSS;
366
395
  };
396
+ var buildPathname = function buildPathname(route) {
397
+ var pathname = "";
398
+ var _iterator = _createForOfIteratorHelper(location.pathname.split("/")),
399
+ _step;
400
+ try {
401
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
402
+ var segment = _step.value;
403
+ if (ramda.isEmpty(segment)) {
404
+ continue;
405
+ }
406
+ if (segment === "themes") {
407
+ break;
408
+ }
409
+ pathname += "/".concat(segment);
410
+ }
411
+ } catch (err) {
412
+ _iterator.e(err);
413
+ } finally {
414
+ _iterator.f();
415
+ }
416
+ return "".concat(pathname).concat(route);
417
+ };
367
418
 
368
419
  var CustomCSS = function CustomCSS(_ref) {
369
420
  var onEditCSSClick = _ref.onEditCSSClick,
@@ -1143,17 +1194,17 @@ var ThemeMeta = reactUtils.withT(function (_ref) {
1143
1194
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1144
1195
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1145
1196
  var Customize = function Customize(_ref) {
1146
- var themeId = _ref.themeId,
1147
- theme = _ref.theme,
1197
+ var theme = _ref.theme,
1148
1198
  onCreateTheme = _ref.onCreateTheme,
1149
1199
  onApplyTheme = _ref.onApplyTheme,
1200
+ onUpdateTheme = _ref.onUpdateTheme,
1150
1201
  isApplyingTheme = _ref.isApplyingTheme,
1151
1202
  onPropertiesChange = _ref.onPropertiesChange,
1152
- onUpdateThemeSuccess = _ref.onUpdateThemeSuccess,
1153
1203
  onEditCSSClick = _ref.onEditCSSClick,
1154
1204
  currentScreen = _ref.currentScreen;
1155
1205
  var _useTranslation = reactI18next.useTranslation(),
1156
1206
  t = _useTranslation.t;
1207
+ var history = reactRouterDom.useHistory();
1157
1208
  var _useState = react.useState({}),
1158
1209
  _useState2 = _slicedToArray(_useState, 2),
1159
1210
  popoverInstance = _useState2[0],
@@ -1166,15 +1217,29 @@ var Customize = function Customize(_ref) {
1166
1217
  }, shallow.shallow),
1167
1218
  themePropertiesSchema = _useConfigStore.themePropertiesSchema,
1168
1219
  entityType = _useConfigStore.entityType;
1169
- var _useThemeUtils = useThemeUtils.useThemeUtils(),
1170
- currentTheme = _useThemeUtils.currentTheme,
1171
- setThemeState = _useThemeUtils.setThemeState;
1220
+ var _useParams = reactRouterDom.useParams(),
1221
+ themeId = _useParams.themeId;
1222
+ var _useThemeStore = useThemeUtils.useThemeStore(function (store) {
1223
+ return {
1224
+ currentTheme: store["currentTheme"],
1225
+ setThemeState: store["setThemeState"]
1226
+ };
1227
+ }, shallow.shallow),
1228
+ currentTheme = _useThemeStore.currentTheme,
1229
+ setThemeState = _useThemeStore.setThemeState;
1172
1230
  var _useShowGlobalTheme = useShowGlobalTheme(entityType),
1173
1231
  _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1174
1232
  _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
1175
1233
  _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1176
1234
  globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
1177
- var isThemeGlobalTheme = (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1235
+ var _useFetchTheme = useFetchTheme(themeId, {
1236
+ enabled: utils.isEditThemeRoute() && ramda.isNotNil(themeId),
1237
+ initialData: theme !== null && theme !== void 0 ? theme : undefined
1238
+ }),
1239
+ _useFetchTheme$data = _useFetchTheme.data,
1240
+ themeData = _useFetchTheme$data === void 0 ? {} : _useFetchTheme$data,
1241
+ isLoading = _useFetchTheme.isLoading;
1242
+ var isThemeGlobalTheme = themeId && (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1178
1243
  var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
1179
1244
  var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1180
1245
  var submitBtnRef = react.useRef(null);
@@ -1206,25 +1271,35 @@ var Customize = function Customize(_ref) {
1206
1271
  values: theme
1207
1272
  });
1208
1273
  onCreateTheme(theme);
1274
+ history.replace(utils$1.buildUrl(buildPathname(routes.themes.edit), {
1275
+ themeId: theme.id
1276
+ }));
1209
1277
  }
1210
1278
  });
1211
1279
  }
1212
1280
  return updateTheme(themeToSave, {
1213
1281
  onSuccess: function onSuccess(_ref4) {
1214
1282
  var theme = _ref4.theme;
1215
- onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(theme);
1216
- setThemeState({
1217
- previewingTheme: theme
1218
- });
1283
+ onUpdateTheme(theme);
1219
1284
  resetForm({
1220
1285
  values: theme
1221
1286
  });
1222
1287
  }
1223
1288
  });
1224
1289
  };
1290
+ react.useEffect(function () {
1291
+ if (ramda.isNotNil(themeId) && !isLoading) {
1292
+ setThemeState({
1293
+ previewingTheme: themeData
1294
+ });
1295
+ }
1296
+ }, [themeData, isLoading]);
1297
+ if (isLoading) {
1298
+ return /*#__PURE__*/jsxRuntime.jsx(PageLoader, {});
1299
+ }
1225
1300
  return /*#__PURE__*/jsxRuntime.jsx(Form, {
1226
1301
  formikProps: {
1227
- initialValues: _objectSpread$1(_objectSpread$1({}, buildInitialValues(theme, themePropertiesSchema)), {}, {
1302
+ initialValues: _objectSpread$1(_objectSpread$1({}, buildInitialValues(themeData, themePropertiesSchema)), {}, {
1228
1303
  shouldSetAsGlobalTheme: isThemeGlobalTheme,
1229
1304
  entityType: entityType
1230
1305
  }),
@@ -1240,7 +1315,7 @@ var Customize = function Customize(_ref) {
1240
1315
  className: "neeto-themes-sidebar__scroll",
1241
1316
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1242
1317
  className: "neeto-themes-sidebar__scroll-content flex flex-grow flex-col px-4 pb-4 lg:px-5",
1243
- children: [/*#__PURE__*/jsxRuntime.jsx(ThemeMeta, {
1318
+ children: [!isSubmitting && /*#__PURE__*/jsxRuntime.jsx(BlockNavigation, {}), /*#__PURE__*/jsxRuntime.jsx(ThemeMeta, {
1244
1319
  className: classnames({
1245
1320
  hidden: isCustomCssScreen
1246
1321
  })
@@ -1300,7 +1375,7 @@ var Customize = function Customize(_ref) {
1300
1375
  type: "reset"
1301
1376
  }), /*#__PURE__*/jsxRuntime.jsx(Button, {
1302
1377
  "data-cy": "save-changes-button",
1303
- disabled: !dirty && (theme === null || theme === void 0 ? void 0 : theme.id) || isSubmitting,
1378
+ disabled: !dirty && (themeData === null || themeData === void 0 ? void 0 : themeData.id) || isSubmitting,
1304
1379
  label: t("neetoThemes.buttons.save"),
1305
1380
  loading: isSubmitting,
1306
1381
  ref: submitBtnRef,
@@ -1342,7 +1417,7 @@ var Customize = function Customize(_ref) {
1342
1417
  label: t("neetoThemes.buttons.applyThisTheme"),
1343
1418
  loading: isApplyingTheme,
1344
1419
  onClick: function onClick() {
1345
- return onApplyTheme(theme);
1420
+ return onApplyTheme(themeData);
1346
1421
  }
1347
1422
  })]
1348
1423
  }),
@@ -1823,11 +1898,16 @@ var Themes = function Themes(_ref) {
1823
1898
  var TitleBar = function TitleBar(_ref) {
1824
1899
  var currentScreen = _ref.currentScreen,
1825
1900
  handleBackPress = _ref.handleBackPress,
1826
- handleCreateNewTheme = _ref.handleCreateNewTheme,
1827
- isNewTheme = _ref.isNewTheme,
1828
- themeToEdit = _ref.themeToEdit;
1901
+ handleCreateNewTheme = _ref.handleCreateNewTheme;
1829
1902
  var _useTranslation = reactI18next.useTranslation(),
1830
1903
  t = _useTranslation.t;
1904
+ var _useThemeStore = useThemeUtils.useThemeStore(function (store) {
1905
+ return {
1906
+ previewingTheme: store["previewingTheme"]
1907
+ };
1908
+ }, shallow.shallow),
1909
+ previewingTheme = _useThemeStore.previewingTheme;
1910
+ var themeId = previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id;
1831
1911
  var _useConfigStore = useThemeUtils.useConfigStore(function (store) {
1832
1912
  return {
1833
1913
  entityType: store["entityType"],
@@ -1836,68 +1916,69 @@ var TitleBar = function TitleBar(_ref) {
1836
1916
  }, shallow.shallow),
1837
1917
  entityType = _useConfigStore.entityType,
1838
1918
  helpDocUrl = _useConfigStore.helpDocUrl;
1919
+ var isCustomizeScreen = utils.isEditThemeRoute() || utils.isNewThemeRoute();
1839
1920
  var isCustomCssScreen = isScreenCustomCSS(currentScreen);
1840
- if (currentScreen === DESIGN_SCREENS.THEMES) {
1921
+ if (isCustomizeScreen) {
1841
1922
  return /*#__PURE__*/jsxRuntime.jsx("div", {
1842
- className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
1923
+ className: "neeto-themes-sidebar__header px-4",
1843
1924
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1844
- className: "flex items-center justify-between space-x-2",
1845
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1846
- className: "flex space-x-2",
1847
- children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
1848
- "data-cy": "themes-header",
1849
- lineHeight: "normal",
1850
- style: "h3",
1851
- weight: "semibold",
1852
- children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
1853
- }), /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
1854
- helpLinkProps: helpDocUrl && {
1855
- href: helpDocUrl
1856
- },
1857
- title: t("neetoThemes.build.leftSideBar.helpPopover.title"),
1858
- description: t("neetoThemes.build.leftSideBar.helpPopover.description", {
1859
- entityType: entityType
1860
- })
1861
- })]
1862
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
1863
- className: "self-end",
1864
- children: /*#__PURE__*/jsxRuntime.jsx(Button, {
1865
- "data-cy": "customize-themes-add-theme-button",
1866
- icon: Plus,
1867
- iconPosition: "left",
1868
- style: "text",
1869
- tooltipProps: {
1870
- content: t("neetoThemes.buttons.addNewTheme"),
1871
- position: "top"
1872
- },
1873
- onClick: handleCreateNewTheme
1874
- })
1925
+ className: "flex items-center justify-start space-x-2",
1926
+ children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
1927
+ "data-cy": "customize-themes-back-button",
1928
+ icon: LeftArrow,
1929
+ iconPosition: "left",
1930
+ style: "text",
1931
+ tooltipProps: {
1932
+ content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
1933
+ position: "top"
1934
+ },
1935
+ onClick: function onClick() {
1936
+ return handleBackPress(themeId);
1937
+ }
1938
+ }), /*#__PURE__*/jsxRuntime.jsxs(Typography, {
1939
+ "data-cy": "themes-header",
1940
+ lineHeight: "normal",
1941
+ style: "h3",
1942
+ weight: "semibold",
1943
+ children: [isCustomizeScreen && (utils.isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
1875
1944
  })]
1876
1945
  })
1877
1946
  });
1878
1947
  }
1879
1948
  return /*#__PURE__*/jsxRuntime.jsx("div", {
1880
- className: "neeto-themes-sidebar__header px-4",
1949
+ className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
1881
1950
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
1882
- className: "flex items-center justify-start space-x-2",
1883
- children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
1884
- "data-cy": "customize-themes-back-button",
1885
- icon: LeftArrow,
1886
- iconPosition: "left",
1887
- style: "text",
1888
- tooltipProps: {
1889
- content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
1890
- position: "top"
1891
- },
1892
- onClick: function onClick() {
1893
- return handleBackPress(themeToEdit);
1894
- }
1895
- }), /*#__PURE__*/jsxRuntime.jsxs(Typography, {
1896
- "data-cy": "themes-header",
1897
- lineHeight: "normal",
1898
- style: "h3",
1899
- weight: "semibold",
1900
- children: [currentScreen === DESIGN_SCREENS.Customize && (isNewTheme ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
1951
+ className: "flex items-center justify-between space-x-2",
1952
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
1953
+ className: "flex space-x-2",
1954
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
1955
+ "data-cy": "themes-header",
1956
+ lineHeight: "normal",
1957
+ style: "h3",
1958
+ weight: "semibold",
1959
+ children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
1960
+ }), /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
1961
+ helpLinkProps: helpDocUrl && {
1962
+ href: helpDocUrl
1963
+ },
1964
+ title: t("neetoThemes.build.leftSideBar.helpPopover.title"),
1965
+ description: t("neetoThemes.build.leftSideBar.helpPopover.description", {
1966
+ entityType: entityType
1967
+ })
1968
+ })]
1969
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
1970
+ className: "self-end",
1971
+ children: /*#__PURE__*/jsxRuntime.jsx(Button, {
1972
+ "data-cy": "customize-themes-add-theme-button",
1973
+ icon: Plus,
1974
+ iconPosition: "left",
1975
+ style: "text",
1976
+ tooltipProps: {
1977
+ content: t("neetoThemes.buttons.addNewTheme"),
1978
+ position: "top"
1979
+ },
1980
+ onClick: handleCreateNewTheme
1981
+ })
1901
1982
  })]
1902
1983
  })
1903
1984
  });
@@ -1905,7 +1986,7 @@ var TitleBar = function TitleBar(_ref) {
1905
1986
 
1906
1987
  var MemoizedAlert = /*#__PURE__*/react.memo(Alert);
1907
1988
  var Sidebar = function Sidebar(_ref) {
1908
- var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
1989
+ var _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
1909
1990
  var thumbnail = _ref.thumbnail,
1910
1991
  onPropertiesChange = _ref.onPropertiesChange,
1911
1992
  onApplyThemeSuccess = _ref.onApplyThemeSuccess,
@@ -1934,6 +2015,7 @@ var Sidebar = function Sidebar(_ref) {
1934
2015
  _useState10 = _slicedToArray(_useState9, 2),
1935
2016
  isThemesSidebarCollapsed = _useState10[0],
1936
2017
  setIsThemesSidebarCollapsed = _useState10[1];
2018
+ var history = reactRouterDom.useHistory();
1937
2019
  react.useEffect(function () {
1938
2020
  setIsThemesSidebarCollapsed(!isLargerScreen);
1939
2021
  }, [isLargerScreen]);
@@ -1995,9 +2077,14 @@ var Sidebar = function Sidebar(_ref) {
1995
2077
  var themeToDelete = react.useRef(null);
1996
2078
  var themeToEdit = react.useRef(null);
1997
2079
  var isCustomCssScreen = isScreenCustomCSS(currentScreen);
2080
+ var handleCreateNewTheme = function handleCreateNewTheme() {
2081
+ history.push(utils$1.buildUrl(buildPathname(routes.themes["new"])));
2082
+ };
1998
2083
  var handleEditTheme = function handleEditTheme(theme) {
1999
2084
  themeToEdit.current = theme;
2000
- setCurrentScreen(DESIGN_SCREENS.Customize);
2085
+ history.push(utils$1.buildUrl(buildPathname(routes.themes.edit), {
2086
+ themeId: theme.id
2087
+ }));
2001
2088
  };
2002
2089
  var onApplyTheme = function onApplyTheme(theme) {
2003
2090
  if (isApplyingTheme) return;
@@ -2008,23 +2095,26 @@ var Sidebar = function Sidebar(_ref) {
2008
2095
  entityType: entityType
2009
2096
  });
2010
2097
  };
2011
- var handleBackPress = function handleBackPress(theme) {
2012
- setTheme(currentTheme);
2013
- highlightTheme(neetoCist.isPresent(theme) ? theme : currentTheme);
2014
- setThemeState({
2015
- previewingTheme: currentTheme
2016
- });
2017
- setCurrentScreen(isCustomCssScreen ? DESIGN_SCREENS.Customize : DESIGN_SCREENS.THEMES);
2098
+ var navigateToThemesScreen = function navigateToThemesScreen(themeId) {
2099
+ highlightTheme(neetoCist.isPresent(themeId) ? themeId : currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
2100
+ history.push(utils$1.buildUrl(buildPathname(routes.themes.index)));
2018
2101
  themeToEdit.current = null;
2019
2102
  };
2020
- var highlightTheme = function highlightTheme(themeToHighlight) {
2103
+ var handleBackPress = function handleBackPress(themeId) {
2104
+ if (isCustomCssScreen) {
2105
+ setCurrentScreen(DESIGN_SCREENS.Customize);
2106
+ return;
2107
+ }
2108
+ navigateToThemesScreen(themeId);
2109
+ };
2110
+ var highlightTheme = function highlightTheme(themeIdToHighlight) {
2021
2111
  setTimeout(function () {
2022
- utils.scrollElementIntoView(themeToHighlight.id);
2112
+ utils.scrollElementIntoView(themeIdToHighlight);
2023
2113
  }, 1500);
2024
2114
  setTimeout(function () {
2025
2115
  setThemeToHighlight(null);
2026
2116
  }, 4000);
2027
- setThemeToHighlight(themeToHighlight.id);
2117
+ setThemeToHighlight(themeIdToHighlight);
2028
2118
  };
2029
2119
  var onCreateTheme = function onCreateTheme(createdTheme) {
2030
2120
  themeToEdit.current = createdTheme;
@@ -2033,6 +2123,10 @@ var Sidebar = function Sidebar(_ref) {
2033
2123
  previewingTheme: createdTheme
2034
2124
  });
2035
2125
  };
2126
+ var onUpdateTheme = function onUpdateTheme(updatedTheme) {
2127
+ themeToEdit.current = updatedTheme;
2128
+ onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(updatedTheme);
2129
+ };
2036
2130
  var handleDelete = function handleDelete(themeId, name, appliedCount) {
2037
2131
  setIsDeleteAlertOpen(true);
2038
2132
  themeToDelete.current = {
@@ -2069,37 +2163,59 @@ var Sidebar = function Sidebar(_ref) {
2069
2163
  children: [/*#__PURE__*/jsxRuntime.jsx(TitleBar, {
2070
2164
  currentScreen: currentScreen,
2071
2165
  handleBackPress: handleBackPress,
2072
- handleCreateNewTheme: function handleCreateNewTheme() {
2073
- return handleEditTheme({});
2074
- },
2075
- isNewTheme: !((_themeToEdit$current = themeToEdit.current) !== null && _themeToEdit$current !== void 0 && _themeToEdit$current.id),
2076
- themeToEdit: themeToEdit.current
2077
- }), currentScreen === DESIGN_SCREENS.THEMES ? /*#__PURE__*/jsxRuntime.jsx(Themes, {
2078
- currentTheme: currentTheme,
2079
- defaultThemes: defaultThemes,
2080
- didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
2081
- highlightTheme: highlightTheme,
2082
- isApplyingTheme: isApplyingTheme,
2083
- isCurrentThemeLoading: isCurrentThemeLoading,
2084
- onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2085
- onApplyTheme: onApplyTheme,
2086
- themeBeingApplied: themeBeingApplied,
2087
- themeToHighlight: themeToHighlight,
2088
- themes: themes,
2089
- thumbnail: thumbnail,
2090
- isLoading: isLoading || isFetchingSchema,
2091
- onDeleteTheme: handleDelete,
2092
- onEditTheme: handleEditTheme
2093
- }) : /*#__PURE__*/jsxRuntime.jsx(Customize, {
2094
- currentScreen: currentScreen,
2095
- isApplyingTheme: isApplyingTheme,
2096
- onApplyTheme: onApplyTheme,
2097
- onCreateTheme: onCreateTheme,
2098
- onPropertiesChange: onPropertiesChange,
2099
- onUpdateThemeSuccess: onUpdateThemeSuccess,
2100
- theme: themeToEdit.current,
2101
- themeId: (_themeToEdit$current2 = themeToEdit.current) === null || _themeToEdit$current2 === void 0 ? void 0 : _themeToEdit$current2.id,
2102
- onEditCSSClick: setCurrentScreen
2166
+ handleCreateNewTheme: handleCreateNewTheme
2167
+ }), /*#__PURE__*/jsxRuntime.jsxs(reactRouterDom.Switch, {
2168
+ children: [/*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
2169
+ exact: true,
2170
+ path: buildPathname(routes.themes.index),
2171
+ render: function render() {
2172
+ return /*#__PURE__*/jsxRuntime.jsx(Themes, {
2173
+ currentTheme: currentTheme,
2174
+ defaultThemes: defaultThemes,
2175
+ didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
2176
+ highlightTheme: highlightTheme,
2177
+ isApplyingTheme: isApplyingTheme,
2178
+ isCurrentThemeLoading: isCurrentThemeLoading,
2179
+ onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2180
+ onApplyTheme: onApplyTheme,
2181
+ themeBeingApplied: themeBeingApplied,
2182
+ themeToHighlight: themeToHighlight,
2183
+ themes: themes,
2184
+ thumbnail: thumbnail,
2185
+ isLoading: isLoading || isFetchingSchema,
2186
+ onDeleteTheme: handleDelete,
2187
+ onEditTheme: handleEditTheme
2188
+ });
2189
+ }
2190
+ }), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
2191
+ path: buildPathname(routes.themes["new"]),
2192
+ render: function render() {
2193
+ return /*#__PURE__*/jsxRuntime.jsx(Customize, {
2194
+ currentScreen: currentScreen,
2195
+ isApplyingTheme: isApplyingTheme,
2196
+ onApplyTheme: onApplyTheme,
2197
+ onCreateTheme: onCreateTheme,
2198
+ onPropertiesChange: onPropertiesChange,
2199
+ onUpdateTheme: onUpdateTheme,
2200
+ theme: themeToEdit.current,
2201
+ onEditCSSClick: setCurrentScreen
2202
+ });
2203
+ }
2204
+ }), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
2205
+ path: buildPathname(routes.themes.edit),
2206
+ render: function render() {
2207
+ return /*#__PURE__*/jsxRuntime.jsx(Customize, {
2208
+ currentScreen: currentScreen,
2209
+ isApplyingTheme: isApplyingTheme,
2210
+ onApplyTheme: onApplyTheme,
2211
+ onCreateTheme: onCreateTheme,
2212
+ onPropertiesChange: onPropertiesChange,
2213
+ onUpdateTheme: onUpdateTheme,
2214
+ theme: themeToEdit.current,
2215
+ onEditCSSClick: setCurrentScreen
2216
+ });
2217
+ }
2218
+ })]
2103
2219
  }), /*#__PURE__*/jsxRuntime.jsx(MemoizedAlert, {
2104
2220
  isOpen: isDeleteAlertOpen,
2105
2221
  isSubmitting: isDeleting,
@@ -2173,7 +2289,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2173
2289
  });
2174
2290
  }, []);
2175
2291
  react.useEffect(function () {
2176
- if (neetoCist.isNotPresent(currentTheme)) return;
2292
+ if (neetoCist.isNotPresent(currentTheme) || utils.isEditThemeRoute()) {
2293
+ return;
2294
+ }
2177
2295
  setThemeState({
2178
2296
  previewingTheme: currentTheme
2179
2297
  });