@bigbinary/neeto-themes-frontend 3.0.3 → 3.1.0

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.
@@ -55,6 +55,10 @@
55
55
  "headerTabs": {
56
56
  "themes": "Themes"
57
57
  },
58
+ "helpPopover": {
59
+ "title": "Themes",
60
+ "description": "Personalize your {{entityType}} to match your brand."
61
+ },
58
62
  "themes": {
59
63
  "systemThemes": "System themes",
60
64
  "customThemes": "Custom themes",
@@ -4,31 +4,34 @@ import { t as t$1 } from 'i18next';
4
4
  import { hyphenate, findBy, findIndexBy, isPresent, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
5
5
  import { useMutationWithInvalidation, withT, useBreakpoints, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
6
6
  import Spinner from '@bigbinary/neetoui/Spinner';
7
- import { useQuery } from '@tanstack/react-query';
7
+ import { B as BASE_URL, b as scrollElementIntoView, c as setCustomCSS, g as getDominantColorFromUrl, i as isEditThemeRoute, d as isFunction, e as isNewThemeRoute } from './index-BzuiCZa9.js';
8
+ import { useQuery, useQueryClient } from '@tanstack/react-query';
8
9
  import axios from 'axios';
9
- import { B as BASE_URL, b as scrollElementIntoView, c as setCustomCSS, g as getDominantColorFromUrl, i as isFunction } from './index-CvV1tFYS.js';
10
- import { Q as QUERY_KEYS, a as useConfigStore, b as useThemeStore, u as useThemeUtils } from './useThemeUtils-BCO-i9ZG.js';
10
+ import { Q as QUERY_KEYS, a as useConfigStore, b as useThemeStore, u as useThemeUtils } from './useThemeUtils-3j-X4pSD.js';
11
11
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
12
12
  import classnames from 'classnames';
13
+ import { joinHyphenCase, buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
13
14
  import Collapse from '@bigbinary/neeto-icons/Collapse';
14
15
  import Alert from '@bigbinary/neetoui/Alert';
15
16
  import Button from '@bigbinary/neetoui/Button';
16
17
  import { useTranslation, Trans } from 'react-i18next';
17
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
18
+ import { useHistory, useParams, Switch as Switch$1, Route } from 'react-router-dom';
18
19
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
20
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
19
21
  import Close from '@bigbinary/neeto-icons/Close';
22
+ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
20
23
  import Popover from '@bigbinary/neetoui/Popover';
21
24
  import Typography from '@bigbinary/neetoui/Typography';
22
25
  import Switch from '@bigbinary/neetoui/Switch';
23
26
  import Tooltip from '@bigbinary/neetoui/Tooltip';
24
27
  import Form from '@bigbinary/neetoui/formik/Form';
28
+ import BlockNavigation from '@bigbinary/neetoui/formik/BlockNavigation';
29
+ import { isEmpty, negate, isNotNil } from 'ramda';
25
30
  import * as yup from 'yup';
26
31
  import Editor from '@monaco-editor/react';
27
32
  import { useFormikContext, Field } from 'formik';
28
33
  import Down from '@bigbinary/neeto-icons/Down';
29
34
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
30
- import { negate, isEmpty } from 'ramda';
31
- import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
32
35
  import CenterAlign from '@bigbinary/neeto-icons/CenterAlign';
33
36
  import LeftAlign from '@bigbinary/neeto-icons/LeftAlign';
34
37
  import ColorPicker from '@bigbinary/neetoui/ColorPicker';
@@ -123,6 +126,8 @@ var themesApi = {
123
126
  applyGlobalTheme: applyGlobalTheme
124
127
  };
125
128
 
129
+ 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; }
130
+ 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; }
126
131
  var useListThemes = function useListThemes(entityId) {
127
132
  var _useConfigStore = useConfigStore(function (store) {
128
133
  return {
@@ -138,19 +143,32 @@ var useListThemes = function useListThemes(entityId) {
138
143
  }
139
144
  });
140
145
  };
146
+ var useFetchTheme = function useFetchTheme(themeId, options) {
147
+ return useQuery(_objectSpread$6({
148
+ queryKey: [QUERY_KEYS.THEME_DETAILS, themeId],
149
+ queryFn: function queryFn() {
150
+ return themesApi.show(themeId);
151
+ }
152
+ }, options));
153
+ };
141
154
  var useCreateTheme = function useCreateTheme() {
142
155
  return useMutationWithInvalidation(themesApi.create, {
143
156
  keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.GLOBAL_THEME_DETAILS]]
144
157
  });
145
158
  };
146
159
  var useUpdateTheme = function useUpdateTheme(themeId) {
160
+ var queryClient = useQueryClient();
147
161
  return useMutationWithInvalidation(function (payload) {
148
162
  return themesApi.update({
149
163
  id: themeId,
150
164
  payload: payload
151
165
  });
152
166
  }, {
153
- keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.THEME_DETAILS, themeId], [QUERY_KEYS.GLOBAL_THEME_DETAILS]]
167
+ keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.THEME_DETAILS, themeId], [QUERY_KEYS.GLOBAL_THEME_DETAILS]],
168
+ onSuccess: function onSuccess(_ref) {
169
+ var theme = _ref.theme;
170
+ queryClient.setQueryData([QUERY_KEYS.THEME_DETAILS, themeId], theme);
171
+ }
154
172
  });
