studiokit-scaffolding-js 4.9.0-alpha.1 → 4.9.0-alpha.2
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.
|
@@ -9,6 +9,8 @@ export interface UserRolesReduxProps {
|
|
|
9
9
|
canDeleteSelf?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface UserRolesOwnProps extends CollectionComponentWrappedProps<UserRole> {
|
|
12
|
+
/** Should the component prevent modifications, independent of permissions? */
|
|
13
|
+
readOnly?: boolean;
|
|
12
14
|
/** Is the current user allowed to delete their own user role? Overrides the value from redux. */
|
|
13
15
|
canDeleteSelf?: boolean;
|
|
14
16
|
/** If multiple roles allowed, each role is displayed per user, otherwise a select dropdown is displayed. */
|
|
@@ -104,5 +106,5 @@ export declare class UserRoles extends Component<UserRolesProps, UserRolesState>
|
|
|
104
106
|
render(): JSX.Element;
|
|
105
107
|
}
|
|
106
108
|
export declare const mapStateToProps: (state: BaseReduxState, ownProps: UserRolesOwnProps) => UserRolesReduxProps;
|
|
107
|
-
declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "externalProviders" | "model" | "ref" | "key" | "guid" | "load" | "modelName" | "pathParams" | "modelStatus" | "queryParams" | "disableAutoLoad" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "previousModelStatus" | "fetchingId" | "textForRole" | "entityName" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "singularArticleForRole"> & UserRolesOwnProps>;
|
|
109
|
+
declare const _default: import("react-redux").ConnectedComponent<typeof UserRoles, Pick<React.ClassAttributes<UserRoles> & UserRolesProps, "externalProviders" | "model" | "ref" | "key" | "readOnly" | "guid" | "load" | "modelName" | "pathParams" | "modelStatus" | "queryParams" | "disableAutoLoad" | "modelArray" | "stopPeriodicLoad" | "create" | "update" | "delete" | "previousModelStatus" | "fetchingId" | "textForRole" | "entityName" | "defaultRole" | "roleDescriptions" | "renderAddDescription" | "isUpdateDisabled" | "isDeleteDisabled" | "allowMultipleRoles" | "requiredRole" | "isAddDisabled" | "modifyUserRoleActivityName" | "deleteOwnUserRoleActivityName" | "addRoleExcludeList" | "entity" | "filterUsers" | "onAdd" | "onUpdate" | "onRemove" | "renderTableDescription" | "singularArticleForRole"> & UserRolesOwnProps>;
|
|
108
110
|
export default _default;
|
|
@@ -390,12 +390,13 @@ var UserRoles = /** @class */ (function (_super) {
|
|
|
390
390
|
//#endregion Remove User
|
|
391
391
|
UserRoles.prototype.render = function () {
|
|
392
392
|
var _this = this;
|
|
393
|
-
var _a = this.props, modelStatus = _a.modelStatus, canModify = _a.canModify, canDeleteSelf = _a.canDeleteSelf, allowMultipleRoles = _a.allowMultipleRoles, isAddDisabled = _a.isAddDisabled, isUpdateDisabled = _a.isUpdateDisabled, isDeleteDisabled = _a.isDeleteDisabled, defaultRole = _a.defaultRole, requiredRole = _a.requiredRole, roleDescriptions = _a.roleDescriptions, addRoleExcludeList = _a.addRoleExcludeList, entityName = _a.entityName, renderTableDescription = _a.renderTableDescription, renderAddDescription = _a.renderAddDescription;
|
|
393
|
+
var _a = this.props, modelStatus = _a.modelStatus, canModify = _a.canModify, readOnly = _a.readOnly, canDeleteSelf = _a.canDeleteSelf, allowMultipleRoles = _a.allowMultipleRoles, isAddDisabled = _a.isAddDisabled, isUpdateDisabled = _a.isUpdateDisabled, isDeleteDisabled = _a.isDeleteDisabled, defaultRole = _a.defaultRole, requiredRole = _a.requiredRole, roleDescriptions = _a.roleDescriptions, addRoleExcludeList = _a.addRoleExcludeList, entityName = _a.entityName, renderTableDescription = _a.renderTableDescription, renderAddDescription = _a.renderAddDescription;
|
|
394
394
|
var _b = this.state, sortedUsers = _b.sortedUsers, isAdding = _b.isAdding, isUpdating = _b.isUpdating, isRemoving = _b.isRemoving, shouldResetAddForm = _b.shouldResetAddForm, shouldShowRemoveDialog = _b.shouldShowRemoveDialog, userRoleToUpdate = _b.userRoleToUpdate, userRoleToRemove = _b.userRoleToRemove, successMessage = _b.successMessage, existingMessage = _b.existingMessage, blockedMessage = _b.blockedMessage, failMessage = _b.failMessage;
|
|
395
395
|
var addableRoleDescriptions = addRoleExcludeList
|
|
396
396
|
? lodash_1.pickBy(roleDescriptions, function (_, key) { return !addRoleExcludeList.includes(key); })
|
|
397
397
|
: roleDescriptions;
|
|
398
398
|
var roles = Object.keys(roleDescriptions);
|
|
399
|
+
var shouldRenderAsMutable = !readOnly && canModify;
|
|
399
400
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
400
401
|
!!successMessage && (react_1.default.createElement(AlertWithIcon_1.default, { id: "successMessageAlert", variant: "success", dismissible: true, onClose: function () {
|
|
401
402
|
return _this.setState({
|
|
@@ -421,13 +422,13 @@ var UserRoles = /** @class */ (function (_super) {
|
|
|
421
422
|
});
|
|
422
423
|
} },
|
|
423
424
|
react_1.default.createElement("p", { className: "pre-wrap" }, failMessage))),
|
|
424
|
-
|
|
425
|
-
!!renderTableDescription && renderTableDescription(
|
|
425
|
+
shouldRenderAsMutable && (react_1.default.createElement(Add_1.default, { id: "entityUserRolesAdd", disabled: isAddDisabled, entityName: entityName, defaultRole: defaultRole, roleDescriptions: addableRoleDescriptions, renderAddDescription: renderAddDescription, textForRole: this.textForRole, isAddingUsersToRole: isAdding, shouldReset: shouldResetAddForm, addUserRoles: this.addUserRoles })),
|
|
426
|
+
!!renderTableDescription && renderTableDescription(shouldRenderAsMutable),
|
|
426
427
|
react_1.default.createElement(react_bootstrap_1.Row, { className: "mt3" },
|
|
427
428
|
react_1.default.createElement(react_bootstrap_1.Col, { xs: 12 }, modelStatus === modelStatus_1.default.LOADING ? (react_1.default.createElement(Loading_1.default, null)) : sortedUsers.length > 0 ? (react_1.default.createElement(Context_1.UserRolesContext.Provider, { value: {
|
|
428
|
-
isUpdateDisabled: isUpdateDisabled,
|
|
429
|
-
isDeleteDisabled: isDeleteDisabled,
|
|
430
|
-
canModify:
|
|
429
|
+
isUpdateDisabled: isUpdateDisabled || readOnly,
|
|
430
|
+
isDeleteDisabled: isDeleteDisabled || readOnly,
|
|
431
|
+
canModify: shouldRenderAsMutable,
|
|
431
432
|
canDeleteSelf: canDeleteSelf,
|
|
432
433
|
allowMultipleRoles: allowMultipleRoles,
|
|
433
434
|
roles: roles,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "studiokit-scaffolding-js",
|
|
3
|
-
"version": "4.9.0-alpha.
|
|
3
|
+
"version": "4.9.0-alpha.2",
|
|
4
4
|
"description": "Common scaffolding for Studio apps at Purdue",
|
|
5
5
|
"repository": "https://gitlab.com/purdue-informatics/studiokit/studiokit-scaffolding-js",
|
|
6
6
|
"license": "MIT",
|