@bigbinary/neeto-approvals-frontend 0.0.8 → 0.0.10
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.cjs.js +57 -53
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +58 -54
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as t$2 from 'react';
|
|
|
2
2
|
import t__default, { createContext, useContext, useState, useRef, useEffect, useMemo, forwardRef, useImperativeHandle, cloneElement, useLayoutEffect } from 'react';
|
|
3
3
|
import { Header, SubHeader, MenuBar, Container } from '@bigbinary/neetoui/layouts';
|
|
4
4
|
import { useLocation, useHistory, useParams, Switch, Route, Redirect } from 'react-router-dom';
|
|
5
|
-
import { isEmpty, assoc, curryN, isNil, curry, complement, either, toPairs, pipe, omit, fromPairs, keys,
|
|
5
|
+
import { isEmpty, assoc, curryN, isNil, curry, complement, either, toPairs, pipe, omit, fromPairs, keys, modify } from 'ramda';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
7
|
import { Typography, Pane, Button, Dropdown, PageLoader, Table, Alert, Tag, Spinner, Kbd, Avatar, Label, Tooltip, Input as Input$1, Toastr, Modal, Tab, Select as Select$1 } from '@bigbinary/neetoui';
|
|
8
8
|
import axios from 'axios';
|
|
@@ -4984,12 +4984,6 @@ var nullSafe$1 = function nullSafe(func) {
|
|
|
4984
4984
|
);
|
|
4985
4985
|
};
|
|
4986
4986
|
var noop = function noop() {};
|
|
4987
|
-
var toLabelAndValue = function toLabelAndValue(string) {
|
|
4988
|
-
return {
|
|
4989
|
-
label: string,
|
|
4990
|
-
value: string
|
|
4991
|
-
};
|
|
4992
|
-
};
|
|
4993
4987
|
var isNotEmpty = /*#__PURE__*/complement(isEmpty);
|
|
4994
4988
|
var isNotPresent = /*#__PURE__*/either(isNil, isEmpty);
|
|
4995
4989
|
var isPresent = /*#__PURE__*/complement(isNotPresent);
|
|
@@ -7778,7 +7772,7 @@ const HISTORY_TABLE_COLUMNS = [{
|
|
|
7778
7772
|
title: t$1("common.id"),
|
|
7779
7773
|
render: (approvalLabel, _ref) => {
|
|
7780
7774
|
let requestableUrl = _ref.requestableUrl;
|
|
7781
|
-
const url = new URL(requestableUrl);
|
|
7775
|
+
const url = new URL(requestableUrl || window.location.origin);
|
|
7782
7776
|
return /*#__PURE__*/t__default.createElement(Button, {
|
|
7783
7777
|
to: url.pathname,
|
|
7784
7778
|
label: approvalLabel,
|
|
@@ -8101,16 +8095,21 @@ const fetch$1 = params => axios.get(`${BASE_URL}/templates`, {
|
|
|
8101
8095
|
params
|
|
8102
8096
|
});
|
|
8103
8097
|
const show$1 = id => axios.get(`${BASE_URL}/templates/${id}`);
|
|
8104
|
-
const create =
|
|
8105
|
-
|
|
8106
|
-
|
|
8098
|
+
const create = _ref => {
|
|
8099
|
+
let _ref$url = _ref.url,
|
|
8100
|
+
url = _ref$url === void 0 ? BASE_URL : _ref$url,
|
|
8107
8101
|
payload = _ref.payload;
|
|
8108
|
-
return axios.
|
|
8109
|
-
template: payload
|
|
8110
|
-
});
|
|
8102
|
+
return axios.post(url, payload);
|
|
8111
8103
|
};
|
|
8112
|
-
const
|
|
8113
|
-
let
|
|
8104
|
+
const update = _ref2 => {
|
|
8105
|
+
let id = _ref2.id,
|
|
8106
|
+
payload = _ref2.payload,
|
|
8107
|
+
_ref2$url = _ref2.url,
|
|
8108
|
+
url = _ref2$url === void 0 ? BASE_URL : _ref2$url;
|
|
8109
|
+
return axios.put(`${url}/${id}`, payload);
|
|
8110
|
+
};
|
|
8111
|
+
const destroy = _ref3 => {
|
|
8112
|
+
let templateId = _ref3.templateId;
|
|
8114
8113
|
return axios.delete(`${BASE_URL}/templates/${templateId}`);
|
|
8115
8114
|
};
|
|
8116
8115
|
const templatesApi = {
|
|
@@ -8187,7 +8186,11 @@ const columnData = _ref => {
|
|
|
8187
8186
|
dataIndex: "visibility",
|
|
8188
8187
|
key: "visibility",
|
|
8189
8188
|
sorter: true,
|
|
8190
|
-
title: instance.t("common.visibility")
|
|
8189
|
+
title: instance.t("common.visibility"),
|
|
8190
|
+
render: (_, _ref2) => {
|
|
8191
|
+
let accessible = _ref2.accessible;
|
|
8192
|
+
return accessible.label;
|
|
8193
|
+
}
|
|
8191
8194
|
}, {
|
|
8192
8195
|
key: "actions",
|
|
8193
8196
|
ellipsis: true,
|
|
@@ -8278,10 +8281,7 @@ const Templates = _ref => {
|
|
|
8278
8281
|
label: t("common.add_", {
|
|
8279
8282
|
what: t("common.approvalTemplate").toLocaleLowerCase()
|
|
8280
8283
|
}),
|
|
8281
|
-
onClick: () => {
|
|
8282
|
-
setIsMenubarOpen(false);
|
|
8283
|
-
history.push(`${approvalsPath}${routes.templates.new}`);
|
|
8284
|
-
}
|
|
8284
|
+
onClick: () => history.push(`${approvalsPath}${routes.templates.new}`)
|
|
8285
8285
|
});
|
|
8286
8286
|
if (isTemplateLoading) {
|
|
8287
8287
|
return /*#__PURE__*/t__default.createElement("div", {
|
|
@@ -8346,26 +8346,16 @@ const TEMPLATE_FORM_INITIAL_VALUES = {
|
|
|
8346
8346
|
};
|
|
8347
8347
|
const TEMPLATE_FORM_VALIDATION_SCHEMA = yup.object().shape({
|
|
8348
8348
|
name: yup.string().trim().required(t$1("validations.name")),
|
|
8349
|
-
description: yup.string().trim().required(t$1("validations.description")),
|
|
8350
8349
|
recipient: yup.object().required(t$1("validations.recipient")),
|
|
8351
8350
|
message: yup.string().test("message", t$1("validations.message"), content => !fr(content)),
|
|
8352
8351
|
variables: yup.array().of(yup.object().shape({
|
|
8353
8352
|
variable: yup.string().trim().required(t$1("validations.variable"))
|
|
8354
8353
|
}))
|
|
8355
8354
|
});
|
|
8356
|
-
const
|
|
8355
|
+
const SELF_VISIBILITY = {
|
|
8357
8356
|
label: t$1("select.visibility.self"),
|
|
8358
|
-
value: "
|
|
8359
|
-
}
|
|
8360
|
-
label: t$1("select.visibility.supportTeam"),
|
|
8361
|
-
value: "Support team"
|
|
8362
|
-
}, {
|
|
8363
|
-
label: t$1("select.visibility.managers"),
|
|
8364
|
-
value: "Managers"
|
|
8365
|
-
}, {
|
|
8366
|
-
label: t$1("select.visibility.financeTeam"),
|
|
8367
|
-
value: "Finance team"
|
|
8368
|
-
}];
|
|
8357
|
+
value: "self"
|
|
8358
|
+
};
|
|
8369
8359
|
|
|
8370
8360
|
const DynamicBlock = () => {
|
|
8371
8361
|
const _useTranslation = useTranslation(),
|
|
@@ -8373,11 +8363,12 @@ const DynamicBlock = () => {
|
|
|
8373
8363
|
const _useFormikContext = useFormikContext(),
|
|
8374
8364
|
_useFormikContext$val = _useFormikContext.values.variables,
|
|
8375
8365
|
variables = _useFormikContext$val === void 0 ? [] : _useFormikContext$val;
|
|
8376
|
-
const editorVariables = variables.map(_ref => {
|
|
8366
|
+
const editorVariables = variables.map((_ref, index) => {
|
|
8377
8367
|
let variable = _ref.variable;
|
|
8368
|
+
const variableValue = variable || `variable_${index + 1}`;
|
|
8378
8369
|
return {
|
|
8379
|
-
key:
|
|
8380
|
-
label:
|
|
8370
|
+
key: variableValue,
|
|
8371
|
+
label: variableValue
|
|
8381
8372
|
};
|
|
8382
8373
|
});
|
|
8383
8374
|
return /*#__PURE__*/t__default.createElement(t__default.Fragment, null, /*#__PURE__*/t__default.createElement("div", {
|
|
@@ -8428,7 +8419,8 @@ const Form$1 = _ref => {
|
|
|
8428
8419
|
_ref$onSubmit = _ref.onSubmit,
|
|
8429
8420
|
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
8430
8421
|
_ref$isLoading = _ref.isLoading,
|
|
8431
|
-
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading
|
|
8422
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
8423
|
+
visibilityOptions = _ref.visibilityOptions;
|
|
8432
8424
|
const history = useHistory();
|
|
8433
8425
|
const _useTranslation = useTranslation(),
|
|
8434
8426
|
t = _useTranslation.t;
|
|
@@ -8469,9 +8461,9 @@ const Form$1 = _ref => {
|
|
|
8469
8461
|
}), /*#__PURE__*/t__default.createElement(Select, {
|
|
8470
8462
|
name: "visibility",
|
|
8471
8463
|
label: t("common.visibility"),
|
|
8472
|
-
options:
|
|
8464
|
+
options: [...visibilityOptions, SELF_VISIBILITY]
|
|
8473
8465
|
})), /*#__PURE__*/t__default.createElement(DynamicBlock, null), /*#__PURE__*/t__default.createElement("div", {
|
|
8474
|
-
className: "space-x-4"
|
|
8466
|
+
className: "space-x-4 pb-6"
|
|
8475
8467
|
}, /*#__PURE__*/t__default.createElement(Button, {
|
|
8476
8468
|
label: t("buttons.saveChanges"),
|
|
8477
8469
|
type: "submit",
|
|
@@ -8493,16 +8485,20 @@ const buildTemplatePayload = template => {
|
|
|
8493
8485
|
let variable = _ref.variable;
|
|
8494
8486
|
return [`variable${index + 1}`, variable];
|
|
8495
8487
|
});
|
|
8496
|
-
const payload =
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8488
|
+
const payload = {
|
|
8489
|
+
template: _objectSpread$3(_objectSpread$3({}, template), {}, {
|
|
8490
|
+
accessibleId: visibility.value,
|
|
8491
|
+
approverId: recipient.value,
|
|
8492
|
+
variables: fromPairs(indexedVariables)
|
|
8493
|
+
})
|
|
8494
|
+
};
|
|
8501
8495
|
return payload;
|
|
8502
8496
|
};
|
|
8503
8497
|
|
|
8504
8498
|
const Create = _ref => {
|
|
8505
|
-
let approvalsPath = _ref.approvalsPath
|
|
8499
|
+
let approvalsPath = _ref.approvalsPath,
|
|
8500
|
+
visibilityOptions = _ref.visibilityOptions,
|
|
8501
|
+
templateUrl = _ref.templateUrl;
|
|
8506
8502
|
const history = useHistory();
|
|
8507
8503
|
const _useTranslation = useTranslation(),
|
|
8508
8504
|
t = _useTranslation.t;
|
|
@@ -8511,7 +8507,10 @@ const Create = _ref => {
|
|
|
8511
8507
|
isLoading = _useCreateTemplate.isLoading;
|
|
8512
8508
|
const onSubmit = template => {
|
|
8513
8509
|
const payload = buildTemplatePayload(template);
|
|
8514
|
-
createTemplate(
|
|
8510
|
+
createTemplate({
|
|
8511
|
+
url: templateUrl,
|
|
8512
|
+
payload
|
|
8513
|
+
}, {
|
|
8515
8514
|
onSuccess: () => history.push(`${approvalsPath}${routes.templates.index}`)
|
|
8516
8515
|
});
|
|
8517
8516
|
};
|
|
@@ -8525,7 +8524,8 @@ const Create = _ref => {
|
|
|
8525
8524
|
}]
|
|
8526
8525
|
}), /*#__PURE__*/t__default.createElement(Form$1, {
|
|
8527
8526
|
onSubmit: onSubmit,
|
|
8528
|
-
isLoading: isLoading
|
|
8527
|
+
isLoading: isLoading,
|
|
8528
|
+
visibilityOptions: visibilityOptions
|
|
8529
8529
|
}));
|
|
8530
8530
|
};
|
|
8531
8531
|
|
|
@@ -8533,7 +8533,9 @@ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if
|
|
|
8533
8533
|
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8534
8534
|
const Edit = _ref => {
|
|
8535
8535
|
var _template$recipient, _template$recipient2;
|
|
8536
|
-
let approvalsPath = _ref.approvalsPath
|
|
8536
|
+
let approvalsPath = _ref.approvalsPath,
|
|
8537
|
+
visibilityOptions = _ref.visibilityOptions,
|
|
8538
|
+
templateUrl = _ref.templateUrl;
|
|
8537
8539
|
const _useParams = useParams(),
|
|
8538
8540
|
id = _useParams.id;
|
|
8539
8541
|
const history = useHistory();
|
|
@@ -8556,7 +8558,8 @@ const Edit = _ref => {
|
|
|
8556
8558
|
const payload = buildTemplatePayload(template);
|
|
8557
8559
|
updateTemplate({
|
|
8558
8560
|
id,
|
|
8559
|
-
payload
|
|
8561
|
+
payload,
|
|
8562
|
+
url: templateUrl
|
|
8560
8563
|
});
|
|
8561
8564
|
};
|
|
8562
8565
|
if (isFetchingTemplate) {
|
|
@@ -8573,10 +8576,11 @@ const Edit = _ref => {
|
|
|
8573
8576
|
text: t("common.templates")
|
|
8574
8577
|
}]
|
|
8575
8578
|
}), /*#__PURE__*/t__default.createElement(Form$1, {
|
|
8579
|
+
visibilityOptions: visibilityOptions,
|
|
8576
8580
|
onSubmit: onSubmit,
|
|
8577
8581
|
isLoading: isUpdating,
|
|
8578
8582
|
initialData: _objectSpread$2(_objectSpread$2({}, template), {}, {
|
|
8579
|
-
visibility:
|
|
8583
|
+
visibility: template.accessible.id,
|
|
8580
8584
|
recipient: {
|
|
8581
8585
|
label: (_template$recipient = template.recipient) === null || _template$recipient === void 0 ? void 0 : _template$recipient.name,
|
|
8582
8586
|
value: (_template$recipient2 = template.recipient) === null || _template$recipient2 === void 0 ? void 0 : _template$recipient2.id
|
|
@@ -8618,7 +8622,7 @@ const Menu = _ref => {
|
|
|
8618
8622
|
const _useTranslation = useTranslation(),
|
|
8619
8623
|
t = _useTranslation.t;
|
|
8620
8624
|
const category = (_pathname$split$ = pathname.split(routes.approvals)[1]) === null || _pathname$split$ === void 0 ? void 0 : _pathname$split$.toLocaleUpperCase();
|
|
8621
|
-
const isActive = filter =>
|
|
8625
|
+
const isActive = filter => category.includes(filter);
|
|
8622
8626
|
const getRoute = filter => `${approvalsPath}${filter.toLowerCase()}`;
|
|
8623
8627
|
return /*#__PURE__*/t__default.createElement(MenuBar, {
|
|
8624
8628
|
showMenu: isMenuOpen,
|
|
@@ -8635,7 +8639,7 @@ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if
|
|
|
8635
8639
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8636
8640
|
const Approvals = _ref => {
|
|
8637
8641
|
let config = _ref.config;
|
|
8638
|
-
const _useState = useState(
|
|
8642
|
+
const _useState = useState(true),
|
|
8639
8643
|
_useState2 = _slicedToArray$2(_useState, 2),
|
|
8640
8644
|
isMenubarOpen = _useState2[0],
|
|
8641
8645
|
setIsMenubarOpen = _useState2[1];
|
|
@@ -8733,7 +8737,7 @@ const Form = _ref => {
|
|
|
8733
8737
|
}, variables.map(variable => /*#__PURE__*/t__default.createElement(Input$1, {
|
|
8734
8738
|
className: "w-full",
|
|
8735
8739
|
key: variable,
|
|
8736
|
-
label:
|
|
8740
|
+
label: variable,
|
|
8737
8741
|
value: variableValues[variable],
|
|
8738
8742
|
onChange: event => {
|
|
8739
8743
|
setVariableValues(assoc(variable, event.target.value));
|