155
173
  };
156
174
  var useDeleteTheme = function useDeleteTheme() {
@@ -163,8 +181,8 @@ var useCloneTheme = function useCloneTheme() {
163
181
  keysToInvalidate: [QUERY_KEYS.THEMES_LIST]
164
182
  });
165
183
  };
166
- var useApplyTheme = function useApplyTheme(_ref) {
167
- var onSuccess = _ref.onSuccess;
184
+ var useApplyTheme = function useApplyTheme(_ref2) {
185
+ var onSuccess = _ref2.onSuccess;
168
186
  return useMutationWithInvalidation(themesApi.apply, {
169
187
  keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS]],
170
188
  onSuccess: onSuccess
@@ -176,6 +194,14 @@ var useApplyGlobalTheme = function useApplyGlobalTheme() {
176
194
  });
177
195
  };
178
196
 
197
+ var routes = {
198
+ themes: {
199
+ index: "/themes",
200
+ edit: "/themes/:themeId/edit",
201
+ "new": "/themes/new"
202
+ }
203
+ };
204
+
179
205
  var show = function show(entityType) {
180
206
  return axios.get("".concat(BASE_URL, "/api/v1/global_theme"), {
181
207
  params: {
@@ -340,9 +366,34 @@ var Card$2 = function Card(_ref) {
340
366
  });
341
367
  };
342
368
 
369
+ 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; } } }; }
370
+ 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; } }
371
+ 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; }
343
372
  var isScreenCustomCSS = function isScreenCustomCSS(screen) {
344
373
  return screen === DESIGN_SCREENS.CustomCSS;
345
374
  };
375
+ var buildPathname = function buildPathname(route) {
376
+ var pathname = "";
377
+ var _iterator = _createForOfIteratorHelper(location.pathname.split("/")),
378
+ _step;
379
+ try {
380
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
381
+ var segment = _step.value;
382
+ if (isEmpty(segment)) {
383
+ continue;
384
+ }
385
+ if (segment === "themes") {
386
+ break;
387
+ }
388
+ pathname += "/".concat(segment);
389
+ }
390
+ } catch (err) {
391
+ _iterator.e(err);
392
+ } finally {
393
+ _iterator.f();
394
+ }
395
+ return "".concat(pathname).concat(route);
396
+ };
346
397
 
