@bigbinary/neeto-tags-frontend 0.0.28 → 0.0.30

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
@@ -20,7 +20,7 @@ import { useHistory, Switch, Route } from 'react-router-dom';
20
20
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
21
21
  import { Tag, Dropdown, Toastr, Pane, Typography, Button, PageLoader, Table, Alert, Input as Input$1, Modal } from '@bigbinary/neetoui';
22
22
  import * as yup from 'yup';
23
- import { MenuHorizontal, Plus } from '@bigbinary/neeto-icons';
23
+ import { MenuHorizontal } from '@bigbinary/neeto-icons';
24
24
  import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
25
25
  import _extends from '@babel/runtime/helpers/esm/extends';
26
26
  import ReactDOM from 'react-dom';
@@ -3393,20 +3393,23 @@ var title = "Tags";
3393
3393
  var selectTags = "Select tags";
3394
3394
  var selectedTags = "Selected tags";
3395
3395
  var plcHolder = "Type to search tag…";
3396
- var manage = "Manage Tags";
3396
+ var manage = "Manage tags";
3397
3397
  var remove = "Remove {{tag}} tag";
3398
3398
  var exists = "{{tag}} already exists.";
3399
+ var deleteTag = "Delete tag";
3399
3400
  var edit = "Edit";
3400
- var addTag = "Add Tag";
3401
- var selectOrCreate = "Select or Create tag";
3401
+ var addTag = "Add tag";
3402
+ var selectOrCreate = "Select or create tag";
3402
3403
  var select = "Select {{what}}";
3403
3404
  var search = "Search {{where}}";
3404
3405
  var addNew = "Add {{what}}";
3405
3406
  var tag = "Tag";
3406
- var noTagsFound = "No Tags Found";
3407
+ var noTagsFound = "No tags found";
3408
+ var goBack = "Go back";
3407
3409
  var deleteItem = "Are you sure you want to delete {{type}}";
3408
3410
  var cannotBeUndone = "This action cannot be undone.";
3409
3411
  var proceed = "Proceed";
3412
+ var saveChanges = "Save changes";
3410
3413
  var cancel = "Cancel";
3411
3414
  var name = "Name";
3412
3415
  var required = "{{what}} is a required field.";
@@ -3421,12 +3424,12 @@ var types = {
3421
3424
  string: "string"
3422
3425
  };
3423
3426
  var merge$1 = {
3424
- sourceTag: "Source Tag",
3425
- destinationTag: "Destination Tag",
3426
- mergeTags: "Merge Tags",
3427
+ sourceTag: "Source tag",
3428
+ destinationTag: "Destination tag",
3429
+ mergeTags: "Merge tags",
3427
3430
  merge: "Merge",
3428
3431
  confirmation: {
3429
- title: "Merge Tags",
3432
+ title: "Merge tags",
3430
3433
  message: "Tag <strong>{{sourceTag}}</strong> will be merged into <strong>{{destinationTag}}</strong> tag. This will also be reflected in {{entities}} that are assigned with. This is a non-reversible operation. Do you wish to continue?"
3431
3434
  }
3432
3435
  };
