Repository URL to install this package:
|
Version:
3.12.20 ▾
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(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; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import { VISIBILITY_OPTIONS, PUBLISH_ACCESS_MODE_OPTIONS } from '@filerobot/utils/lib/constants';
import { getActualVisibility } from '@filerobot/utils/lib/visibility';
import RadioOptions from './RadioOptions';
import * as Styled from './PublishModal.styled';
import { VISIBILITY_INHERITED_GET } from './Publish.constants';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
var VISIBILITY_LIST = [VISIBILITY_OPTIONS.PUBLIC, VISIBILITY_OPTIONS.NOT_PUBLIC];
var VisibilitySection = function VisibilitySection(_ref) {
var i18n = _ref.i18n,
accessMode = _ref.accessMode,
setAccessMode = _ref.setAccessMode,
visibility = _ref.visibility,
setVisibility = _ref.setVisibility,
isAccessModeInherit = _ref.isAccessModeInherit,
parentFolder = _ref.parentFolder,
openedFolders = _ref.openedFolders,
data = _ref.data,
updateData = _ref.updateData,
filesUuids = _ref.filesUuids,
foldersUuids = _ref.foldersUuids;
var onAccessModeChange = function onAccessModeChange(nextAccessMode) {
var _openedFolders$find;
/* TODO (Dima) a hack to get actual visibility from folder when Inherit is set. This logic should be moved to BE.
here is the task https://scaleflexhq.atlassian.net/browse/FRA-2025, after implementation it should be switch to
visibility.parent instead of trying to get parent folder */
var parentFolderVisibility = openedFolders && getActualVisibility((_openedFolders$find = openedFolders.find(function (_ref2) {
var uuid = _ref2.uuid;
return (parentFolder === null || parentFolder === void 0 ? void 0 : parentFolder.uuid) === uuid;
})) === null || _openedFolders$find === void 0 ? void 0 : _openedFolders$find.visibility);
setAccessMode(nextAccessMode);
if (nextAccessMode === PUBLISH_ACCESS_MODE_OPTIONS.INHERITED.value) {
setVisibility(parentFolderVisibility);
updateData(_objectSpread(_objectSpread({}, data), {}, {
filesUuids: filesUuids,
foldersUuids: foldersUuids,
visibility: VISIBILITY_INHERITED_GET
}));
} else {
updateData(_objectSpread(_objectSpread({}, data), {}, {
filesUuids: filesUuids,
foldersUuids: foldersUuids,
visibility: visibility
}));
}
};
var onVisibilityChange = function onVisibilityChange(nextVisibility) {
setVisibility(nextVisibility);
updateData(_objectSpread(_objectSpread({}, data), {}, {
filesUuids: filesUuids,
foldersUuids: foldersUuids,
visibility: nextVisibility
}));
};
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsxs(Styled.ModalGroupWrapper, {
children: [/*#__PURE__*/_jsxs(Styled.ModalGroupInner, {
children: [/*#__PURE__*/_jsx(Styled.ModalGroupTitle, {
children: i18n('mutualizedAccessModeLabel')
}), /*#__PURE__*/_jsx(Styled.ModalGroupHint, {
children: i18n('accessModeHint')
})]
}), /*#__PURE__*/_jsx(RadioOptions, {
i18n: i18n,
options: Object.keys(PUBLISH_ACCESS_MODE_OPTIONS).map(function (key) {
return PUBLISH_ACCESS_MODE_OPTIONS[key];
}),
currentValue: accessMode,
isHint: false,
handleOptionSelection: onAccessModeChange
})]
}), /*#__PURE__*/_jsxs(Styled.ModalGroupWrapper, {
children: [/*#__PURE__*/_jsx(Styled.ModalGroupInner, {
children: /*#__PURE__*/_jsx(Styled.ModalGroupTitle, {
children: i18n('mutualizedVisibilityLabel')
})
}), /*#__PURE__*/_jsx(RadioOptions, {
i18n: i18n,
options: VISIBILITY_LIST,
currentValue: visibility,
isDisabled: isAccessModeInherit || !accessMode,
handleOptionSelection: onVisibilityChange
})]
})]
});
};
export default VisibilitySection;