2022-01-05 16:28:56 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
|
2022-09-02 15:30:34 +00:00
|
|
|
import { Team } from '@/react/portainer/users/teams/types';
|
2022-03-16 06:35:32 +00:00
|
|
|
import { Role, User, UserId } from '@/portainer/users/types';
|
2022-10-23 06:53:25 +00:00
|
|
|
import { Environment } from '@/react/portainer/environments/types';
|
2022-03-16 06:35:32 +00:00
|
|
|
|
|
|
|
export function createMockUsers(
|
|
|
|
count: number,
|
|
|
|
roles: Role | Role[] | ((id: UserId) => Role) = () => _.random(1, 3)
|
|
|
|
): User[] {
|
2022-01-05 16:28:56 +00:00
|
|
|
return _.range(1, count + 1).map((value) => ({
|
|
|
|
Id: value,
|
|
|
|
Username: `user${value}`,
|
2022-03-16 06:35:32 +00:00
|
|
|
Role: getRoles(roles, value),
|
2022-01-05 16:28:56 +00:00
|
|
|
RoleName: '',
|
|
|
|
AuthenticationMethod: '',
|
|
|
|
Checked: false,
|
|
|
|
EndpointAuthorizations: {},
|
|
|
|
PortainerAuthorizations: {},
|
2023-02-19 04:17:50 +00:00
|
|
|
ThemeSettings: {
|
|
|
|
color: 'auto',
|
|
|
|
},
|
2022-01-05 16:28:56 +00:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2022-03-16 06:35:32 +00:00
|
|
|
function getRoles(
|
|
|
|
roles: Role | Role[] | ((id: UserId) => Role),
|
|
|
|
id: UserId
|
|
|
|
): Role {
|
|
|
|
if (typeof roles === 'function') {
|
|
|
|
return roles(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof roles === 'number') {
|
|
|
|
return roles;
|
|
|
|
}
|
|
|
|
|
|
|
|
return roles[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createMockTeams(count: number): Team[] {
|
2022-01-05 16:28:56 +00:00
|
|
|
return _.range(1, count + 1).map((value) => ({
|
|
|
|
Id: value,
|
|
|
|
Name: `team${value}`,
|
|
|
|
}));
|
|
|
|
}
|
2022-02-24 23:22:56 +00:00
|
|
|
|
|
|
|
export function createMockSubscriptions(count: number) {
|
|
|
|
const subscriptions = _.range(1, count + 1).map((x) => ({
|
|
|
|
id: `/subscriptions/subscription-${x}`,
|
|
|
|
subscriptionId: `subscription-${x}`,
|
|
|
|
}));
|
|
|
|
|
|
|
|
return { value: subscriptions };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function createMockResourceGroups(subscription: string, count: number) {
|
|
|
|
const resourceGroups = _.range(1, count + 1).map((x) => ({
|
|
|
|
id: `/subscriptions/${subscription}/resourceGroups/resourceGroup-${x}`,
|
|
|
|
name: `resourcegroup-${x}`,
|
|
|
|
}));
|
|
|
|
|
|
|
|
return { value: resourceGroups };
|
|
|
|
}
|
2022-06-22 17:11:46 +00:00
|
|
|
|
|
|
|
export function createMockEnvironment(): Environment {
|
|
|
|
return {
|
|
|
|
TagIds: [],
|
|
|
|
GroupId: 1,
|
|
|
|
Type: 1,
|
|
|
|
Name: 'environment',
|
|
|
|
Status: 1,
|
|
|
|
URL: 'url',
|
|
|
|
Snapshots: [],
|
2022-09-21 04:49:42 +00:00
|
|
|
Kubernetes: {
|
|
|
|
Snapshots: [],
|
|
|
|
Configuration: {
|
|
|
|
IngressClasses: [],
|
|
|
|
IngressAvailabilityPerNamespace: false,
|
2022-10-24 20:41:30 +00:00
|
|
|
AllowNoneIngressClass: false,
|
2022-09-21 04:49:42 +00:00
|
|
|
},
|
|
|
|
},
|
2022-12-07 14:51:20 +00:00
|
|
|
Nomad: { Snapshots: [] },
|
2022-06-22 17:11:46 +00:00
|
|
|
EdgeKey: '',
|
2023-03-03 01:47:10 +00:00
|
|
|
EnableGPUManagement: false,
|
2022-06-22 17:11:46 +00:00
|
|
|
Id: 3,
|
|
|
|
UserTrusted: false,
|
|
|
|
Edge: {
|
|
|
|
AsyncMode: false,
|
|
|
|
PingInterval: 0,
|
|
|
|
CommandInterval: 0,
|
|
|
|
SnapshotInterval: 0,
|
|
|
|
},
|
2022-06-23 07:25:56 +00:00
|
|
|
SecuritySettings: {
|
|
|
|
allowBindMountsForRegularUsers: false,
|
|
|
|
allowPrivilegedModeForRegularUsers: false,
|
|
|
|
allowContainerCapabilitiesForRegularUsers: false,
|
|
|
|
allowDeviceMappingForRegularUsers: false,
|
|
|
|
allowHostNamespaceForRegularUsers: false,
|
|
|
|
allowStackManagementForRegularUsers: false,
|
|
|
|
allowSysctlSettingForRegularUsers: false,
|
|
|
|
allowVolumeBrowserForRegularUsers: false,
|
|
|
|
enableHostManagementFeatures: false,
|
|
|
|
},
|
2023-02-22 20:13:33 +00:00
|
|
|
DeploymentOptions: {
|
|
|
|
overrideGlobalOptions: false,
|
|
|
|
hideAddWithForm: true,
|
|
|
|
hideWebEditor: false,
|
|
|
|
hideFileUpload: false,
|
|
|
|
},
|
2022-07-17 23:02:14 +00:00
|
|
|
Gpus: [],
|
2022-09-21 04:49:42 +00:00
|
|
|
Agent: { Version: '1.0.0' },
|
2023-02-22 20:13:33 +00:00
|
|
|
EnableImageNotification: false,
|
|
|
|
ChangeWindow: {
|
|
|
|
Enabled: false,
|
|
|
|
EndTime: '',
|
|
|
|
StartTime: '',
|
|
|
|
},
|
2022-06-22 17:11:46 +00:00
|
|
|
};
|
|
|
|
}
|