Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NET-1600): add description of platform access level, fix "tenant"… #762

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions src/components/modals/add-user-modal/AddUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Radio,
Row,
Select,
Skeleton,
Table,
TableColumnProps,
Tabs,
Expand All @@ -23,6 +24,7 @@ import { User, UserGroup, UserRole, UserRoleId } from '@/models/User';
import { UsersService } from '@/services/UsersService';
import { kebabCaseToTitleCase, useServerLicense } from '@/utils/Utils';
import { isAdminUserOrRole } from '@/utils/UserMgmtUtils';
import { ExternalLinks } from '@/constants/LinkAndImageConstants';

interface AddUserModalProps {
isOpen: boolean;
Expand Down Expand Up @@ -71,6 +73,7 @@ export default function AddUserModal({
const [groups, setGroups] = useState<UserGroup[]>([]);
const [selectedNetworkRoles, setSelectedNetworkRoles] = useState<NetworkRolePair[]>([]);
const [activeTab, setActiveTab] = useState(defaultTabKey);
const [isLoadingPlatformRoles, setIsLoadingPlatformRoles] = useState(true);

const palVal = Form.useWatch('platform_role_id', form);

Expand Down Expand Up @@ -176,6 +179,8 @@ export default function AddUserModal({
message: 'Failed to load roles',
description: extractErrorMsg(err as any),
});
} finally {
setIsLoadingPlatformRoles(false);
}
}, [notify]);

Expand Down Expand Up @@ -342,17 +347,29 @@ export default function AddUserModal({
<Form.Item
name="platform_role_id"
label="Platform Access Level"
tooltip="This specifies the tenant-wide permissions this user will have"
tooltip="This specifies the server-wide permissions this user will have"
rules={[{ required: true }]}
initialValue={isServerEE ? undefined : 'admin'}
>
<Radio.Group>
{platformRoles.map((role) => (
<Radio key={role.id} value={role.id} disabled={!isServerEE && !isAdminUserOrRole(role)}>
{kebabCaseToTitleCase(role.id)}
</Radio>
))}
</Radio.Group>
<Typography.Text type="secondary">
Admins can access all features and manage all users. Platform users can log into the dashboard and
access the networks they are assigned to. Service users cannot log into the dashboard; they use{' '}
<Typography.Link href={ExternalLinks.RAC_DOWNLOAD_DOCS_LINK} target="_blank">
RAC
</Typography.Link>{' '}
to access their assigned networks.
</Typography.Text>
<br />
<br />
<Skeleton active loading={isLoadingPlatformRoles} paragraph={false}>
<Radio.Group>
{platformRoles.map((role) => (
<Radio key={role.id} value={role.id} disabled={!isServerEE && !isAdminUserOrRole(role)}>
{kebabCaseToTitleCase(role.id)}
</Radio>
))}
</Radio.Group>
</Skeleton>
</Form.Item>
</Col>
</Row>
Expand Down
34 changes: 26 additions & 8 deletions src/components/modals/invite-user-modal/InviteUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Radio,
Row,
Select,
Skeleton,
Steps,
Table,
TableColumnProps,
Expand All @@ -28,6 +29,7 @@ import { copyTextToClipboard, kebabCaseToTitleCase, useServerLicense } from '@/u
import { getInviteMagicLink } from '@/utils/RouteUtils';
import CreateUserGroupModal from '@/pages/users/CreateUserGroupModal';
import { isAdminUserOrRole } from '@/utils/UserMgmtUtils';
import { ExternalLinks } from '@/constants/LinkAndImageConstants';

interface InviteUserModalProps {
isOpen: boolean;
Expand Down Expand Up @@ -85,6 +87,7 @@ export default function InviteUserModal({ isOpen, onInviteFinish, onClose, onCan
const [isCreateGroupModalOpen, setIsCreateGroupModalOpen] = useState(false);
const [activeTab, setActiveTab] = useState(defaultTabKey);
const [isCreating, setIsCreating] = useState(false);
const [isLoadingPlatformRoles, setIsLoadingPlatformRoles] = useState(true);

const userGroupsVal = Form.useWatch('user-groups', form);
const palVal = Form.useWatch('platform_role_id', form);
Expand Down Expand Up @@ -228,6 +231,8 @@ export default function InviteUserModal({ isOpen, onInviteFinish, onClose, onCan
message: 'Failed to load roles',
description: extractErrorMsg(err as any),
});
} finally {
setIsLoadingPlatformRoles(false);
}
}, [notify]);

Expand Down Expand Up @@ -388,17 +393,30 @@ export default function InviteUserModal({ isOpen, onInviteFinish, onClose, onCan
<Form.Item
name="platform_role_id"
label="Platform Access Level"
tooltip="This specifies the tenant-wide permissions this user will have"
tooltip="This specifies the server-wide permissions this user will have"
rules={[{ required: true }]}
initialValue={isServerEE ? undefined : 'admin'}
>
<Radio.Group>
{platformRoles.map((role) => (
<Radio key={role.id} value={role.id} disabled={!isServerEE && !isAdminUserOrRole(role)}>
{kebabCaseToTitleCase(role.id)}
</Radio>
))}
</Radio.Group>
<Typography.Text type="secondary">
Admins can access all features and manage all users. Platform users can log into the dashboard
and access the networks they are assigned to. Service users cannot log into the dashboard;
they use{' '}
<Typography.Link href={ExternalLinks.RAC_DOWNLOAD_DOCS_LINK} target="_blank">
RAC
</Typography.Link>{' '}
to access their assigned networks.
</Typography.Text>
<br />
<br />
<Skeleton active loading={isLoadingPlatformRoles} paragraph={false}>
<Radio.Group>
{platformRoles.map((role) => (
<Radio key={role.id} value={role.id} disabled={!isServerEE && !isAdminUserOrRole(role)}>
{kebabCaseToTitleCase(role.id)}
</Radio>
))}
</Radio.Group>
</Skeleton>
</Form.Item>
</Col>
</Row>
Expand Down
Loading