mirror of
https://github.com/grafana/grafana.git
synced 2024-12-25 08:21:46 -06:00
Schema: Move TeamDTO properties out of the resource (#68155)
This commit is contained in:
parent
1763b82b5d
commit
2c75a51285
@ -64,15 +64,10 @@ extraFields is reserved for any fields that are pulled from the API server metad
|
||||
|
||||
### Spec
|
||||
|
||||
| Property | Type | Required | Default | Description |
|
||||
|-----------------|--------------------|----------|---------|----------------------------------------------------------|
|
||||
| `memberCount` | integer | **Yes** | | MemberCount is the number of the team members. |
|
||||
| `name` | string | **Yes** | | Name of the team. |
|
||||
| `orgId` | integer | **Yes** | | OrgId is the ID of an organisation the team belongs to. |
|
||||
| `permission` | integer | **Yes** | | Possible values are: `0`, `1`, `2`, `4`. |
|
||||
| `accessControl` | map[string]boolean | No | | AccessControl metadata associated with a given resource. |
|
||||
| `avatarUrl` | string | No | | AvatarUrl is the team's avatar URL. |
|
||||
| `email` | string | No | | Email of the team. |
|
||||
| Property | Type | Required | Default | Description |
|
||||
|----------|--------|----------|---------|--------------------|
|
||||
| `name` | string | **Yes** | | Name of the team. |
|
||||
| `email` | string | No | | Email of the team. |
|
||||
|
||||
### Status
|
||||
|
||||
|
@ -10,25 +10,11 @@ lineage: seqs: [
|
||||
// v0.0
|
||||
{
|
||||
spec: {
|
||||
// OrgId is the ID of an organisation the team belongs to.
|
||||
orgId: int64 @grafanamaturity(ToMetadata="sys")
|
||||
// Name of the team.
|
||||
name: string
|
||||
// Email of the team.
|
||||
email?: string
|
||||
// AvatarUrl is the team's avatar URL.
|
||||
avatarUrl?: string @grafanamaturity(MaybeRemove)
|
||||
// MemberCount is the number of the team members.
|
||||
memberCount: int64 @grafanamaturity(ToMetadata="kind")
|
||||
// TODO - it seems it's a team_member.permission, unlikely it should belong to the team kind
|
||||
permission: #Permission @grafanamaturity(ToMetadata="kind", MaybeRemove)
|
||||
// AccessControl metadata associated with a given resource.
|
||||
accessControl?: {
|
||||
[string]: bool @grafanamaturity(ToMetadata="sys")
|
||||
}
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
#Permission: 0 | 1 | 2 | 4 @cuetsy(kind="enum",memberNames="Member|Viewer|Editor|Admin")
|
||||
},
|
||||
]
|
||||
},
|
||||
|
@ -140,6 +140,3 @@ export { defaultServiceAccount } from './raw/serviceaccount/x/serviceaccount_typ
|
||||
|
||||
// Raw generated types from Team kind.
|
||||
export type { Team } from './raw/team/x/team_types.gen';
|
||||
|
||||
// Raw generated enums and default consts from team kind.
|
||||
export { Permission } from './raw/team/x/team_types.gen';
|
||||
|
@ -8,40 +8,13 @@
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
export enum Permission {
|
||||
Admin = 4,
|
||||
Editor = 2,
|
||||
Member = 0,
|
||||
Viewer = 1,
|
||||
}
|
||||
|
||||
export interface Team {
|
||||
/**
|
||||
* AccessControl metadata associated with a given resource.
|
||||
*/
|
||||
accessControl?: Record<string, boolean>;
|
||||
/**
|
||||
* AvatarUrl is the team's avatar URL.
|
||||
*/
|
||||
avatarUrl?: string;
|
||||
/**
|
||||
* Email of the team.
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* MemberCount is the number of the team members.
|
||||
*/
|
||||
memberCount: number;
|
||||
/**
|
||||
* Name of the team.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* OrgId is the ID of an organisation the team belongs to.
|
||||
*/
|
||||
orgId: number;
|
||||
/**
|
||||
* TODO - it seems it's a team_member.permission, unlikely it should belong to the team kind
|
||||
*/
|
||||
permission: Permission;
|
||||
}
|
||||
|
@ -9,35 +9,11 @@
|
||||
|
||||
package team
|
||||
|
||||
// Defines values for Permission.
|
||||
const (
|
||||
PermissionN0 Permission = 0
|
||||
PermissionN1 Permission = 1
|
||||
PermissionN2 Permission = 2
|
||||
PermissionN4 Permission = 4
|
||||
)
|
||||
|
||||
// Permission defines model for Permission.
|
||||
type Permission int
|
||||
|
||||
// Spec defines model for Spec.
|
||||
type Spec struct {
|
||||
// AccessControl metadata associated with a given resource.
|
||||
AccessControl map[string]bool `json:"accessControl,omitempty"`
|
||||
|
||||
// AvatarUrl is the team's avatar URL.
|
||||
AvatarUrl *string `json:"avatarUrl,omitempty"`
|
||||
|
||||
// Email of the team.
|
||||
Email *string `json:"email,omitempty"`
|
||||
|
||||
// MemberCount is the number of the team members.
|
||||
MemberCount int64 `json:"memberCount"`
|
||||
|
||||
// Name of the team.
|
||||
Name string `json:"name"`
|
||||
|
||||
// OrgId is the ID of an organisation the team belongs to.
|
||||
OrgId int64 `json:"orgId"`
|
||||
Permission Permission `json:"permission"`
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { Permission } from '@grafana/schema';
|
||||
|
||||
// Alias to an existing type to reduce the number of changes
|
||||
export { Permission as TeamPermissionLevel };
|
||||
export enum TeamPermissionLevel {
|
||||
Admin = 4,
|
||||
Editor = 2,
|
||||
Member = 0,
|
||||
Viewer = 1,
|
||||
}
|
||||
|
||||
export enum OrgRole {
|
||||
Viewer = 'Viewer',
|
||||
@ -123,15 +125,15 @@ export const dashboardPermissionLevels: DashboardPermissionInfo[] = [
|
||||
];
|
||||
|
||||
export interface TeamPermissionInfo {
|
||||
value: Permission;
|
||||
value: TeamPermissionLevel;
|
||||
label: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const teamsPermissionLevels: TeamPermissionInfo[] = [
|
||||
{ value: Permission.Member, label: 'Member', description: 'Is team member' },
|
||||
{ value: TeamPermissionLevel.Member, label: 'Member', description: 'Is team member' },
|
||||
{
|
||||
value: Permission.Admin,
|
||||
value: TeamPermissionLevel.Admin,
|
||||
label: 'Admin',
|
||||
description: 'Can add/remove permissions, members and delete team.',
|
||||
},
|
||||
|
@ -1,11 +1,43 @@
|
||||
import { Team as TeamBase } from '@grafana/schema';
|
||||
import { Team as TeamDTO } from '@grafana/schema/src/raw/team/x/team_types.gen';
|
||||
|
||||
export interface Team extends TeamBase {
|
||||
import { TeamPermissionLevel } from './acl';
|
||||
|
||||
// The team resource
|
||||
export { TeamDTO };
|
||||
|
||||
// This is the team resource with permissions and metadata expanded
|
||||
export interface Team {
|
||||
id: number; // TODO switch to UUID
|
||||
}
|
||||
|
||||
// Represents the data sent via an API to create a team
|
||||
export interface TeamDTO extends Pick<TeamBase, 'name' | 'email'> {}
|
||||
/**
|
||||
* AccessControl metadata associated with a given resource.
|
||||
*/
|
||||
accessControl?: Record<string, boolean>;
|
||||
/**
|
||||
* AvatarUrl is the team's avatar URL.
|
||||
*/
|
||||
avatarUrl?: string;
|
||||
/**
|
||||
* Email of the team.
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* MemberCount is the number of the team members.
|
||||
*/
|
||||
memberCount: number;
|
||||
/**
|
||||
* Name of the team.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* OrgId is the ID of an organisation the team belongs to.
|
||||
*/
|
||||
orgId: number;
|
||||
/**
|
||||
* TODO - it seems it's a team_member.permission, unlikely it should belong to the team kind
|
||||
*/
|
||||
permission: TeamPermissionLevel;
|
||||
}
|
||||
|
||||
export interface TeamMember {
|
||||
userId: number;
|
||||
|
Loading…
Reference in New Issue
Block a user