347
398
  var CustomCSS = function CustomCSS(_ref) {
348
399
  var onEditCSSClick = _ref.onEditCSSClick,
@@ -1122,17 +1173,17 @@ var ThemeMeta = withT(function (_ref) {
1122
1173
  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; }
1123
1174
  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; }
1124
1175
  var Customize = function Customize(_ref) {
1125
- var themeId = _ref.themeId,
1126
- theme = _ref.theme,
1176
+ var theme = _ref.theme,
1127
1177
  onCreateTheme = _ref.onCreateTheme,
1128
1178
  onApplyTheme = _ref.onApplyTheme,
1179
+ onUpdateTheme = _ref.onUpdateTheme,
1129
1180
  isApplyingTheme = _ref.isApplyingTheme,
1130
1181
  onPropertiesChange = _ref.onPropertiesChange,
1131
- onUpdateThemeSuccess = _ref.onUpdateThemeSuccess,
1132
1182
  onEditCSSClick = _ref.onEditCSSClick,
1133
1183
  currentScreen = _ref.currentScreen;
1134
1184
  var _useTranslation = useTranslation(),
1135
1185
  t = _useTranslation.t;
1186
+ var history = useHistory();
1136
1187
  var _useState = useState({}),
1137
1188
  _useState2 = _slicedToArray(_useState, 2),
1138
1189
  popoverInstance = _useState2[0],
@@ -1145,15 +1196,29 @@ var Customize = function Customize(_ref) {
1145
1196
  }, shallow),
1146
1197
  themePropertiesSchema = _useConfigStore.themePropertiesSchema,
1147
1198
  entityType = _useConfigStore.entityType;
1148
- var _useThemeUtils = useThemeUtils(),
1149
- currentTheme = _useThemeUtils.currentTheme,
1150
- setThemeState = _useThemeUtils.setThemeState;
1199
+ var _useParams = useParams(),
1200
+ themeId = _useParams.themeId;
1201
+ var _useThemeStore = useThemeStore(function (store) {
1202
+ return {
1203
+ currentTheme: store["currentTheme"],
1204
+ setThemeState: store["setThemeState"]
1205
+ };
1206
+ }, shallow),
1207
+ currentTheme = _useThemeStore.currentTheme,
1208
+ setThemeState = _useThemeStore.setThemeState;
1151
1209
  var _useShowGlobalTheme = useShowGlobalTheme(entityType),
1152
1210
  _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1153
1211
  _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
1154
1212
  _useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
1155
1213
  globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
1156
- var isThemeGlobalTheme = (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1214
+ var _useFetchTheme = useFetchTheme(themeId, {
1215
+ enabled: isEditThemeRoute() && isNotNil(themeId),
1216
+ initialData: theme !== null && theme !== void 0 ? theme : undefined
1217
+ }),
1218
+ _useFetchTheme$data = _useFetchTheme.data,
1219
+ themeData = _useFetchTheme$data === void 0 ? {} : _useFetchTheme$data,
1220
+ isLoading = _useFetchTheme.isLoading;
1221
+ var isThemeGlobalTheme = themeId && (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1157
1222
  var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
1158
1223
  var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1159
1224
  var submitBtnRef = useRef(null);
@@ -1185,25 +1250,35 @@ var Customize = function Customize(_ref) {
1185
1250
  values: theme
1186
1251
  });
1187
1252
  onCreateTheme(theme);
1253
+ history.replace(buildUrl(buildPathname(routes.themes.edit), {
1254
+ themeId: theme.id
1255
+ }));
1188
1256
  }
1189
1257
  });
1190
1258
  }
1191
1259
  return updateTheme(themeToSave, {
1192
1260
  onSuccess: function onSuccess(_ref4) {
1193
1261
  var theme = _ref4.theme;
1194
- onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(theme);
1195
- setThemeState({
1196
- previewingTheme: theme
1197
- });
1262
+ onUpdateTheme(theme);
1198
1263
  resetForm({
1199
1264
  values: theme
1200
1265
  });
1201
1266
  }
1202
1267
  });
