@dovetail-v2/refine 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ export interface YamlFormProps {
17
17
  isShowLayout?: boolean;
18
18
  useFormProps?: Parameters<typeof useYamlForm>[0];
19
19
  rules?: YamlFormRule[];
20
- transformInitValues?: (values: Unstructured) => Unstructured;
20
+ transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
21
21
  transformApplyValues?: (values: Unstructured) => Unstructured;
22
22
  onSaveButtonPropsChange?: (saveButtonProps: {
23
23
  disabled?: boolean;
@@ -25,5 +25,6 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
25
25
  * @see {@link https://refine.dev/docs/advanced-tutorials/forms/server-side-form-validation/}
26
26
  */
27
27
  disableServerSideValidation?: boolean;
28
+ transformApplyValues?: (values: TVariables) => TVariables;
28
29
  } & UseHookFormProps<TVariables, TContext>;
29
- export declare const useForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends FieldValues = FieldValues, TContext extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ refineCoreProps, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, disableServerSideValidation: disableServerSideValidationProp, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
30
+ export declare const useForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables extends FieldValues = FieldValues, TContext extends object = object, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ refineCoreProps, warnWhenUnsavedChanges: warnWhenUnsavedChangesProp, disableServerSideValidation: disableServerSideValidationProp, transformApplyValues, ...rest }?: UseFormProps<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>) => UseFormReturnType<TQueryFnData, TError, TVariables, TContext, TData, TResponse, TResponseError>;
@@ -25,7 +25,7 @@ export type UseFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError ex
25
25
  };
26
26
  initialValuesForCreate?: Record<string, unknown>;
27
27
  initialValuesForEdit?: Record<string, unknown>;
28
- transformInitValues?: (values: Unstructured) => Unstructured;
28
+ transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
29
29
  transformApplyValues?: (values: Unstructured) => Unstructured;
30
30
  rules?: YamlFormRule[];
31
31
  };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { PersistentVolumeClaimModel } from 'src/models';
3
+ interface DistributeStorageFormHandler {
4
+ submit: () => Promise<unknown> | undefined;
5
+ }
6
+ interface DistributeStorageFormProps {
7
+ pvc: PersistentVolumeClaimModel;
8
+ defaultValue: number;
9
+ }
10
+ export declare const DistributeStorageForm: React.ForwardRefExoticComponent<DistributeStorageFormProps & React.RefAttributes<DistributeStorageFormHandler>>;
11
+ interface PVCDistributeStorageProps {
12
+ pvc: PersistentVolumeClaimModel;
13
+ editable: boolean;
14
+ }
15
+ declare function PVCDistributeStorage({ pvc, editable }: PVCDistributeStorageProps): JSX.Element;
16
+ export default PVCDistributeStorage;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { IResourceComponentsProps } from '@refinedev/core';
3
- import { ResourceModel } from '../../../models';
4
- import { ResourceConfig } from '../../../types';
3
+ import { ResourceModel } from 'src/models';
4
+ import { ResourceConfig } from 'src/types';
5
5
  type Props<Model extends ResourceModel> = IResourceComponentsProps & {
6
6
  config: ResourceConfig<Model>;
7
7
  };
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { useTable } from '@refinedev/core';
3
+ import { ResourceModel } from 'src/models';
4
+ interface ResourceTableProps<Model extends ResourceModel> {
5
+ resource: string;
6
+ useTableParams?: Parameters<typeof useTable<Model>>[0];
7
+ }
8
+ export declare function ResourceTable<Model extends ResourceModel>(props: ResourceTableProps<Model>): JSX.Element;
9
+ export {};
@@ -1,3 +1,4 @@
1
+ import { useTable } from '@refinedev/core';
1
2
  import { i18n as I18nType } from 'i18next';
2
3
  import { Unstructured } from 'k8s-api-provider';
