@bigbinary/neeto-tags-frontend 0.0.29 → 0.0.31
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 +83 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +34 -0
package/dist/index.js
CHANGED
|
@@ -20,14 +20,14 @@ 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
|
|
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';
|
|
27
27
|
import axios from 'axios';
|
|
28
28
|
import { Container, Header, SubHeader, Scrollable, MenuBar } from '@bigbinary/neetoui/layouts';
|
|
29
29
|
import { Formik, Form } from 'formik';
|
|
30
|
-
import { Input, Textarea
|
|
30
|
+
import { Input, Textarea } from '@bigbinary/neetoui/formik';
|
|
31
31
|
import classnames from 'classnames';
|
|
32
32
|
|
|
33
33
|
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -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
|
|
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
|
|
3401
|
-
var selectOrCreate = "Select or
|
|
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
|
|
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
|
|
3425
|
-
destinationTag: "Destination
|
|
3426
|
-
mergeTags: "Merge
|
|
3427
|
+
sourceTag: "Source tag",
|
|
3428
|
+
destinationTag: "Destination tag",
|
|
3429
|
+
mergeTags: "Merge tags",
|
|
3427
3430
|
merge: "Merge",
|
|
3428
3431
|
confirmation: {
|
|
3429
|
-
title: "Merge
|
|
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,
|
|
@@ -3499,22 +3505,22 @@ var COMMON_COLUMNS = [{
|
|
|
3499
3505
|
},
|
|
3500
3506
|
width: "40%"
|
|
3501
3507
|
}];
|
|
3502
|
-
var TAG_SCHEMA = yup.object({
|
|
3508
|
+
var TAG_SCHEMA = yup.object().shape({
|
|
3503
3509
|
name: yup.string().typeError(instance.t("type", {
|
|
3504
3510
|
what: instance.t("name"),
|
|
3505
3511
|
type: instance.t("types.string")
|
|
3506
3512
|
})).required(instance.t("required", {
|
|
3507
3513
|
what: instance.t("name")
|
|
3508
|
-
})).max(50, instance.t("
|
|
3514
|
+
})).max(50, instance.t("maxLength", {
|
|
3509
3515
|
what: instance.t("name"),
|
|
3510
|
-
|
|
3516
|
+
length: 50
|
|
3511
3517
|
})),
|
|
3512
3518
|
description: yup.string().typeError(instance.t("type", {
|
|
3513
3519
|
what: instance.t("description"),
|
|
3514
3520
|
type: instance.t("types.string")
|
|
3515
|
-
})).nullable().max(
|
|
3521
|
+
})).nullable().max(255, instance.t("maxLength", {
|
|
3516
3522
|
what: instance.t("description"),
|
|
3517
|
-
|
|
3523
|
+
length: 255
|
|
3518
3524
|
}))
|
|
3519
3525
|
});
|
|
3520
3526
|
var PANE_TYPES = {
|
|
@@ -6852,7 +6858,8 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
6852
6858
|
var createTags = _ref.createTags,
|
|
6853
6859
|
goToFirstPage = _ref.goToFirstPage,
|
|
6854
6860
|
isEdit = _ref.isEdit,
|
|
6855
|
-
|
|
6861
|
+
onPaneClose = _ref.onPaneClose,
|
|
6862
|
+
setHasSubmitted = _ref.setHasSubmitted,
|
|
6856
6863
|
tagType = _ref.tagType,
|
|
6857
6864
|
updateTags = _ref.updateTags;
|
|
6858
6865
|
var tagModification = isEdit ? useUpdateTag : useCreateTag;
|
|
@@ -6866,6 +6873,7 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
6866
6873
|
var _values$description;
|
|
6867
6874
|
|
|
6868
6875
|
var resetForm = _ref2.resetForm;
|
|
6876
|
+
setHasSubmitted(true);
|
|
6869
6877
|
values.description = values === null || values === void 0 ? void 0 : (_values$description = values.description) === null || _values$description === void 0 ? void 0 : _values$description.trim();
|
|
6870
6878
|
var tagData = {
|
|
6871
6879
|
payload: {
|
|
@@ -6884,7 +6892,7 @@ var useTagsForm = function useTagsForm(_ref) {
|
|
|
6884
6892
|
|
|
6885
6893
|
!isEdit && goToFirstPage();
|
|
6886
6894
|
tagOperation === null || tagOperation === void 0 ? void 0 : (_tagOperation$onSucce = tagOperation.onSuccess) === null || _tagOperation$onSucce === void 0 ? void 0 : _tagOperation$onSucce.callback();
|
|
6887
|
-
|
|
6895
|
+
onPaneClose();
|
|
6888
6896
|
},
|
|
6889
6897
|
onError: function onError() {
|
|
6890
6898
|
resetForm();
|
|
@@ -6906,48 +6914,62 @@ var ManageTags = function ManageTags(_ref) {
|
|
|
6906
6914
|
tagType = _ref.tagType,
|
|
6907
6915
|
type = _ref.type,
|
|
6908
6916
|
updateTags = _ref.updateTags;
|
|
6909
|
-
var isEdit = type === PANE_TYPES.EDIT;
|
|
6910
|
-
var initValues = isEdit ? tag : INITIAL_TAG_VALUES;
|
|
6911
6917
|
|
|
6912
6918
|
var _useTranslation = useTranslation(),
|
|
6913
6919
|
t = _useTranslation.t;
|
|
6914
6920
|
|
|
6921
|
+
var _useState = useState(false),
|
|
6922
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6923
|
+
hasSubmitted = _useState2[0],
|
|
6924
|
+
setHasSubmitted = _useState2[1];
|
|
6925
|
+
|
|
6926
|
+
var isEdit = type === PANE_TYPES.EDIT;
|
|
6927
|
+
var initValues = isEdit ? tag : INITIAL_TAG_VALUES;
|
|
6928
|
+
|
|
6929
|
+
var onPaneClose = function onPaneClose() {
|
|
6930
|
+
setHasSubmitted(false);
|
|
6931
|
+
onClose();
|
|
6932
|
+
};
|
|
6933
|
+
|
|
6915
6934
|
var _useTagsForm = useTagsForm({
|
|
6916
6935
|
createTags: createTags,
|
|
6917
6936
|
goToFirstPage: goToFirstPage,
|
|
6918
6937
|
isEdit: isEdit,
|
|
6919
|
-
|
|
6938
|
+
onPaneClose: onPaneClose,
|
|
6939
|
+
setHasSubmitted: setHasSubmitted,
|
|
6920
6940
|
tagType: tagType,
|
|
6921
6941
|
updateTags: updateTags
|
|
6922
6942
|
}),
|
|
6923
|
-
handleSubmit = _useTagsForm.handleSubmit
|
|
6943
|
+
handleSubmit = _useTagsForm.handleSubmit,
|
|
6944
|
+
isSubmitting = _useTagsForm.isSubmitting;
|
|
6924
6945
|
|
|
6925
6946
|
return /*#__PURE__*/React.createElement(Pane, {
|
|
6926
6947
|
isOpen: !!type,
|
|
6927
|
-
onClose:
|
|
6948
|
+
onClose: onPaneClose
|
|
6928
6949
|
}, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
|
|
6929
6950
|
style: "h2",
|
|
6930
6951
|
weight: "semibold"
|
|
6931
6952
|
}, isEdit ? t("editItem", {
|
|
6932
|
-
what: t("tag")
|
|
6953
|
+
what: t("tag").toLocaleLowerCase()
|
|
6933
6954
|
}) : t("addNew", {
|
|
6934
|
-
what: t("tag")
|
|
6955
|
+
what: t("tag").toLocaleLowerCase()
|
|
6935
6956
|
}))), /*#__PURE__*/React.createElement(Formik, {
|
|
6936
6957
|
initialValues: initValues,
|
|
6937
|
-
validateOnBlur: false,
|
|
6938
|
-
validateOnChange: false,
|
|
6939
6958
|
onSubmit: handleSubmit,
|
|
6959
|
+
validateOnBlur: hasSubmitted,
|
|
6960
|
+
validateOnChange: hasSubmitted,
|
|
6940
6961
|
validationSchema: TAG_SCHEMA
|
|
6941
6962
|
}, function (_ref2) {
|
|
6942
|
-
var
|
|
6943
|
-
return /*#__PURE__*/React.createElement(
|
|
6944
|
-
className: "flex w-full flex-col space-y-4",
|
|
6963
|
+
var dirty = _ref2.dirty;
|
|
6964
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
6945
6965
|
noValidate: true
|
|
6966
|
+
}, /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
|
|
6967
|
+
className: "flex w-full flex-col space-y-4"
|
|
6946
6968
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
6947
6969
|
required: true,
|
|
6948
6970
|
autoFocus: true,
|
|
6949
6971
|
name: "name",
|
|
6950
|
-
label: "".concat(t("tag"), " ").concat(t("name")),
|
|
6972
|
+
label: "".concat(t("tag"), " ").concat(t("name").toLocaleLowerCase()),
|
|
6951
6973
|
"data-cy": "tag-name-text-field",
|
|
6952
6974
|
maxLength: 50
|
|
6953
6975
|
}), /*#__PURE__*/React.createElement(Textarea, {
|
|
@@ -6956,15 +6978,21 @@ var ManageTags = function ManageTags(_ref) {
|
|
|
6956
6978
|
rows: 3,
|
|
6957
6979
|
"data-cy": "tag-description-text-area",
|
|
6958
6980
|
maxLength: 255
|
|
6959
|
-
}))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6981
|
+
}))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(Button, {
|
|
6982
|
+
"data-cy": "neeto-tags-manage-tag-submit-button",
|
|
6983
|
+
disabled: !dirty || isSubmitting,
|
|
6984
|
+
label: t("saveChanges"),
|
|
6985
|
+
loading: isSubmitting,
|
|
6986
|
+
onClick: function onClick() {
|
|
6987
|
+
return setHasSubmitted(true);
|
|
6964
6988
|
},
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6989
|
+
style: "primary",
|
|
6990
|
+
type: "submit"
|
|
6991
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
6992
|
+
"data-cy": "neeto-tags-manage-tag-cancel-button",
|
|
6993
|
+
label: t("cancel"),
|
|
6994
|
+
onClick: onPaneClose,
|
|
6995
|
+
style: "text"
|
|
6968
6996
|
})));
|
|
6969
6997
|
}));
|
|
6970
6998
|
};
|
|
@@ -7198,7 +7226,7 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
7198
7226
|
setSearchTerm(value);
|
|
7199
7227
|
},
|
|
7200
7228
|
placeholder: t("search", {
|
|
7201
|
-
where: t("title")
|
|
7229
|
+
where: t("title").toLocaleLowerCase()
|
|
7202
7230
|
})
|
|
7203
7231
|
},
|
|
7204
7232
|
actionBlock: /*#__PURE__*/React.createElement(React.Fragment, null, tagsMergable && /*#__PURE__*/React.createElement(Button, {
|
|
@@ -7209,9 +7237,8 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
7209
7237
|
},
|
|
7210
7238
|
disabled: (data === null || data === void 0 ? void 0 : data.tags.length) < PLURAL.count
|
|
7211
7239
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
7212
|
-
icon: Plus,
|
|
7213
7240
|
label: t("addNew", {
|
|
7214
|
-
what: t("tag")
|
|
7241
|
+
what: t("tag").toLocaleLowerCase()
|
|
7215
7242
|
}),
|
|
7216
7243
|
onClick: function onClick() {
|
|
7217
7244
|
setSelectedTag(null);
|
|
@@ -7221,12 +7248,11 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
7221
7248
|
})),
|
|
7222
7249
|
breadcrumbs: breadcrumbs
|
|
7223
7250
|
}), !(data !== null && data !== void 0 && (_data$tags2 = data.tags) !== null && _data$tags2 !== void 0 && _data$tags2.length) ? /*#__PURE__*/React.createElement(EmptyState, {
|
|
7224
|
-
title: "
|
|
7251
|
+
title: t("noTagsFound"),
|
|
7225
7252
|
kbArticleUrl: kbArticleUrl,
|
|
7226
7253
|
actionBlock: /*#__PURE__*/React.createElement(Button, {
|
|
7227
|
-
icon: Plus,
|
|
7228
7254
|
label: t("addNew", {
|
|
7229
|
-
what: t("tag")
|
|
7255
|
+
what: t("tag").toLocaleLowerCase()
|
|
7230
7256
|
}),
|
|
7231
7257
|
onClick: function onClick() {
|
|
7232
7258
|
setSelectedTag(null);
|
|
@@ -7240,7 +7266,7 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
7240
7266
|
leftActionBlock: /*#__PURE__*/React.createElement(Typography, {
|
|
7241
7267
|
component: "h4",
|
|
7242
7268
|
className: "neeto-ui-gray-800 font-semibold"
|
|
7243
|
-
}, "".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, "
|
|
7269
|
+
}, "".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)"))
|
|
7244
7270
|
}), /*#__PURE__*/React.createElement("div", {
|
|
7245
7271
|
className: "neeto-tags--table__wrapper"
|
|
7246
7272
|
}, /*#__PURE__*/React.createElement(Table, {
|
|
@@ -7278,9 +7304,9 @@ var Dashboard = function Dashboard(_ref) {
|
|
|
7278
7304
|
updateTags: updateTags
|
|
7279
7305
|
}), /*#__PURE__*/React.createElement(Alert, {
|
|
7280
7306
|
isOpen: isDeleteAlertOpen,
|
|
7281
|
-
title:
|
|
7307
|
+
title: t("deleteTag"),
|
|
7282
7308
|
message: /*#__PURE__*/React.createElement(React.Fragment, null, t("deleteItem", {
|
|
7283
|
-
type: t("tag")
|
|
7309
|
+
type: t("tag").toLocaleLowerCase()
|
|
7284
7310
|
}), " ", /*#__PURE__*/React.createElement("strong", null, selectedTag === null || selectedTag === void 0 ? void 0 : selectedTag.name), "? ", t("cannotBeUndone")),
|
|
7285
7311
|
onSubmit: handleConfirmDelete,
|
|
7286
7312
|
onClose: handleAlertClose,
|
|
@@ -7297,6 +7323,9 @@ var List = function List(_ref) {
|
|
|
7297
7323
|
selectedTagId = _ref.selectedTagId,
|
|
7298
7324
|
type = _ref.type;
|
|
7299
7325
|
|
|
7326
|
+
var _useTranslation = useTranslation(),
|
|
7327
|
+
t = _useTranslation.t;
|
|
7328
|
+
|
|
7300
7329
|
var _useState = useState([]),
|
|
7301
7330
|
_useState2 = _slicedToArray(_useState, 2),
|
|
7302
7331
|
tags = _useState2[0],
|
|
@@ -7323,7 +7352,9 @@ var List = function List(_ref) {
|
|
|
7323
7352
|
onChange: function onChange(e) {
|
|
7324
7353
|
return setSearchTerm(e.target.value);
|
|
7325
7354
|
},
|
|
7326
|
-
placeholder: "
|
|
7355
|
+
placeholder: t("search", {
|
|
7356
|
+
where: t("tag").toLocaleLowerCase()
|
|
7357
|
+
})
|
|
7327
7358
|
}), /*#__PURE__*/React.createElement("div", {
|
|
7328
7359
|
className: "tags-merge__items"
|
|
7329
7360
|
}, tags.map(function (tag) {
|
|
@@ -7541,14 +7572,14 @@ var Merge = function Merge(_ref) {
|
|
|
7541
7572
|
}),
|
|
7542
7573
|
breadcrumbs: updatedBreadcrumbs
|
|
7543
7574
|
}), !(data !== null && data !== void 0 && (_data$tags = data.tags) !== null && _data$tags !== void 0 && _data$tags.length) ? /*#__PURE__*/React.createElement(EmptyState, {
|
|
7544
|
-
title: "
|
|
7575
|
+
title: t("noTagsFound"),
|
|
7545
7576
|
kbArticleUrl: kbArticleUrl,
|
|
7546
7577
|
actionBlock: /*#__PURE__*/React.createElement(Button, {
|
|
7547
7578
|
size: "small",
|
|
7548
7579
|
onClick: function onClick() {
|
|
7549
7580
|
return history.push(tagsPath);
|
|
7550
7581
|
},
|
|
7551
|
-
label: "
|
|
7582
|
+
label: t("goBack")
|
|
7552
7583
|
})
|
|
7553
7584
|
}) : /*#__PURE__*/React.createElement(Scrollable, {
|
|
7554
7585
|
className: "w-full"
|
|
@@ -7560,7 +7591,7 @@ var Merge = function Merge(_ref) {
|
|
|
7560
7591
|
selectedCounterTagId: destinationTag === null || destinationTag === void 0 ? void 0 : destinationTag.id,
|
|
7561
7592
|
selectedTagId: sourceTag === null || sourceTag === void 0 ? void 0 : sourceTag.id,
|
|
7562
7593
|
type: t("select", {
|
|
7563
|
-
what: t("merge.sourceTag")
|
|
7594
|
+
what: t("merge.sourceTag").toLocaleLowerCase()
|
|
7564
7595
|
})
|
|
7565
7596
|
}), /*#__PURE__*/React.createElement(List, {
|
|
7566
7597
|
tagList: data === null || data === void 0 ? void 0 : data.tags,
|
|
@@ -7568,7 +7599,7 @@ var Merge = function Merge(_ref) {
|
|
|
7568
7599
|
selectedCounterTagId: sourceTag === null || sourceTag === void 0 ? void 0 : sourceTag.id,
|
|
7569
7600
|
selectedTagId: destinationTag === null || destinationTag === void 0 ? void 0 : destinationTag.id,
|
|
7570
7601
|
type: t("select", {
|
|
7571
|
-
what: t("merge.destinationTag")
|
|
7602
|
+
what: t("merge.destinationTag").toLocaleLowerCase()
|
|
7572
7603
|
})
|
|
7573
7604
|
})))), /*#__PURE__*/React.createElement(MergeAlert, {
|
|
7574
7605
|
showModal: isModalOpen,
|