1203
1268
  };
1269
+ useEffect(function () {
1270
+ if (isNotNil(themeId) && !isLoading) {
1271
+ setThemeState({
1272
+ previewingTheme: themeData
1273
+ });
1274
+ }
1275
+ }, [themeData, isLoading]);
1276
+ if (isLoading) {
1277
+ return /*#__PURE__*/jsx(PageLoader, {});
1278
+ }
1204
1279
  return /*#__PURE__*/jsx(Form, {
1205
1280
  formikProps: {
1206
- initialValues: _objectSpread$1(_objectSpread$1({}, buildInitialValues(theme, themePropertiesSchema)), {}, {
1281
+ initialValues: _objectSpread$1(_objectSpread$1({}, buildInitialValues(themeData, themePropertiesSchema)), {}, {
1207
1282
  shouldSetAsGlobalTheme: isThemeGlobalTheme,
1208
1283
  entityType: entityType
1209
1284
  }),
@@ -1219,7 +1294,7 @@ var Customize = function Customize(_ref) {
1219
1294
  className: "neeto-themes-sidebar__scroll",
1220
1295
  children: [/*#__PURE__*/jsxs("div", {
1221
1296
  className: "neeto-themes-sidebar__scroll-content flex flex-grow flex-col px-4 pb-4 lg:px-5",
1222
- children: [/*#__PURE__*/jsx(ThemeMeta, {
1297
+ children: [!isSubmitting && /*#__PURE__*/jsx(BlockNavigation, {}), /*#__PURE__*/jsx(ThemeMeta, {
1223
1298
  className: classnames({
1224
1299
  hidden: isCustomCssScreen
1225
1300
  })
@@ -1279,7 +1354,7 @@ var Customize = function Customize(_ref) {
1279
1354
  type: "reset"
1280
1355
  }), /*#__PURE__*/jsx(Button, {
1281
1356
  "data-cy": "save-changes-button",
1282
- disabled: !dirty && (theme === null || theme === void 0 ? void 0 : theme.id) || isSubmitting,
1357
+ disabled: !dirty && (themeData === null || themeData === void 0 ? void 0 : themeData.id) || isSubmitting,
1283
1358
  label: t("neetoThemes.buttons.save"),
1284
1359
  loading: isSubmitting,
1285
1360
  ref: submitBtnRef,
@@ -1321,7 +1396,7 @@ var Customize = function Customize(_ref) {
1321
1396
  label: t("neetoThemes.buttons.applyThisTheme"),
1322
1397
  loading: isApplyingTheme,
1323
1398
  onClick: function onClick() {
1324
- return onApplyTheme(theme);
1399
+ return onApplyTheme(themeData);
1325
1400
  }
1326
1401
  })]
1327
1402
  }),
@@ -1802,62 +1877,87 @@ var Themes = function Themes(_ref) {
1802
1877
  var TitleBar = function TitleBar(_ref) {
1803
1878
  var currentScreen = _ref.currentScreen,
1804
1879
  handleBackPress = _ref.handleBackPress,
1805
- handleCreateNewTheme = _ref.handleCreateNewTheme,
1806
- isNewTheme = _ref.isNewTheme,
1807
- themeToEdit = _ref.themeToEdit;
1880
+ handleCreateNewTheme = _ref.handleCreateNewTheme;
1808
1881
  var _useTranslation = useTranslation(),
1809
1882
  t = _useTranslation.t;
1883
+ var _useThemeStore = useThemeStore(function (store) {
1884
+ return {
1885
+ previewingTheme: store["previewingTheme"]
1886
+ };
1887
+ }, shallow),
1888
+ previewingTheme = _useThemeStore.previewingTheme;
1889
+ var themeId = previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id;
1890
+ var _useConfigStore = useConfigStore(function (store) {
1891
+ return {
1892
+ entityType: store["entityType"],
1893
+ helpDocUrl: store["helpDocUrl"]
1894
+ };
1895
+ }, shallow),
1896
+ entityType = _useConfigStore.entityType,
1897
+ helpDocUrl = _useConfigStore.helpDocUrl;
1898
+ var isCustomizeScreen = isEditThemeRoute() || isNewThemeRoute();
1810
1899
  var isCustomCssScreen = isScreenCustomCSS(currentScreen);
1811
- if (currentScreen === DESIGN_SCREENS.THEMES) {
1900
+ if (isCustomizeScreen) {
1812
1901
  return /*#__PURE__*/jsx("div", {
1813
- className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
1902
+ className: "neeto-themes-sidebar__header px-4",
1814
1903
  children: /*#__PURE__*/jsxs("div", {
1815
- className: "flex items-center justify-between space-x-2",
1816
- children: [/*#__PURE__*/jsx(Typography, {
1904
+ className: "flex items-center justify-start space-x-2",
1905
+ children: [/*#__PURE__*/jsx(Button, {
1906
+ "data-cy": "customize-themes-back-button",
1907
+ icon: LeftArrow,
1908
+ iconPosition: "left",
1909
+ style: "text",
1910
+ tooltipProps: {
1911
+ content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
1912
+ position: "top"
1913
+ },
1914
+ onClick: function onClick() {
1915
+ return handleBackPress(themeId);
1916
+ }
1917
+ }), /*#__PURE__*/jsxs(Typography, {
1817
1918
  "data-cy": "themes-header",
1818
1919
  lineHeight: "normal",
1819
1920
  style: "h3",
1820
1921
  weight: "semibold",
1821
- children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
1822
- }), /*#__PURE__*/jsx("div", {
1823
- className: "self-end",
1824
- children: /*#__PURE__*/jsx(Button, {
1825
- "data-cy": "customize-themes-add-theme-button",
1826
- icon: Plus,
1827
- iconPosition: "left",
1828
- style: "text",
1829
- tooltipProps: {
1830
- content: t("neetoThemes.buttons.addNewTheme"),
1831
- position: "top"
1832
- },
1833
- onClick: handleCreateNewTheme
1834
- })
1922
+ children: [isCustomizeScreen && (isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
1835
1923
  })]
1836
1924
  })
1837
1925
  });
1838
1926
  }
1839
1927
  return /*#__PURE__*/jsx("div", {
1840
- className: "neeto-themes-sidebar__header px-4",
1928
+ className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
1841
1929
  children: /*#__PURE__*/jsxs("div", {
1842
- className: "flex items-center justify-start space-x-2",
1843
- children: [/*#__PURE__*/jsx(Button, {
1844
- "data-cy": "customize-themes-back-button",
1845
- icon: LeftArrow,
1846
- iconPosition: "left",
1847
- style: "text",
1848
- tooltipProps: {
1849
- content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
1850
- position: "top"
1851
- },
1852
- onClick: function onClick() {
1853
- return handleBackPress(themeToEdit);
1854
- }
1855
- }), /*#__PURE__*/jsxs(Typography, {
1856
- "data-cy": "themes-header",
1857
- lineHeight: "normal",
1858
- style: "h3",
1859
- weight: "semibold",
1860
- 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")]
1930
+ className: "flex items-center justify-between space-x-2",
1931
+ children: [/*#__PURE__*/jsxs("div", {
1932
+ className: "flex space-x-2",
1933
+ children: [/*#__PURE__*/jsx(Typography, {
1934
+ "data-cy": "themes-header",
1935
+ lineHeight: "normal",
1936
+ style: "h3",
1937
+ weight: "semibold",
1938
+ children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
1939
+ }), /*#__PURE__*/jsx(HelpPopover, {
1940
+ helpLinkProps: helpDocUrl && {
1941
+ href: helpDocUrl
1942
+ },
1943
+ title: t("neetoThemes.build.leftSideBar.helpPopover.title"),
1944
+ description: t("neetoThemes.build.leftSideBar.helpPopover.description", {
1945
+ entityType: entityType
1946
+ })
1947
+ })]
1948
+ }), /*#__PURE__*/jsx("div", {
1949
+ className: "self-end",
1950
+ children: /*#__PURE__*/jsx(Button, {
1951
+ "data-cy": "customize-themes-add-theme-button",
1952
+ icon: Plus,
1953
+ iconPosition: "left",
1954
+ style: "text",
1955
+ tooltipProps: {
1956
+ content: t("neetoThemes.buttons.addNewTheme"),
1957
+ position: "top"
1958
+ },
1959
+ onClick: handleCreateNewTheme
1960
+ })
1861
1961
  })]
1862
1962
  })
1863
1963
  });
@@ -1865,7 +1965,7 @@ var TitleBar = function TitleBar(_ref) {
1865
1965
 
1866
1966
  var MemoizedAlert = /*#__PURE__*/memo(Alert);
1867
1967
  var Sidebar = function Sidebar(_ref) {
1868
- var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
1968
+ var _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
1869
1969
  var thumbnail = _ref.thumbnail,
1870
1970
  onPropertiesChange = _ref.onPropertiesChange,
1871
1971
  onApplyThemeSuccess = _ref.onApplyThemeSuccess,
@@ -1894,6 +1994,7 @@ var Sidebar = function Sidebar(_ref) {
1894
1994
  _useState10 = _slicedToArray(_useState9, 2),
1895
1995
  isThemesSidebarCollapsed = _useState10[0],
1896
1996
  setIsThemesSidebarCollapsed = _useState10[1];
1997
+ var history = useHistory();
1897
1998
  useEffect(function () {
1898
1999
  setIsThemesSidebarCollapsed(!isLargerScreen);
1899
2000
  }, [isLargerScreen]);
@@ -1955,9 +2056,14 @@ var Sidebar = function Sidebar(_ref) {
1955
2056
  var themeToDelete = useRef(null);
1956
2057
  var themeToEdit = useRef(null);
1957
2058
  var isCustomCssScreen = isScreenCustomCSS(currentScreen);
2059
+ var handleCreateNewTheme = function handleCreateNewTheme() {
2060
+ history.push(buildUrl(buildPathname(routes.themes["new"])));
2061
+ };
1958
2062
  var handleEditTheme = function handleEditTheme(theme) {
1959
2063
  themeToEdit.current = theme;
1960
- setCurrentScreen(DESIGN_SCREENS.Customize);
2064
+ history.push(buildUrl(buildPathname(routes.themes.edit), {
2065
+ themeId: theme.id
2066
+ }));
1961
2067
  };
1962
2068
  var onApplyTheme = function onApplyTheme(theme) {
1963
2069
  if (isApplyingTheme) return;
@@ -1968,23 +2074,30 @@ var Sidebar = function Sidebar(_ref) {
1968
2074
  entityType: entityType
1969
2075
  });
1970
2076
  };
1971
- var handleBackPress = function handleBackPress(theme) {
2077
+ var navigateToThemesScreen = function navigateToThemesScreen(themeId) {
1972
2078
  setTheme(currentTheme);
1973
- highlightTheme(isPresent(theme) ? theme : currentTheme);
2079
+ highlightTheme(isPresent(themeId) ? themeId : currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1974
2080
  setThemeState({
1975
2081
  previewingTheme: currentTheme
1976
2082
  });
1977
- setCurrentScreen(isCustomCssScreen ? DESIGN_SCREENS.Customize : DESIGN_SCREENS.THEMES);
2083
+ history.push(buildUrl(buildPathname(routes.themes.index)));
1978
2084
  themeToEdit.current = null;
1979
2085
  };
1980
- var highlightTheme = function highlightTheme(themeToHighlight) {
2086
+ var handleBackPress = function handleBackPress(themeId) {
2087
+ if (isCustomCssScreen) {
2088
+ setCurrentScreen(DESIGN_SCREENS.Customize);
2089
+ return;
2090
+ }
2091
+ navigateToThemesScreen(themeId);
2092
+ };
2093
+ var highlightTheme = function highlightTheme(themeIdToHighlight) {
1981
2094
  setTimeout(function () {
1982
- scrollElementIntoView(themeToHighlight.id);
2095
+ scrollElementIntoView(themeIdToHighlight);
1983
2096
  }, 1500);
1984
2097
  setTimeout(function () {
1985
2098
  setThemeToHighlight(null);
1986
2099
  }, 4000);
1987
- setThemeToHighlight(themeToHighlight.id);
2100
+ setThemeToHighlight(themeIdToHighlight);
1988
2101
  };
1989
2102
  var onCreateTheme = function onCreateTheme(createdTheme) {
1990
2103
  themeToEdit.current = createdTheme;
@@ -1993,6 +2106,10 @@ var Sidebar = function Sidebar(_ref) {
1993
2106
  previewingTheme: createdTheme
1994
2107
  });
1995
2108
  };
2109
+ var onUpdateTheme = function onUpdateTheme(updatedTheme) {
2110
+ themeToEdit.current = updatedTheme;
2111
+ onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(updatedTheme);
2112
+ };
1996
2113
  var handleDelete = function handleDelete(themeId, name, appliedCount) {
1997
2114
  setIsDeleteAlertOpen(true);
1998
2115
  themeToDelete.current = {
@@ -2029,37 +2146,59 @@ var Sidebar = function Sidebar(_ref) {
2029
2146
  children: [/*#__PURE__*/jsx(TitleBar, {
2030
2147
  currentScreen: currentScreen,
2031
2148
  handleBackPress: handleBackPress,
2032
- handleCreateNewTheme: function handleCreateNewTheme() {
2033
- return handleEditTheme({});
2034
- },
2035
- isNewTheme: !((_themeToEdit$current = themeToEdit.current) !== null && _themeToEdit$current !== void 0 && _themeToEdit$current.id),
2036
- themeToEdit: themeToEdit.current
2037
- }), currentScreen === DESIGN_SCREENS.THEMES ? /*#__PURE__*/jsx(Themes, {
2038
- currentTheme: currentTheme,
2039
- defaultThemes: defaultThemes,
2040
- didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
2041
- highlightTheme: highlightTheme,
2042
- isApplyingTheme: isApplyingTheme,
2043
- isCurrentThemeLoading: isCurrentThemeLoading,
2044
- onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2045
- onApplyTheme: onApplyTheme,
2046
- themeBeingApplied: themeBeingApplied,
2047
- themeToHighlight: themeToHighlight,
2048
- themes: themes,
2049
- thumbnail: thumbnail,
2050
- isLoading: isLoading || isFetchingSchema,
2051
- onDeleteTheme: handleDelete,
2052
- onEditTheme: handleEditTheme
2053
- }) : /*#__PURE__*/jsx(Customize, {
2054
- currentScreen: currentScreen,
2055
- isApplyingTheme: isApplyingTheme,
2056
- onApplyTheme: onApplyTheme,
2057
- onCreateTheme: onCreateTheme,
2058
- onPropertiesChange: onPropertiesChange,
2059
- onUpdateThemeSuccess: onUpdateThemeSuccess,
2060
- theme: themeToEdit.current,
2061
- themeId: (_themeToEdit$current2 = themeToEdit.current) === null || _themeToEdit$current2 === void 0 ? void 0 : _themeToEdit$current2.id,
2062
- onEditCSSClick: setCurrentScreen
2149
+ handleCreateNewTheme: handleCreateNewTheme
2150
+ }), /*#__PURE__*/jsxs(Switch$1, {
2151
+ children: [/*#__PURE__*/jsx(Route, {
2152
+ exact: true,
2153
+ path: buildPathname(routes.themes.index),
2154
+ render: function render() {
2155
+ return /*#__PURE__*/jsx(Themes, {
2156
+ currentTheme: currentTheme,
2157
+ defaultThemes: defaultThemes,
2158
+ didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
2159
+ highlightTheme: highlightTheme,
2160
+ isApplyingTheme: isApplyingTheme,
2161
+ isCurrentThemeLoading: isCurrentThemeLoading,
2162
+ onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
2163
+ onApplyTheme: onApplyTheme,
2164
+ themeBeingApplied: themeBeingApplied,
2165
+ themeToHighlight: themeToHighlight,
2166
+ themes: themes,
2167
+ thumbnail: thumbnail,
2168
+ isLoading: isLoading || isFetchingSchema,
2169
+ onDeleteTheme: handleDelete,
2170
+ onEditTheme: handleEditTheme
2171
+ });
2172
+ }
2173
+ }), /*#__PURE__*/jsx(Route, {
2174
+ path: buildPathname(routes.themes["new"]),
2175
+ render: function render() {
2176
+ return /*#__PURE__*/jsx(Customize, {
2177
+ currentScreen: currentScreen,
2178
+ isApplyingTheme: isApplyingTheme,
2179
+ onApplyTheme: onApplyTheme,
2180
+ onCreateTheme: onCreateTheme,
2181
+ onPropertiesChange: onPropertiesChange,
2182
+ onUpdateTheme: onUpdateTheme,
2183
+ theme: themeToEdit.current,
2184
+ onEditCSSClick: setCurrentScreen
2185
+ });
2186
+ }
2187
+ }), /*#__PURE__*/jsx(Route, {
2188
+ path: buildPathname(routes.themes.edit),
2189
+ render: function render() {
2190
+ return /*#__PURE__*/jsx(Customize, {
2191
+ currentScreen: currentScreen,
2192
+ isApplyingTheme: isApplyingTheme,
2193
+ onApplyTheme: onApplyTheme,
2194
+ onCreateTheme: onCreateTheme,
2195
+ onPropertiesChange: onPropertiesChange,
2196
+ onUpdateTheme: onUpdateTheme,
2197
+ theme: themeToEdit.current,
2198
+ onEditCSSClick: setCurrentScreen
2199
+ });
2200
+ }
2201
+ })]
2063
2202
  }), /*#__PURE__*/jsx(MemoizedAlert, {
2064
2203
  isOpen: isDeleteAlertOpen,
2065
2204
  isSubmitting: isDeleting,
@@ -2092,6 +2231,8 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2092
2231
  entityId = _ref.entityId,
2093
2232
  thumbnail = _ref.thumbnail,
2094
2233
  onPropertiesChange = _ref.onPropertiesChange,
2234
+ _ref$helpDocUrl = _ref.helpDocUrl,
2235
+ helpDocUrl = _ref$helpDocUrl === void 0 ? null : _ref$helpDocUrl,
2095
2236
  _ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
2096
2237
  isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes,
2097
2238
  _ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
@@ -2126,11 +2267,14 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
2126
2267
  setConfigState({
2127
2268
  entityType: entityType,
2128
2269
  entityId: entityId,
2129
- isTemplateThemesEnabled: isTemplateThemesEnabled
2270
+ isTemplateThemesEnabled: isTemplateThemesEnabled,
2271
+ helpDocUrl: helpDocUrl
2130
2272
  });
2131
2273
  }, []);
2132
2274
  useEffect(function () {
2133
- if (isNotPresent(currentTheme)) return;
2275
+ if (isNotPresent(currentTheme) || isEditThemeRoute()) {
2276
+ return;
2277
+ }
2134
2278
  setThemeState({
2135
2279
  previewingTheme: currentTheme
2136
2280
  });