2021-04-14 16:52:15 +00:00
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import teamInterface, { ITeam } from "./team";
|
2016-10-21 23:13:41 +00:00
|
|
|
|
|
|
|
export default PropTypes.shape({
|
2021-08-16 14:30:19 +00:00
|
|
|
created_at: PropTypes.string,
|
|
|
|
updated_at: PropTypes.string,
|
|
|
|
id: PropTypes.number,
|
|
|
|
name: PropTypes.string,
|
2016-10-21 23:13:41 +00:00
|
|
|
email: PropTypes.string,
|
2021-10-26 14:24:16 +00:00
|
|
|
role: PropTypes.string,
|
2016-10-21 23:13:41 +00:00
|
|
|
force_password_reset: PropTypes.bool,
|
2021-04-29 13:47:33 +00:00
|
|
|
gravatar_url: PropTypes.string,
|
|
|
|
sso_enabled: PropTypes.bool,
|
2021-08-16 14:30:19 +00:00
|
|
|
global_role: PropTypes.string,
|
|
|
|
api_only: PropTypes.bool,
|
2021-04-09 10:44:57 +00:00
|
|
|
teams: PropTypes.arrayOf(teamInterface),
|
2016-10-21 23:13:41 +00:00
|
|
|
});
|
2021-03-24 13:18:56 +00:00
|
|
|
|
2023-04-07 23:17:09 +00:00
|
|
|
export const USERS_ROLES = [
|
|
|
|
"admin",
|
|
|
|
"maintainer",
|
|
|
|
"observer",
|
|
|
|
"observer_plus",
|
|
|
|
] as const;
|
2023-03-31 17:40:14 +00:00
|
|
|
export type IUserRole = typeof USERS_ROLES[number];
|
2023-04-07 15:36:47 +00:00
|
|
|
export type UserRole =
|
|
|
|
| "admin"
|
|
|
|
| "maintainer"
|
|
|
|
| "observer"
|
|
|
|
| "observer_plus"
|
|
|
|
| "gitops"
|
|
|
|
| "Admin"
|
|
|
|
| "Maintainer"
|
|
|
|
| "Observer"
|
|
|
|
| "Observer+"
|
|
|
|
| "GitOps"
|
|
|
|
| "Unassigned"
|
|
|
|
| ""
|
|
|
|
| "Various";
|
2023-03-31 17:40:14 +00:00
|
|
|
|
2021-03-24 13:18:56 +00:00
|
|
|
export interface IUser {
|
2021-08-16 14:30:19 +00:00
|
|
|
created_at?: string;
|
|
|
|
updated_at?: string;
|
|
|
|
id: number;
|
|
|
|
name: string;
|
2021-04-14 16:52:15 +00:00
|
|
|
email: string;
|
2023-04-07 15:36:47 +00:00
|
|
|
role: UserRole;
|
2021-04-14 16:52:15 +00:00
|
|
|
force_password_reset: boolean;
|
2023-02-01 19:06:06 +00:00
|
|
|
gravatar_url?: string;
|
|
|
|
gravatar_url_dark?: string;
|
2021-04-29 13:47:33 +00:00
|
|
|
sso_enabled: boolean;
|
2023-04-07 15:36:47 +00:00
|
|
|
global_role: UserRole | null;
|
2021-08-16 14:30:19 +00:00
|
|
|
api_only: boolean;
|
2021-04-09 10:44:57 +00:00
|
|
|
teams: ITeam[];
|
2021-04-29 13:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The shape of the request body when updating a user.
|
|
|
|
*/
|
|
|
|
export interface IUserUpdateBody {
|
2023-04-07 15:36:47 +00:00
|
|
|
global_role?: UserRole | null;
|
2021-04-29 13:47:33 +00:00
|
|
|
teams?: ITeam[];
|
2023-04-07 15:36:47 +00:00
|
|
|
name: string;
|
2021-04-29 13:47:33 +00:00
|
|
|
email?: string;
|
|
|
|
sso_enabled?: boolean;
|
2023-04-07 15:36:47 +00:00
|
|
|
role?: UserRole;
|
|
|
|
id: number;
|
2021-03-24 13:18:56 +00:00
|
|
|
}
|
2021-10-26 14:24:16 +00:00
|
|
|
|
|
|
|
export interface IUserFormErrors {
|
2022-03-01 18:28:51 +00:00
|
|
|
email?: string | null;
|
|
|
|
name?: string | null;
|
|
|
|
password?: string | null;
|
|
|
|
sso_enabled?: boolean | null;
|
2021-10-26 14:24:16 +00:00
|
|
|
}
|
2023-08-02 15:29:49 +00:00
|
|
|
export interface IResetPasswordFormErrors {
|
|
|
|
new_password?: string | null;
|
|
|
|
new_password_confirmation?: string | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IResetPasswordForm {
|
|
|
|
new_password: string;
|
|
|
|
new_password_confirmation: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ILoginUserData {
|
|
|
|
email: string;
|
|
|
|
password: string;
|
|
|
|
}
|
2022-01-13 23:11:45 +00:00
|
|
|
|
|
|
|
export interface ICreateUserFormData {
|
|
|
|
email: string;
|
2023-04-07 15:36:47 +00:00
|
|
|
global_role: UserRole | null;
|
2022-01-13 23:11:45 +00:00
|
|
|
name: string;
|
|
|
|
password?: string | null;
|
|
|
|
sso_enabled?: boolean | undefined;
|
|
|
|
teams: ITeam[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IUpdateUserFormData {
|
|
|
|
currentUserId?: number;
|
|
|
|
email?: string;
|
2023-04-07 15:36:47 +00:00
|
|
|
global_role?: UserRole | null;
|
2022-01-13 23:11:45 +00:00
|
|
|
name?: string;
|
|
|
|
password?: string | null;
|
|
|
|
sso_enabled?: boolean;
|
|
|
|
teams?: ITeam[];
|
|
|
|
}
|
2022-04-01 06:42:26 +00:00
|
|
|
|
|
|
|
export interface ICreateUserWithInvitationFormData {
|
|
|
|
email: string;
|
|
|
|
invite_token: string;
|
|
|
|
name: string;
|
|
|
|
password: string;
|
|
|
|
password_confirmation: string;
|
|
|
|
}
|