Skip to content

Commit 1eaf9c5

Browse files
authored
feat: add types and utils (#12)
1 parent 8d62a10 commit 1eaf9c5

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

components/design/TypedObjectIcon.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { SVGIconProps } from '@patternfly/react-icons/dist/esm/createIcon';
33
import { ProjectObjectType, typedColor } from '~/components/design/utils';
4-
import { RegisteredModelIcon } from '~/images/icons';
4+
import { GroupIcon, RegisteredModelIcon, UserIcon } from '~/images/icons';
55

66
type TypedObjectIconProps = SVGIconProps & {
77
resourceType: ProjectObjectType;
@@ -21,6 +21,12 @@ const TypedObjectIcon: React.FC<TypedObjectIconProps> = ({
2121
case ProjectObjectType.modelRegistrySettings:
2222
Icon = RegisteredModelIcon;
2323
break;
24+
case ProjectObjectType.user:
25+
Icon = UserIcon;
26+
break;
27+
case ProjectObjectType.group:
28+
Icon = GroupIcon;
29+
break;
2430
default:
2531
return null;
2632
}

types/common.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ export declare type K8sResourceIdentifier = {
6363
kind: string;
6464
};
6565

66+
export declare type K8sStatus = K8sResourceIdentifier & {
67+
code: number;
68+
message: string;
69+
reason: string;
70+
status: 'Success' | 'Failure';
71+
};
72+
6673
export declare type K8sResourceCommon = K8sResourceIdentifier &
6774
Partial<{
6875
metadata: Partial<{

types/k8sTypes.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,31 @@ export type ServiceKind = K8sResourceCommon & {
265265
}[];
266266
};
267267
};
268+
269+
export type RoleBindingSubject = {
270+
kind: string;
271+
apiGroup?: string;
272+
name: string;
273+
};
274+
275+
export type RoleBindingRoleRef = {
276+
kind: 'Role' | 'ClusterRole';
277+
apiGroup?: string;
278+
name: string;
279+
};
280+
281+
export type RoleBindingKind = K8sResourceCommon & {
282+
metadata: {
283+
name: string;
284+
namespace: string;
285+
};
286+
subjects: RoleBindingSubject[];
287+
roleRef: RoleBindingRoleRef;
288+
};
289+
290+
export type GroupKind = K8sResourceCommon & {
291+
metadata: {
292+
name: string;
293+
};
294+
users: string[];
295+
};

utilities/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export * from './appUtils';
33
export * from './const';
44
export * from './markdown';
55
export * from './time';
6+
export * from './string';
67
export * from './useDebounceCallback';
78
export * from './useDeepCompareMemoize';
89
export * from './useEventListener';

utilities/string.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const genRandomChars = (len = 6): string =>
2+
Math.random()
3+
.toString(36)
4+
.replace(/[^a-z0-9]+/g, '')
5+
.substr(1, len);

0 commit comments

Comments
 (0)