fleet/frontend/components/UserRow/helpers.js
noahtalerman 19816cee1a
Add help text within user actions dropdown menu. Update copy in API documentation. (#142)
- Add help text within dropdown in smaller font size underneath "Require password reset" saying "This will revoke all active Fleet API tokens for this user."
- Update API docs to use "API token" parlance instead of "Auth token"
2020-12-21 15:47:35 -08:00

34 lines
1.1 KiB
JavaScript

const userActionOptions = (isCurrentUser, user, invite) => {
const inviteActions = [
{ disabled: false, label: 'Revoke Invitation', value: 'revert_invitation' },
];
const userEnableAction = user.enabled
? { disabled: isCurrentUser, label: 'Disable Account', value: 'disable_account' }
: { disabled: false, label: 'Enable Account', value: 'enable_account' };
const userPromotionAction = user.admin
? { disabled: isCurrentUser, label: 'Demote User', value: 'demote_user' }
: { disabled: false, label: 'Promote User', value: 'promote_user' };
if (invite) return inviteActions;
const result = [
userEnableAction,
userPromotionAction,
];
if (!user.sso_enabled) {
result.push({ disabled: false, label: 'Require Password Reset', value: 'reset_password', helpText: 'This will revoke all active Fleet API tokens for this user.' });
}
result.push({ disabled: false, label: 'Modify Details', value: 'modify_details' });
return result;
};
const userStatusLabel = (user, invite) => {
if (invite) {
return 'Invited';
}
return user.enabled ? 'Active' : 'Disabled';
};
export default { userActionOptions, userStatusLabel };