@@ -3440,6 +3443,7 @@ var en = {
3440
3443
  exists: exists,
3441
3444
  "new": "Create new tag",
3442
3445
  "delete": "Delete",
3446
+ deleteTag: deleteTag,
3443
3447
  edit: edit,
3444
3448
  addTag: addTag,
3445
3449
  selectOrCreate: selectOrCreate,
@@ -3448,9 +3452,11 @@ var en = {
3448
3452
  addNew: addNew,
3449
3453
  tag: tag,
3450
3454
  noTagsFound: noTagsFound,
3455
+ goBack: goBack,
3451
3456
  deleteItem: deleteItem,
3452
3457
  cannotBeUndone: cannotBeUndone,
3453
3458
  proceed: proceed,
3459
+ saveChanges: saveChanges,
3454
3460
  cancel: cancel,
3455
3461
  name: name,
3456
3462
  required: required,
@@ -6849,11 +6855,14 @@ var refetchTags = function refetchTags() {
6849
6855
  };
6850
6856
 
6851
6857
  var useTagsForm = function useTagsForm(_ref) {
6852
- var isEdit = _ref.isEdit,
6853
- tagType = _ref.tagType,
6858
+ var createTags = _ref.createTags,
6859
+ goToFirstPage = _ref.goToFirstPage,
6860
+ isEdit = _ref.isEdit,
6854
6861
  onClose = _ref.onClose,
6855
- goToFirstPage = _ref.goToFirstPage;
6862
+ tagType = _ref.tagType,
6863
+ updateTags = _ref.updateTags;
6856
6864
  var tagModification = isEdit ? useUpdateTag : useCreateTag;
6865
+ var tagOperation = isEdit ? updateTags : createTags;
6857
6866
 
6858
6867
  var _tagModification = tagModification(),
6859
6868
  mutate = _tagModification.mutate,
@@ -6877,7 +6886,10 @@ var useTagsForm = function useTagsForm(_ref) {
6877
6886
 
6878
6887
  mutate(tagData, {
6879
6888
  onSuccess: function onSuccess() {
6889
+ var _tagOperation$onSucce;
6890
+
6880
6891
  !isEdit && goToFirstPage();
6892
+ tagOperation === null || tagOperation === void 0 ? void 0 : (_tagOperation$onSucce = tagOperation.onSuccess) === null || _tagOperation$onSucce === void 0 ? void 0 : _tagOperation$onSucce.callback();
6881
6893
  onClose();
6882
6894
  },
6883
6895
  onError: function onError() {
@@ -6893,11 +6905,13 @@ var useTagsForm = function useTagsForm(_ref) {
6893
6905
  };
6894
6906
 
6895
6907
  var ManageTags = function ManageTags(_ref) {
6896
- var tag = _ref.tag,
6897
- type = _ref.type,
6908
+ var createTags = _ref.createTags,
6909
+ goToFirstPage = _ref.goToFirstPage,
6898
6910
  onClose = _ref.onClose,
6911
+ tag = _ref.tag,
6899
6912
  tagType = _ref.tagType,
6900
- goToFirstPage = _ref.goToFirstPage;
6913
+ type = _ref.type,
6914
+ updateTags = _ref.updateTags;
6901
6915
  var isEdit = type === PANE_TYPES.EDIT;
6902
6916
  var initValues = isEdit ? tag : INITIAL_TAG_VALUES;
6903
6917
 
@@ -6905,10 +6919,12 @@ var ManageTags = function ManageTags(_ref) {
6905
6919
  t = _useTranslation.t;
6906
6920
 
6907
6921
  var _useTagsForm = useTagsForm({
6922
+ createTags: createTags,
6923
+ goToFirstPage: goToFirstPage,
6908
6924
  isEdit: isEdit,
6909
- tagType: tagType,
6910
6925
  onClose: onClose,
6911
- goToFirstPage: goToFirstPage
6926
+ tagType: tagType,
6927
+ updateTags: updateTags
6912
6928
  }),
6913
6929
  handleSubmit = _useTagsForm.handleSubmit;
6914
6930
 
@@ -6919,9 +6935,9 @@ var ManageTags = function ManageTags(_ref) {
6919
6935
  style: "h2",
6920
6936
  weight: "semibold"
6921
6937
  }, isEdit ? t("editItem", {
6922
- what: t("tag")
6938
+ what: t("tag").toLocaleLowerCase()
6923
6939
  }) : t("addNew", {
6924
- what: t("tag")
6940
+ what: t("tag").toLocaleLowerCase()
6925
6941
  }))), /*#__PURE__*/React.createElement(Formik, {
6926
6942
  initialValues: initValues,
6927
6943
  validateOnBlur: false,
@@ -6937,7 +6953,7 @@ var ManageTags = function ManageTags(_ref) {
6937
6953
  required: true,
6938
6954
  autoFocus: true,
6939
6955
  name: "name",
6940
- label: "".concat(t("tag"), " ").concat(t("name")),
6956
+ label: "".concat(t("tag"), " ").concat(t("name").toLocaleLowerCase()),
6941
6957
  "data-cy": "tag-name-text-field",
6942
6958
  maxLength: 50
6943
6959
  }), /*#__PURE__*/React.createElement(Textarea, {
@@ -6949,10 +6965,12 @@ var ManageTags = function ManageTags(_ref) {
6949
6965
  }))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(ActionBlock, {
6950
6966
  className: "flex items-center space-x-2",
6951
6967
  cancelButtonProps: {
6952
- onClick: onClose
6968
+ onClick: onClose,
6969
+ disabled: false
6953
6970
  },
6954
6971
  submitButtonProps: {
6955
- loading: isSubmitting
6972
+ loading: isSubmitting,
6973
+ label: t("saveChanges")
6956
6974
  }
6957
6975
  })));
6958
6976
  }));
@@ -7065,15 +7083,18 @@ var EmptyState = function EmptyState(_ref) {
7065
7083
  var Dashboard = function Dashboard(_ref) {
7066
7084
  var _data$tags2, _data$tags3, _data$tags4;
7067
7085
 
7068
- var tagType = _ref.tagType,
7069
- breadcrumbs = _ref.breadcrumbs,
7086
+ var breadcrumbs = _ref.breadcrumbs,
7087
+ createTags = _ref.createTags,
7088
+ deleteTags = _ref.deleteTags,
7070
7089
  displayMenu = _ref.displayMenu,
7071
7090
  handleMenuToggle = _ref.handleMenuToggle,
7072
- tagsPath = _ref.tagsPath,
7073
7091
  kbArticleUrl = _ref.kbArticleUrl,
7074
7092
  onTagRowClick = _ref.onTagRowClick,
7075
7093
  _ref$tagsMergable = _ref.tagsMergable,
7076
- tagsMergable = _ref$tagsMergable === void 0 ? false : _ref$tagsMergable;
7094
+ tagsMergable = _ref$tagsMergable === void 0 ? false : _ref$tagsMergable,
7095
+ tagsPath = _ref.tagsPath,
7096
+ tagType = _ref.tagType,
7097
+ updateTags = _ref.updateTags;
7077
7098
 
7078
7099
  var _useState = useState(null),
7079
7100
  _useState2 = _slicedToArray(_useState, 2),
@@ -7147,7 +7168,7 @@ var Dashboard = function Dashboard(_ref) {
7147
7168
  };
7148
7169
  mutate(payload, {
7149
7170
  onSuccess: function onSuccess() {
7150
- var _data$tags;
7171
+ var _data$tags, _deleteTags$onSuccess;
7151
7172
 
7152
7173
  setIsDeleteAlertOpen(false);
7153
7174
 
@@ -7157,6 +7178,7 @@ var Dashboard = function Dashboard(_ref) {
7157
7178
  });
7158
7179
  }
7159
7180
 
7181
+ deleteTags === null || deleteTags === void 0 ? void 0 : (_deleteTags$onSuccess = deleteTags.onSuccess) === null || _deleteTags$onSuccess === void 0 ? void 0 : _deleteTags$onSuccess.callback();
7160
7182
  Toastr.success(t("deleteSuccess"));
7161
7183
  },
7162
7184
  onError: function onError(_ref2) {
@@ -7183,7 +7205,7 @@ var Dashboard = function Dashboard(_ref) {
7183
7205
  setSearchTerm(value);
7184
7206
  },
7185
7207
  placeholder: t("search", {
7186
- where: t("title")
7208
+ where: t("title").toLocaleLowerCase()
7187
7209
  })
7188
7210
  },
7189
7211
  actionBlock: /*#__PURE__*/React.createElement(React.Fragment, null, tagsMergable && /*#__PURE__*/React.createElement(Button, {
@@ -7194,9 +7216,8 @@ var Dashboard = function Dashboard(_ref) {
7194
7216
  },
7195
7217
  disabled: (data === null || data === void 0 ? void 0 : data.tags.length) < PLURAL.count
7196
7218
  }), /*#__PURE__*/React.createElement(Button, {
7197
- icon: Plus,
7198
7219
  label: t("addNew", {
7199
- what: t("tag")
7220
+ what: t("tag").toLocaleLowerCase()
7200
7221
  }),
7201
7222
  onClick: function onClick() {
7202
7223
  setSelectedTag(null);
@@ -7206,12 +7227,11 @@ var Dashboard = function Dashboard(_ref) {
7206
7227
  })),
7207
7228
  breadcrumbs: breadcrumbs
7208
7229
  }), !(data !== null && data !== void 0 && (_data$tags2 = data.tags) !== null && _data$tags2 !== void 0 && _data$tags2.length) ? /*#__PURE__*/React.createElement(EmptyState, {
7209
- title: "No Tags Found",
7230
+ title: t("noTagsFound"),
7210
7231
  kbArticleUrl: kbArticleUrl,
7211
7232
  actionBlock: /*#__PURE__*/React.createElement(Button, {
7212
- icon: Plus,
7213
7233
  label: t("addNew", {
7214
- what: t("tag")
7234
+ what: t("tag").toLocaleLowerCase()
7215
7235
  }),
7216
7236
  onClick: function onClick() {
7217
7237
  setSelectedTag(null);
@@ -7225,7 +7245,7 @@ var Dashboard = function Dashboard(_ref) {
7225
7245
  leftActionBlock: /*#__PURE__*/React.createElement(Typography, {
7226
7246
  component: "h4",
7227
7247
  className: "neeto-ui-gray-800 font-semibold"
7228
- }, "".concat(data === null || data === void 0 ? void 0 : (_data$tags3 = data.tags) === null || _data$tags3 === void 0 ? void 0 : _data$tags3.length, " ").concat(tagType.label, " Tag(s)"))
7248
+ }, "".concat(data === null || data === void 0 ? void 0 : (_data$tags3 = data.tags) === null || _data$tags3 === void 0 ? void 0 : _data$tags3.length, " ").concat(tagType.label, " tag(s)"))
7229
7249
  }), /*#__PURE__*/React.createElement("div", {
7230
7250
  className: "neeto-tags--table__wrapper"
7231
7251
  }, /*#__PURE__*/React.createElement(Table, {
@@ -7252,18 +7272,20 @@ var Dashboard = function Dashboard(_ref) {
7252
7272
  x: "100%"
7253
7273
  }
7254
7274
  })))), /*#__PURE__*/React.createElement(ManageTags, {
7255
- type: paneType,
7256
- tagType: tagType,
7257
- tag: selectedTag,
7275
+ createTags: createTags,
7276
+ goToFirstPage: goToFirstPage,
7258
7277
  onClose: function onClose() {
7259
7278
  return setPaneType(null);
7260
7279
  },
7261
- goToFirstPage: goToFirstPage
7280
+ tag: selectedTag,
7281
+ tagType: tagType,
7282
+ type: paneType,
7283
+ updateTags: updateTags
7262
7284
  }), /*#__PURE__*/React.createElement(Alert, {
7263
7285
  isOpen: isDeleteAlertOpen,
7264
- title: "".concat(t("delete"), " ").concat(selectedTag === null || selectedTag === void 0 ? void 0 : selectedTag.name),
7286
+ title: t("deleteTag"),
7265
7287
  message: /*#__PURE__*/React.createElement(React.Fragment, null, t("deleteItem", {
7266
- type: t("tag")
7288
+ type: t("tag").toLocaleLowerCase()
7267
7289
  }), " ", /*#__PURE__*/React.createElement("strong", null, selectedTag === null || selectedTag === void 0 ? void 0 : selectedTag.name), "? ", t("cannotBeUndone")),
7268
7290
  onSubmit: handleConfirmDelete,
7269
7291
  onClose: handleAlertClose,
@@ -7280,6 +7302,9 @@ var List = function List(_ref) {
7280
7302
  selectedTagId = _ref.selectedTagId,
7281
7303
  type = _ref.type;
7282
7304
 
7305
+ var _useTranslation = useTranslation(),
7306
+ t = _useTranslation.t;
7307
+
7283
7308
  var _useState = useState([]),
7284
7309
  _useState2 = _slicedToArray(_useState, 2),
7285
7310
  tags = _useState2[0],
@@ -7306,7 +7331,9 @@ var List = function List(_ref) {
7306
7331
  onChange: function onChange(e) {
7307
7332
  return setSearchTerm(e.target.value);
7308
7333
  },
7309
- placeholder: "Search tags"
7334
+ placeholder: t("search", {
7335
+ where: t("tag").toLocaleLowerCase()
7336
+ })
7310
7337
  }), /*#__PURE__*/React.createElement("div", {
7311
7338
  className: "tags-merge__items"
7312
7339
  }, tags.map(function (tag) {
@@ -7435,12 +7462,13 @@ var MergeAlert = function MergeAlert(_ref) {
7435
7462
  var Merge = function Merge(_ref) {
7436
7463
  var _data$tags;
7437
7464
 
7438
- var tagType = _ref.tagType,
7439
- breadcrumbs = _ref.breadcrumbs,
7440
- tagsPath = _ref.tagsPath,
7441
- handleMenuToggle = _ref.handleMenuToggle,
7465
+ var breadcrumbs = _ref.breadcrumbs,
7442
7466
  displayMenu = _ref.displayMenu,
7443
- kbArticleUrl = _ref.kbArticleUrl;
7467
+ handleMenuToggle = _ref.handleMenuToggle,
7468
+ kbArticleUrl = _ref.kbArticleUrl,
7469
+ mergeTags = _ref.mergeTags,
7470
+ tagsPath = _ref.tagsPath,
7471
+ tagType = _ref.tagType;
7444
7472
 
7445
7473
  var _useState = useState({}),
7446
7474
  _useState2 = _slicedToArray(_useState, 2),
@@ -7491,8 +7519,11 @@ var Merge = function Merge(_ref) {
7491
7519
  payload: payload
7492
7520
  }, {
7493
7521
  onSuccess: function onSuccess() {
7522
+ var _mergeTags$onSuccess;
7523
+
7494
7524
  setDestinationTag("");
7495
7525
  setSourceTag("");
7526
+ mergeTags === null || mergeTags === void 0 ? void 0 : (_mergeTags$onSuccess = mergeTags.onSuccess) === null || _mergeTags$onSuccess === void 0 ? void 0 : _mergeTags$onSuccess.callback();
7496
7527
  setIsModalOpen(false);
7497
7528
  }
7498
7529
  });
@@ -7520,14 +7551,14 @@ var Merge = function Merge(_ref) {
7520
7551
  }),
7521
7552
  breadcrumbs: updatedBreadcrumbs
7522
7553
  }), !(data !== null && data !== void 0 && (_data$tags = data.tags) !== null && _data$tags !== void 0 && _data$tags.length) ? /*#__PURE__*/React.createElement(EmptyState, {
7523
- title: "Tags Not Found",
7554
+ title: t("noTagsFound"),
7524
7555
  kbArticleUrl: kbArticleUrl,
7525
7556
  actionBlock: /*#__PURE__*/React.createElement(Button, {
7526
7557
  size: "small",
7527
7558
  onClick: function onClick() {
7528
7559
  return history.push(tagsPath);
7529
7560
  },
7530
- label: "Go Back"
7561
+ label: t("goBack")
7531
7562
  })
7532
7563
  }) : /*#__PURE__*/React.createElement(Scrollable, {
7533
7564
  className: "w-full"
@@ -7539,7 +7570,7 @@ var Merge = function Merge(_ref) {
7539
7570
  selectedCounterTagId: destinationTag === null || destinationTag === void 0 ? void 0 : destinationTag.id,
7540
7571
  selectedTagId: sourceTag === null || sourceTag === void 0 ? void 0 : sourceTag.id,
7541
7572
  type: t("select", {
7542
- what: t("merge.sourceTag")
7573
+ what: t("merge.sourceTag").toLocaleLowerCase()
7543
7574
  })
7544
7575
  }), /*#__PURE__*/React.createElement(List, {
7545
7576
  tagList: data === null || data === void 0 ? void 0 : data.tags,
@@ -7547,7 +7578,7 @@ var Merge = function Merge(_ref) {
7547
7578
  selectedCounterTagId: sourceTag === null || sourceTag === void 0 ? void 0 : sourceTag.id,
7548
7579
  selectedTagId: destinationTag === null || destinationTag === void 0 ? void 0 : destinationTag.id,
7549
7580
  type: t("select", {
7550
- what: t("merge.destinationTag")
7581
+ what: t("merge.destinationTag").toLocaleLowerCase()
7551
7582
  })
7552
7583
  })))), /*#__PURE__*/React.createElement(MergeAlert, {
7553
7584
  showModal: isModalOpen,