3
4
  import { NetworkPolicy } from 'kubernetes-types/networking/v1';
@@ -62,7 +63,14 @@ export declare const StorageClassProvisionerField: <Model extends StorageClassMo
62
63
  export declare const StorageClassPvField: <Model extends StorageClassModel>() => ShowField<Model>;
63
64
  export declare const PVCapacityField: <Model extends PersistentVolumeModel>(i18n: I18nType) => ShowField<Model>;
64
65
  export declare const PVCStorageField: <Model extends PersistentVolumeClaimModel>(i18n: I18nType) => ShowField<Model>;
66
+ export declare const PVRefField: <Model extends PersistentVolumeClaimModel>(i18n: I18nType) => ShowField<Model>;
65
67
  export declare const PVStorageClassField: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => ShowField<Model>;
66
68
  export declare const PVPhaseField: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => ShowField<Model>;
67
69
  export declare const PVVolumeModeField: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => ShowField<Model>;
68
70
  export declare const PVAccessModeField: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => ShowField<Model>;
71
+ export declare const PVCRefField: <Model extends PersistentVolumeModel>(i18n: I18nType) => ShowField<Model>;
72
+ export declare const PVCSIRefField: <Model extends PersistentVolumeModel>(i18n: I18nType) => ShowField<Model>;
73
+ export declare const IsDefaultSCField: <Model extends StorageClassModel>(i18n: I18nType) => ShowField<Model>;
74
+ export declare const SCReclaimPolicyField: <Model extends StorageClassModel>(i18n: I18nType) => ShowField<Model>;
75
+ export declare const IsSCAllowVolumeExpansionField: <Model extends StorageClassModel>(i18n: I18nType) => ShowField<Model>;
76
+ export declare const ResourceTableField: <Model extends ResourceModel<Unstructured>>(resource: string, useTableParams?: import("@refinedev/core").useTableProps<Model, import("@refinedev/core").HttpError, Model> | undefined) => ShowField<Model>;
@@ -21,3 +21,4 @@ export declare const DataGroup: <Model extends ResourceModel<Unstructured>>(i18n
21
21
  export declare const NetworkPolicyIngressRulesGroup: <Model extends ResourceModel<Unstructured>>(i18n: I18nType) => ShowGroup<Model>;
22
22
  export declare const NetworkPolicyEgressRulesGroup: <Model extends ResourceModel<Unstructured>>(i18n: I18nType) => ShowGroup<Model>;
23
23
  export declare const StorageClassPvGroup: <Model extends StorageClassModel>(i18n: I18nType) => ShowGroup<Model>;
24
+ export declare const ResourceTableGroup: <Model extends StorageClassModel>(resource: string, title: string) => ShowGroup<Model>;
@@ -47,3 +47,4 @@ export * as ValueDisplay from './ValueDisplay';
47
47
  export * from './ResourceSelect';
48
48
  export * from './Shell';
49
49
  export * from './PodShellModal';
50
+ export * from './ResourceTable';
@@ -477,11 +477,46 @@ export declare const NODE_INIT_VALUE: {
477
477
  spec: {};
478
478
  };
479
479
  export declare const STORAGE_CLASS_INIT_VALUE: {
480
+ apiVersion: string;
481
+ kind: string;
482
+ metadata: {
483
+ name: string;
484
+ };
485
+ parameters: {};
486
+ provisioner: string;
487
+ reclaimPolicy: string;
488
+ allowVolumeExpansion: boolean;
489
+ volumeBindingMode: string;
490
+ };
491
+ export declare const PV_INIT_VALUE: {
492
+ apiVersion: string;
493
+ kind: string;
494
+ metadata: {
495
+ name: string;
496
+ };
497
+ spec: {
498
+ accessModes: string[];
499
+ capacity: {
500
+ storage: string;
501
+ };
502
+ persistentVolumeReclaimPolicy: string;
503
+ volumeMode: string;
504
+ };
505
+ };
506
+ export declare const PVC_INIT_VALUE: {
480
507
  apiVersion: string;
481
508
  kind: string;
482
509
  metadata: {
483
510
  name: string;
484
511
  namespace: string;
485
512
  };
486
- spec: {};
513
+ spec: {
514
+ accessModes: string[];
515
+ resources: {
516
+ requests: {
517
+ storage: string;
518
+ };
519
+ };
520
+ storageClassName: string;
521
+ };
487
522
  };
@@ -36,7 +36,12 @@ export declare const PortMappingColumnRenderer: <Model extends ServiceModel>(i18
36
36
  export declare const ProvisionerColumnRenderer: <Model extends StorageClassModel>(i18n: I18nType) => Column<Model>;
37
37
  export declare const PVCapacityColumnRenderer: <Model extends PersistentVolumeModel>(i18n: I18nType) => Column<Model>;
38
38
  export declare const PVCStorageColumnRenderer: <Model extends PersistentVolumeClaimModel>(i18n: I18nType) => Column<Model>;
39
+ export declare const PVRefColumnRenderer: <Model extends PersistentVolumeClaimModel>(i18n: I18nType) => Column<Model>;
39
40
  export declare const PVStorageClassColumnRenderer: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => Column<Model>;
40
41
  export declare const PVPhaseColumnRenderer: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => Column<Model>;
42
+ export declare const PVCRefColumnRenderer: <Model extends PersistentVolumeModel>(i18n: I18nType) => Column<Model>;
43
+ export declare const PVCSIRefColumnRenderer: <Model extends PersistentVolumeModel>(i18n: I18nType) => Column<Model>;
41
44
  export declare const PVVolumeModeColumnRenderer: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => Column<Model>;
42
45
  export declare const PVAccessModeColumnRenderer: <Model extends PersistentVolumeModel | PersistentVolumeClaimModel>(i18n: I18nType) => Column<Model>;
46
+ export declare const IsDefaultSCColumnRenderer: <Model extends StorageClassModel>(i18n: I18nType) => Column<Model>;
47
+ export declare const SCReclaimPolicyColumnRenderer: <Model extends StorageClassModel>(i18n: I18nType) => Column<Model>;
@@ -5,6 +5,7 @@ import { Column, TableProps } from '../../components/Table';
5
5
  import { ResourceModel } from '../../models';
6
6
  type Params<Model extends ResourceModel> = {
7
7
  useTableParams: Parameters<typeof useTable<Model>>[0];
8
+ resource?: string;
8
9
  columns: Column<Model>[];
9
10
  tableProps?: Partial<TableProps<Model>>;
10
11
  formatter?: (d: Model) => Model;
package/lib/i18n.d.ts CHANGED
@@ -163,7 +163,6 @@ export declare const resources: {
163
163
  provisioner: string;
164
164
  file_system: string;
165
165
  capacity: string;
166
- phase: string;
167
166
  volume_mode: string;
168
167
  access_mode: string;
169
168
  block: string;
@@ -332,6 +331,7 @@ export declare const resources: {
332
331
  out_cluster_lb_desc: string;
333
332
  out_external_name_desc: string;
334
333
  only_support_one_yaml: string;
334
+ support: string;
335
335
  not_support: string;
336
336
  stopped: string;
337
337
  any_node_ip: string;
@@ -340,7 +340,7 @@ export declare const resources: {
340
340
  provisioner: string;
341
341
  file_system: string;
342
342
  capacity: string;
343
- phase: string;
343
+ distributed: string;
344
344
  volume_mode: string;
345
345
  access_mode: string;
346
346
  block: string;
@@ -364,6 +364,16 @@ export declare const resources: {
364
364
  edit_label_success_toast: string;
365
365
  edit_annotation: string;
366
366
  edit_annotation_success_toast: string;
367
+ pvc: string;
368
+ pv: string;
369
+ csi: string;
370
+ retain: string;
371
+ default_sc: string;
372
+ reclaim_policy: string;
373
+ allow_expand: string;
374
+ edit_distribute_storage: string;
375
+ edit_distribute_storage_success_toast: string;
376
+ edit_distribute_storage_failed_toast: string;
367
377
  };
368
378
  };
369
379
  };
@@ -160,7 +160,6 @@ declare const _default: {
160
160
  provisioner: string;
161
161
  file_system: string;
162
162
  capacity: string;
163
- phase: string;
164
163
  volume_mode: string;
165
164
  access_mode: string;
166
165
  block: string;
@@ -153,6 +153,7 @@ declare const _default: {
153
153
  out_cluster_lb_desc: string;
154
154
  out_external_name_desc: string;
155
155
  only_support_one_yaml: string;
156
+ support: string;
156
157
  not_support: string;
157
158
  stopped: string;
158
159
  any_node_ip: string;
@@ -161,7 +162,7 @@ declare const _default: {
161
162
  provisioner: string;
162
163
  file_system: string;
163
164
  capacity: string;
164
- phase: string;
165
+ distributed: string;
165
166
  volume_mode: string;
166
167
  access_mode: string;
167
168
  block: string;
@@ -185,6 +186,16 @@ declare const _default: {
185
186
  edit_label_success_toast: string;
186
187
  edit_annotation: string;
187
188
  edit_annotation_success_toast: string;
189
+ pvc: string;
190
+ pv: string;
191
+ csi: string;
192
+ retain: string;
193
+ default_sc: string;
194
+ reclaim_policy: string;
195
+ allow_expand: string;
196
+ edit_distribute_storage: string;
197
+ edit_distribute_storage_success_toast: string;
198
+ edit_distribute_storage_failed_toast: string;
188
199
  };
189
200
  };
190
201
  export default _default;
@@ -4,6 +4,10 @@ import { ResourceModel } from './resource-model';
4
4
  type RequiredPersistentClaimVolume = Required<PersistentVolumeClaim> & Unstructured;
5
5
  export declare class PersistentVolumeClaimModel extends ResourceModel {
6
6
  _rawYaml: RequiredPersistentClaimVolume;
7
+ spec: Required<PersistentVolumeClaim>['spec'];
7
8
  constructor(_rawYaml: RequiredPersistentClaimVolume, _globalStore: GlobalStore);
9
+ get phase(): string | undefined;
10
+ get pv(): string | undefined;
11
+ updateDistributeStorage(distributeStorage: number): Unstructured;
8
12
  }
9
13
  export {};
@@ -4,6 +4,10 @@ import { ResourceModel } from './resource-model';
4
4
  type RequiredPersistentVolume = Required<PersistentVolume> & Unstructured;
5
5
  export declare class PersistentVolumeModel extends ResourceModel {
6
6
  _rawYaml: RequiredPersistentVolume;
7
+ spec: PersistentVolume['spec'];
7
8
  constructor(_rawYaml: RequiredPersistentVolume, _globalStore: GlobalStore);
9
+ get phase(): string | undefined;
10
+ get csi(): string | undefined;
11
+ get pvc(): string | undefined;
8
12
  }
9
13
  export {};
@@ -1,4 +1,5 @@
1
1
  import { GlobalStore, Unstructured } from 'k8s-api-provider';
2
+ import type { PersistentVolume } from 'kubernetes-types/core/v1';
2
3
  import type { StorageClass } from 'kubernetes-types/storage/v1';
3
4
  import { PersistentVolumeModel } from './persistent-volume';
4
5
  import { ResourceModel } from './resource-model';
@@ -8,5 +9,8 @@ export declare class StorageClassModel extends ResourceModel {
8
9
  pvs: PersistentVolumeModel[];
9
10
  constructor(_rawYaml: RequiredStorageClass, _globalStore: GlobalStore);
10
11
  init(): Promise<void>;
12
+ filterPV(pv: PersistentVolume | PersistentVolumeModel, scName?: string): boolean;
13
+ get isDefaultSC(): string | undefined;
14
+ get reclaimPolicy(): string;
11
15
  }
12
16
  export {};
@@ -12,9 +12,12 @@ export declare const StorageClassConfig: (i18n: I18n) => {
12
12
  kind: string;
13
13
  metadata: {
14
14
  name: string;
15
- namespace: string;
16
15
  };
17
- spec: {};
16
+ parameters: {};
17
+ provisioner: string;
18
+ reclaimPolicy: string;
19
+ allowVolumeExpansion: boolean;
20
+ volumeBindingMode: string;
18
21
  };
19
22
  formConfig: {
20
23
  fields?: ((props: {
@@ -25,8 +28,8 @@ export declare const StorageClassConfig: (i18n: I18n) => {
25
28
  saveButtonText?: string | undefined;
26
29
  renderForm?: ((props: import("../../components").YamlFormProps) => import("react").ReactNode) | undefined;
27
30
  formType?: import("src/types").FormType | undefined;
28
- transformInitValues?: ((values: import("k8s-api-provider").Unstructured) => import("k8s-api-provider").Unstructured) | undefined;
29
- transformApplyValues?: ((values: import("k8s-api-provider").Unstructured) => import("k8s-api-provider").Unstructured) | undefined;
31
+ transformInitValues?: ((values: Record<string, unknown>) => Record<string, unknown>) | undefined;
32
+ transformApplyValues?: ((values: Record<string, unknown>) => import("k8s-api-provider").Unstructured) | undefined;
30
33
  formTitle?: string | ((action: "create" | "edit") => string) | undefined;
31
34
  formDesc?: string | ((action: "create" | "edit") => string) | undefined;
32
35
  formatError?: ((errorBody: unknown) => string) | undefined;
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { UseFormProps } from '@refinedev/react-hook-form';
3
- import { Unstructured } from 'k8s-api-provider';
4
3
  import { YamlFormProps } from '../components';
5
4
  import { RefineFormField } from '../components/Form';
6
5
  import { ShowConfig } from '../components/ShowContent';
@@ -52,8 +51,8 @@ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
52
51
  saveButtonText?: string;
53
52
  renderForm?: (props: YamlFormProps) => React.ReactNode;
54
53
  formType?: FormType;
55
- transformInitValues?: (values: Unstructured) => Unstructured;
56
- transformApplyValues?: (values: Unstructured) => Unstructured;
54
+ transformInitValues?: (values: Record<string, unknown>) => Record<string, unknown>;
55
+ transformApplyValues?: (values: Record<string, unknown>) => Model['_rawYaml'];
57
56
  formTitle?: string | ((action: 'create' | 'edit') => string);
58
57
  formDesc?: string | ((action: 'create' | 'edit') => string);
59
58
  formatError?: (errorBody: unknown) => string;
@@ -0,0 +1,13 @@
1
+ export declare enum StorageUnit {
2
+ Pi = "Pi",
3
+ PiB = "PiB",
4
+ Ti = "Ti",
5
+ TiB = "TiB",
6
+ Gi = "Gi",
7
+ GiB = "GiB",
8
+ Mi = "Mi",
9
+ MiB = "MiB",
10
+ Ki = "Ki",
11
+ KiB = "KiB"
12
+ }
13
+ export declare function transformStorageUnit(value: string, toUnit?: StorageUnit): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dovetail-v2/refine",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "main": "./dist/refine.umd.js",
10
10
  "module": "./dist/refine.js",
11
- "types": "./lib/src/index.d.ts",
11
+ "types": "./lib/index.d.ts",
12
12
  "dependencies": {
13
13
  "@cloudtower/eagle": "^0.31.7",
14
14
  "@cloudtower/icons-react": "^0.31.7",