@dovetail-v2/refine 0.0.52 → 0.0.53
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.
- package/dist/{MonacoYamlDiffEditor-1745c907.js → MonacoYamlDiffEditor-c2895adf.js} +1 -1
- package/dist/{index-7fe9ade3.js → index-247253d2.js} +313 -308
- package/dist/refine.js +1 -1
- package/dist/refine.umd.cjs +312 -307
- package/lib/src/components/Form/YamlForm.d.ts +3 -0
- package/lib/src/components/ModalContextProvider/index.d.ts +12 -0
- package/lib/src/components/NetworkPolicyRulesTable/NetworkPolicyRulesTable.d.ts +2 -1
- package/lib/src/components/YamlForm/index.d.ts +4 -0
- package/lib/src/hooks/useEagleForm.d.ts +2 -1
- package/lib/src/hooks/useModal.d.ts +0 -0
- package/lib/src/hooks/useNamespaceFilter.d.ts +5 -0
- package/lib/src/model/cronjob-model.d.ts +9 -0
- package/lib/src/model/index.d.ts +6 -0
- package/lib/src/model/job-model.d.ts +10 -0
- package/lib/src/model/pod-metrics-model.d.ts +7 -0
- package/lib/src/model/pod-model.d.ts +15 -0
- package/lib/src/model/resource-model.d.ts +17 -0
- package/lib/src/model/workload-model.d.ts +17 -0
- package/lib/src/types/metric.d.ts +25 -0
- package/package.json +1 -1
- package/lib/src/App.js +0 -91
- package/lib/src/Dovetail.js +0 -45
- package/lib/src/components/Breadcrumb/index.js +0 -20
- package/lib/src/components/ConditionsTable/ConditionsTable.js +0 -56
- package/lib/src/components/ConditionsTable/index.js +0 -1
- package/lib/src/components/CreateButton/index.js +0 -10
- package/lib/src/components/CronJobDropdown/index.js +0 -26
- package/lib/src/components/CronjobJobsTable/index.js +0 -49
- package/lib/src/components/DeleteButton/index.js +0 -13
- package/lib/src/components/DeleteManyButton/index.js +0 -16
- package/lib/src/components/DrawerShow/DrawerShow.js +0 -13
- package/lib/src/components/DrawerShow/index.js +0 -1
- package/lib/src/components/EditButton/index.js +0 -13
- package/lib/src/components/EditField/index.js +0 -47
- package/lib/src/components/ErrorContent/index.js +0 -36
- package/lib/src/components/EventsTable/EventsTable.js +0 -59
- package/lib/src/components/EventsTable/index.js +0 -1
- package/lib/src/components/Form/KeyValueListWidget.js +0 -56
- package/lib/src/components/Form/MetadataForm.js +0 -9
- package/lib/src/components/Form/NameInputWidget.js +0 -50
- package/lib/src/components/Form/NamespaceSelectWidget.js +0 -21
- package/lib/src/components/Form/index.js +0 -4
- package/lib/src/components/Form/widget.js +0 -1
- package/lib/src/components/FormErrorAlert/index.js +0 -8
- package/lib/src/components/FormLayout/index.js +0 -21
- package/lib/src/components/FormModal/index.js +0 -51
- package/lib/src/components/ImageNames/index.js +0 -14
- package/lib/src/components/IngressRulesComponent/index.js +0 -11
- package/lib/src/components/IngressRulesTable/IngressRulesTable.js +0 -51
- package/lib/src/components/IngressRulesTable/index.js +0 -1
- package/lib/src/components/K8sDropdown/index.js +0 -31
- package/lib/src/components/KeyValue/KeyValue.js +0 -27
- package/lib/src/components/KeyValue/index.js +0 -1
- package/lib/src/components/KeyValueData/index.js +0 -50
- package/lib/src/components/Layout/index.js +0 -39
- package/lib/src/components/ListPage/index.js +0 -25
- package/lib/src/components/Menu/index.js +0 -36
- package/lib/src/components/NamespacesFilter/index.js +0 -34
- package/lib/src/components/NetworkPolicyRulesTable/NetworkPolicyRulesTable.js +0 -77
- package/lib/src/components/NetworkPolicyRulesTable/index.js +0 -1
- package/lib/src/components/PageShow/PageShow.js +0 -11
- package/lib/src/components/PageShow/index.js +0 -1
- package/lib/src/components/PodContainersTable/PodContainersTable.js +0 -78
- package/lib/src/components/PodContainersTable/index.js +0 -1
- package/lib/src/components/PodLog/index.js +0 -136
- package/lib/src/components/ReferenceLink/index.js +0 -17
- package/lib/src/components/RefineForm/RefineFormContent.d.ts +0 -10
- package/lib/src/components/RefineForm/RefineFormModal.d.ts +0 -8
- package/lib/src/components/RefineForm/RefineFormPage.d.ts +0 -7
- package/lib/src/components/RefineForm/index.d.ts +0 -3
- package/lib/src/components/RefineForm/type.d.ts +0 -20
- package/lib/src/components/RefineForm/useRefineForm.d.ts +0 -10
- package/lib/src/components/ResourceCRUD/ResourceCRUD.js +0 -15
- package/lib/src/components/ResourceCRUD/create/index.js +0 -13
- package/lib/src/components/ResourceCRUD/index.js +0 -4
- package/lib/src/components/ResourceCRUD/list/index.js +0 -19
- package/lib/src/components/ResourceCRUD/show/index.js +0 -6
- package/lib/src/components/ResourceLink/index.js +0 -21
- package/lib/src/components/ResourceUsageBar/index.js +0 -81
- package/lib/src/components/Separator/index.js +0 -11
- package/lib/src/components/ShowContent/ShowContent.js +0 -157
- package/lib/src/components/ShowContent/fields.js +0 -157
- package/lib/src/components/ShowContent/index.js +0 -2
- package/lib/src/components/StateTag/StateTag.js +0 -22
- package/lib/src/components/StateTag/index.js +0 -1
- package/lib/src/components/Table/ErrorContent.js +0 -36
- package/lib/src/components/Table/TableToolBar.js +0 -14
- package/lib/src/components/Table/TableWidgets.js +0 -28
- package/lib/src/components/Table/index.js +0 -69
- package/lib/src/components/Tags/index.js +0 -22
- package/lib/src/components/Time/index.js +0 -14
- package/lib/src/components/WorkloadDropdown/index.js +0 -24
- package/lib/src/components/WorkloadPodsTable/WorkloadPodsTable.js +0 -39
- package/lib/src/components/WorkloadPodsTable/index.js +0 -1
- package/lib/src/components/WorkloadReplicas/index.js +0 -50
- package/lib/src/components/YamlEditor/MonacoYamlDiffEditor.js +0 -34
- package/lib/src/components/YamlEditor/MonacoYamlEditor.js +0 -149
- package/lib/src/components/YamlEditor/YamlEditorComponent.js +0 -90
- package/lib/src/components/YamlEditor/index.js +0 -1
- package/lib/src/components/YamlEditor/style.js +0 -102
- package/lib/src/components/YamlEditor/yaml.worker.js +0 -1
- package/lib/src/components/YamlForm/index.js +0 -61
- package/lib/src/components/index.js +0 -38
- package/lib/src/constants/index.js +0 -2
- package/lib/src/constants/k8s.js +0 -203
- package/lib/src/constants/state.js +0 -15
- package/lib/src/contexts/component.js +0 -3
- package/lib/src/contexts/configs.js +0 -3
- package/lib/src/contexts/global-store.js +0 -3
- package/lib/src/contexts/index.js +0 -3
- package/lib/src/hooks/index.js +0 -7
- package/lib/src/hooks/useDeleteModal/index.js +0 -1
- package/lib/src/hooks/useDeleteModal/useDeleteManyModal.js +0 -31
- package/lib/src/hooks/useDeleteModal/useDeleteModal.js +0 -38
- package/lib/src/hooks/useDownloadYAML.js +0 -10
- package/lib/src/hooks/useEagleForm.js +0 -177
- package/lib/src/hooks/useEagleTable/columns.js +0 -246
- package/lib/src/hooks/useEagleTable/index.js +0 -2
- package/lib/src/hooks/useEagleTable/useEagleTable.js +0 -63
- package/lib/src/hooks/useEdit.js +0 -19
- package/lib/src/hooks/useGlobalStore.js +0 -5
- package/lib/src/hooks/useK8sYamlEditor.js +0 -37
- package/lib/src/hooks/useOpenForm.js +0 -43
- package/lib/src/hooks/useSchema.js +0 -37
- package/lib/src/hooks/useSubmitForm.js +0 -42
- package/lib/src/i18n.js +0 -19
- package/lib/src/index.js +0 -13
- package/lib/src/locales/en-US/dovetail.json +0 -18
- package/lib/src/locales/en-US/index.js +0 -4
- package/lib/src/locales/index.js +0 -6
- package/lib/src/locales/zh-CN/dovetail.json +0 -91
- package/lib/src/locales/zh-CN/index.js +0 -4
- package/lib/src/main.js +0 -12
- package/lib/src/models/cronjob-model.js +0 -32
- package/lib/src/models/daemonset-model.js +0 -17
- package/lib/src/models/deployment-model.js +0 -17
- package/lib/src/models/event-model.js +0 -11
- package/lib/src/models/index.js +0 -14
- package/lib/src/models/ingress-model.js +0 -24
- package/lib/src/models/job-model.js +0 -56
- package/lib/src/models/network-policy-model.js +0 -10
- package/lib/src/models/pod-metrics-model.js +0 -34
- package/lib/src/models/pod-model.js +0 -78
- package/lib/src/models/resource-model.js +0 -34
- package/lib/src/models/server-instance-model.d.ts +0 -10
- package/lib/src/models/service-model.js +0 -17
- package/lib/src/models/statefulset-model.js +0 -17
- package/lib/src/models/types/index.js +0 -1
- package/lib/src/models/types/metric.js +0 -1
- package/lib/src/models/workload-base-model.js +0 -22
- package/lib/src/models/workload-model.js +0 -51
- package/lib/src/pages/configmaps/index.js +0 -15
- package/lib/src/pages/cronjobs/create/index.js +0 -6
- package/lib/src/pages/cronjobs/index.js +0 -3
- package/lib/src/pages/cronjobs/list/index.js +0 -42
- package/lib/src/pages/cronjobs/show/index.js +0 -16
- package/lib/src/pages/daemonsets/create/index.js +0 -6
- package/lib/src/pages/daemonsets/index.js +0 -3
- package/lib/src/pages/daemonsets/list/index.js +0 -32
- package/lib/src/pages/daemonsets/show/index.js +0 -16
- package/lib/src/pages/deployments/create/index.js +0 -7
- package/lib/src/pages/deployments/index.js +0 -3
- package/lib/src/pages/deployments/list/index.js +0 -26
- package/lib/src/pages/deployments/show/index.js +0 -16
- package/lib/src/pages/ingresses/index.js +0 -26
- package/lib/src/pages/jobs/index.js +0 -34
- package/lib/src/pages/networkPolicies/index.js +0 -67
- package/lib/src/pages/pods/create/index.js +0 -6
- package/lib/src/pages/pods/index.js +0 -3
- package/lib/src/pages/pods/list/index.js +0 -81
- package/lib/src/pages/pods/show/index.js +0 -54
- package/lib/src/pages/secrets/index.js +0 -15
- package/lib/src/pages/services/index.js +0 -26
- package/lib/src/pages/statefulsets/create/index.js +0 -6
- package/lib/src/pages/statefulsets/index.js +0 -3
- package/lib/src/pages/statefulsets/list/index.js +0 -26
- package/lib/src/pages/statefulsets/show/index.js +0 -16
- package/lib/src/plugins/index.js +0 -3
- package/lib/src/plugins/model-plugin.js +0 -46
- package/lib/src/plugins/relation-plugin.js +0 -81
- package/lib/src/plugins/type.js +0 -1
- package/lib/src/providers/index.js +0 -1
- package/lib/src/providers/router-provider/index.js +0 -100
- package/lib/src/types/index.js +0 -1
- package/lib/src/types/resource.js +0 -12
- package/lib/src/utils/addId.js +0 -8
- package/lib/src/utils/download.js +0 -9
- package/lib/src/utils/error.js +0 -53
- package/lib/src/utils/form.js +0 -9
- package/lib/src/utils/k8s.js +0 -6
- package/lib/src/utils/labels.js +0 -15
- package/lib/src/utils/match-selector.js +0 -12
- package/lib/src/utils/openapi.js +0 -33
- package/lib/src/utils/schema.js +0 -117
- package/lib/src/utils/selector.js +0 -12
- package/lib/src/utils/string.js +0 -6
- package/lib/src/utils/time.js +0 -46
- package/lib/src/utils/unit.js +0 -69
- package/lib/src/utils/yaml.js +0 -44
- package/lib/vite.config.js +0 -60
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function download(filename, content) {
|
|
2
|
-
const element = document.createElement('a');
|
|
3
|
-
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(content));
|
|
4
|
-
element.setAttribute('download', filename);
|
|
5
|
-
element.style.display = 'none';
|
|
6
|
-
document.body.appendChild(element);
|
|
7
|
-
element.click();
|
|
8
|
-
document.body.removeChild(element);
|
|
9
|
-
}
|
package/lib/src/utils/error.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export function isNetworkError(errors) {
|
|
2
|
-
if (errors?.some(error => error?.code || error?.reason)) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
else {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export function getSubmitError(errorResponse, text, i18n) {
|
|
10
|
-
return !errorResponse ? i18n.t('dovetail.network_error') : text;
|
|
11
|
-
}
|
|
12
|
-
export function getCommonErrors(responseBody, i18n) {
|
|
13
|
-
if (!(responseBody?.message ||
|
|
14
|
-
responseBody?.code ||
|
|
15
|
-
responseBody?.reason ||
|
|
16
|
-
responseBody?.details ||
|
|
17
|
-
responseBody?.graphQLErrors)) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
const causes = responseBody.details?.causes || responseBody.graphQLErrors || [];
|
|
21
|
-
if (causes.length) {
|
|
22
|
-
return causes.map(cause => {
|
|
23
|
-
let params = {};
|
|
24
|
-
let message = cause.message;
|
|
25
|
-
try {
|
|
26
|
-
const info = JSON.parse(cause.message);
|
|
27
|
-
params = info.params;
|
|
28
|
-
message = info.message;
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return i18n.t([
|
|
32
|
-
`error.${cause.reason}`,
|
|
33
|
-
`error.${cause.code}`,
|
|
34
|
-
`${message}${cause.field ? `(${cause.field})` : ''}`,
|
|
35
|
-
], {
|
|
36
|
-
...params,
|
|
37
|
-
fallbackLng: '',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return i18n.t([
|
|
41
|
-
`error.${cause.reason}`,
|
|
42
|
-
`error.${cause.code}`,
|
|
43
|
-
`${message}${cause.field ? `(${cause.field})` : ''}`,
|
|
44
|
-
], {
|
|
45
|
-
...params,
|
|
46
|
-
fallbackLng: '',
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return [
|
|
51
|
-
i18n.t([`error.${responseBody.code}`, `error.${responseBody.reason}`, responseBody.message || ''], { fallbackLng: '' }),
|
|
52
|
-
];
|
|
53
|
-
}
|
package/lib/src/utils/form.js
DELETED
package/lib/src/utils/k8s.js
DELETED
package/lib/src/utils/labels.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function toLabelStrings(labels = {}) {
|
|
2
|
-
return Object.keys(labels).map(key => `${key}/${labels[key]}`);
|
|
3
|
-
}
|
|
4
|
-
export function toLabelsArray(labels = {}) {
|
|
5
|
-
return Object.keys(labels).map(key => ({
|
|
6
|
-
key,
|
|
7
|
-
value: labels[key],
|
|
8
|
-
}));
|
|
9
|
-
}
|
|
10
|
-
export function toLabelsRecord(labels) {
|
|
11
|
-
return labels.reduce((prev, cur) => {
|
|
12
|
-
prev[cur.key] = cur.value;
|
|
13
|
-
return prev;
|
|
14
|
-
}, {});
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function matchSelector(pod, selector) {
|
|
2
|
-
let match = true;
|
|
3
|
-
// TODO: support complete selector match strategy
|
|
4
|
-
// https://github.com/rancher/dashboard/blob/master/shell/utils/selector.js#L166
|
|
5
|
-
for (const key in selector.matchLabels) {
|
|
6
|
-
if (!pod.metadata?.labels?.[key] ||
|
|
7
|
-
pod.metadata.labels?.[key] !== selector.matchLabels[key]) {
|
|
8
|
-
match = false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return match;
|
|
12
|
-
}
|
package/lib/src/utils/openapi.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getApiVersion } from 'src/utils/k8s';
|
|
2
|
-
import { resolveRef } from 'src/utils/schema';
|
|
3
|
-
class K8sOpenAPI {
|
|
4
|
-
resourceBasePath;
|
|
5
|
-
response = null;
|
|
6
|
-
apiVersion;
|
|
7
|
-
constructor(resourceBasePath) {
|
|
8
|
-
this.resourceBasePath = resourceBasePath;
|
|
9
|
-
this.apiVersion = getApiVersion(resourceBasePath);
|
|
10
|
-
}
|
|
11
|
-
async fetch() {
|
|
12
|
-
const response = await fetch(`/api/sks/api/v1/clusters/sks-mgmt/proxy/openapi/v3${this.resourceBasePath}`);
|
|
13
|
-
return response.json();
|
|
14
|
-
}
|
|
15
|
-
async findSchema(kind) {
|
|
16
|
-
const result = this.response || (await this.fetch());
|
|
17
|
-
const schema = Object.values(result.components.schemas).find(schema => schema['x-kubernetes-group-version-kind']?.some(({ kind: schemaKind, version: schemaVersion, group: schemaGroup }) => kind === schemaKind &&
|
|
18
|
-
this.apiVersion === `${schemaGroup ? schemaGroup + '/' : ''}${schemaVersion}`));
|
|
19
|
-
if (schema) {
|
|
20
|
-
resolveRef(schema, result.components.schemas, {
|
|
21
|
-
prune: {
|
|
22
|
-
description: true,
|
|
23
|
-
optional: false,
|
|
24
|
-
fields: [],
|
|
25
|
-
metadata: true,
|
|
26
|
-
xProperty: true,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return schema;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export default K8sOpenAPI;
|
package/lib/src/utils/schema.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { pick } from 'lodash';
|
|
2
|
-
export function generateValueFromSchema(schema, options) {
|
|
3
|
-
const { generateValue } = options;
|
|
4
|
-
if (!schema) {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
7
|
-
switch (true) {
|
|
8
|
-
case schema.type === 'string' && 'enum' in schema && Boolean(schema.enum?.length):
|
|
9
|
-
return generateValue?.(schema) || schema.enum?.[0];
|
|
10
|
-
case schema.type === 'string':
|
|
11
|
-
return generateValue?.(schema) || '';
|
|
12
|
-
case schema.type === 'boolean':
|
|
13
|
-
return generateValue?.(schema) || false;
|
|
14
|
-
case schema.type === 'array':
|
|
15
|
-
if (!schema.minItems ||
|
|
16
|
-
!schema.items ||
|
|
17
|
-
typeof schema.items === 'boolean' ||
|
|
18
|
-
Array.isArray(schema.items)) {
|
|
19
|
-
return generateValue?.(schema) || [];
|
|
20
|
-
}
|
|
21
|
-
return new Array(schema.minItems).fill(generateValueFromSchema(schema.items, options));
|
|
22
|
-
case schema.type === 'number':
|
|
23
|
-
case schema.type === 'integer':
|
|
24
|
-
return generateValue?.(schema) || 0;
|
|
25
|
-
case schema.type === 'object': {
|
|
26
|
-
const obj = {};
|
|
27
|
-
for (const key in schema.properties) {
|
|
28
|
-
obj[key] = generateValueFromSchema(schema.properties[key], options);
|
|
29
|
-
}
|
|
30
|
-
return obj;
|
|
31
|
-
}
|
|
32
|
-
case Array.isArray(schema.type) && 'anyOf' in schema && Boolean(schema.anyOf?.length):
|
|
33
|
-
case Array.isArray(schema.type) &&
|
|
34
|
-
'oneOf' in schema &&
|
|
35
|
-
Boolean(schema.oneOf?.length):
|
|
36
|
-
{
|
|
37
|
-
const subSchema = (schema.anyOf || schema.oneOf)?.[0];
|
|
38
|
-
return generateValueFromSchema(subSchema, options);
|
|
39
|
-
}
|
|
40
|
-
case 'allOf' in schema && Boolean(schema.allOf?.length):
|
|
41
|
-
return generateValueFromSchema(schema.allOf?.[0], options);
|
|
42
|
-
default:
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export function generateSchemaTypeValue(schema) {
|
|
47
|
-
return generateValueFromSchema(schema, {
|
|
48
|
-
generateValue(schema) {
|
|
49
|
-
if (schema.type === 'array' && schema.items) {
|
|
50
|
-
return generateSchemaTypeValue(schema.items);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return schema.type;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
export function resolveRef(schema, schemas, options) {
|
|
59
|
-
const { prune } = options;
|
|
60
|
-
if (schema.$ref) {
|
|
61
|
-
const refKey = schema.$ref.replace('#/components/schemas/', '');
|
|
62
|
-
Object.assign(schema, schemas[refKey]);
|
|
63
|
-
if (prune.metadata &&
|
|
64
|
-
[
|
|
65
|
-
'io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta',
|
|
66
|
-
'io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta',
|
|
67
|
-
].some(k => refKey.includes(k)) &&
|
|
68
|
-
schema.properties) {
|
|
69
|
-
schema.properties = pick(schema.properties, [
|
|
70
|
-
'name',
|
|
71
|
-
'namespace',
|
|
72
|
-
'annotations',
|
|
73
|
-
'labels',
|
|
74
|
-
]);
|
|
75
|
-
}
|
|
76
|
-
delete schema.$ref;
|
|
77
|
-
}
|
|
78
|
-
for (const schemaKey in schema) {
|
|
79
|
-
if (prune.xProperty &&
|
|
80
|
-
schemaKey.startsWith('x-') &&
|
|
81
|
-
schemaKey !== 'x-kubernetes-group-version-kind') {
|
|
82
|
-
delete schema[schemaKey];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
switch (true) {
|
|
86
|
-
case schema.type === 'array':
|
|
87
|
-
if (Array.isArray(schema.items)) {
|
|
88
|
-
schema.items.forEach(item => resolveRef(item, schemas, options));
|
|
89
|
-
}
|
|
90
|
-
else if (typeof schema.items === 'object') {
|
|
91
|
-
resolveRef(schema.items, schemas, options);
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
case schema.type === 'object':
|
|
95
|
-
for (const key in schema.properties) {
|
|
96
|
-
const subSchema = schema.properties[key];
|
|
97
|
-
if (prune.optional && !schema.required?.includes(key)) {
|
|
98
|
-
delete schema.properties[key];
|
|
99
|
-
}
|
|
100
|
-
if (prune.fields.includes(key)) {
|
|
101
|
-
delete schema.properties[key];
|
|
102
|
-
}
|
|
103
|
-
resolveRef(subSchema, schemas, options);
|
|
104
|
-
}
|
|
105
|
-
if (schema.additionalProperties) {
|
|
106
|
-
resolveRef(schema.additionalProperties, schemas, options);
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
case !!(schema.allOf && schema.allOf[0]):
|
|
110
|
-
resolveRef(schema.allOf?.[0], schemas, options);
|
|
111
|
-
default:
|
|
112
|
-
}
|
|
113
|
-
if (prune.description) {
|
|
114
|
-
delete schema.description;
|
|
115
|
-
}
|
|
116
|
-
return schema;
|
|
117
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function matchSelector(pod, selector) {
|
|
2
|
-
let match = true;
|
|
3
|
-
// TODO: support complete selector match strategy
|
|
4
|
-
// https://github.com/rancher/dashboard/blob/master/shell/utils/selector.js#L166
|
|
5
|
-
for (const key in selector.matchLabels) {
|
|
6
|
-
if (!pod.metadata?.labels?.[key] ||
|
|
7
|
-
pod.metadata.labels?.[key] !== selector.matchLabels[key]) {
|
|
8
|
-
match = false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return match;
|
|
12
|
-
}
|
package/lib/src/utils/string.js
DELETED
package/lib/src/utils/time.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export function getSecondsDiff(startDate, endDate) {
|
|
2
|
-
return Math.round(Math.abs(Date.parse(endDate) - Date.parse(startDate)) / 1000);
|
|
3
|
-
}
|
|
4
|
-
export function elapsedTime(seconds, i18nMap) {
|
|
5
|
-
const { min, sec, hr, day } = i18nMap;
|
|
6
|
-
if (!seconds) {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
if (seconds < 120) {
|
|
10
|
-
return {
|
|
11
|
-
diff: 1,
|
|
12
|
-
label: `${seconds} ${sec}`,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const minutes = Math.floor(seconds / 60);
|
|
16
|
-
if (minutes < 10) {
|
|
17
|
-
return {
|
|
18
|
-
diff: 1,
|
|
19
|
-
label: `${minutes} ${min} ${seconds - minutes * 60} ${sec}`,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const hours = Math.floor(seconds / 3600);
|
|
23
|
-
if (hours < 3) {
|
|
24
|
-
return {
|
|
25
|
-
diff: 60,
|
|
26
|
-
label: `${minutes} ${min}`,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const days = Math.floor(seconds / (3600 * 24));
|
|
30
|
-
if (days > 1) {
|
|
31
|
-
return {
|
|
32
|
-
diff: 60,
|
|
33
|
-
label: `${days} ${day} ${hours - days * 24} ${hr}`,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (hours > 7) {
|
|
37
|
-
return {
|
|
38
|
-
diff: 60,
|
|
39
|
-
label: `${hours} ${hr}`,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
diff: 60,
|
|
44
|
-
label: `${hours} ${hr} ${minutes - hours * 60} ${min}`,
|
|
45
|
-
};
|
|
46
|
-
}
|
package/lib/src/utils/unit.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const UNITS = ['', 'K', 'M', 'G', 'T', 'P'];
|
|
2
|
-
const FRACTIONAL = ['', 'm', 'u', 'n', 'p', 'f']; // milli micro nano pico femto
|
|
3
|
-
export function formatSi(inValue, options) {
|
|
4
|
-
const { increment = 1000, suffix = null, firstSuffix = null, startingExponent = 0, minExponent = 0, maxPrecision = 2, atLeastOne = true, } = options || {};
|
|
5
|
-
let val = inValue;
|
|
6
|
-
let exp = startingExponent;
|
|
7
|
-
while ((val >= increment && exp + 1 < UNITS.length) || exp < minExponent) {
|
|
8
|
-
val = val / increment;
|
|
9
|
-
exp++;
|
|
10
|
-
}
|
|
11
|
-
let out = 0;
|
|
12
|
-
if (val < 10 && maxPrecision >= 2) {
|
|
13
|
-
out = Math.round(val * 100) / 100;
|
|
14
|
-
}
|
|
15
|
-
else if (val < 100 && maxPrecision >= 1) {
|
|
16
|
-
out = Math.round(val * 10) / 10;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
out = Math.round(val);
|
|
20
|
-
}
|
|
21
|
-
if (atLeastOne && out === 0) {
|
|
22
|
-
out = 1;
|
|
23
|
-
}
|
|
24
|
-
let outStr = String(out);
|
|
25
|
-
if (exp === 0 && firstSuffix !== null) {
|
|
26
|
-
outStr += `${firstSuffix}`;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
outStr += `${UNITS[exp]}${suffix}` || '';
|
|
30
|
-
}
|
|
31
|
-
return outStr;
|
|
32
|
-
}
|
|
33
|
-
export function parseSi(inValue, increment = null, allowFractional = true) {
|
|
34
|
-
if (!inValue || typeof inValue !== 'string' || !inValue.length) {
|
|
35
|
-
return NaN;
|
|
36
|
-
}
|
|
37
|
-
inValue = inValue.replace(/,/g, '');
|
|
38
|
-
// eslint-disable-next-line prefer-const
|
|
39
|
-
let [, valStr, unit, incStr] = inValue.match(/^([0-9.-]+)\s*([^0-9.-]?)([^0-9.-]?)/) || [];
|
|
40
|
-
const val = parseFloat(valStr);
|
|
41
|
-
if (!unit) {
|
|
42
|
-
return val;
|
|
43
|
-
}
|
|
44
|
-
// micro "mu" symbol -> u
|
|
45
|
-
if (unit.charCodeAt(0) === 181) {
|
|
46
|
-
unit = 'u';
|
|
47
|
-
}
|
|
48
|
-
const divide = FRACTIONAL.includes(unit);
|
|
49
|
-
const multiply = UNITS.includes(unit.toUpperCase());
|
|
50
|
-
if (increment === null) {
|
|
51
|
-
// Automatically handle 1 KB = 1000B, 1 KiB = 1024B if no increment set
|
|
52
|
-
if ((multiply || divide) && incStr === 'i') {
|
|
53
|
-
increment = 1024;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
increment = 1000;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (divide && allowFractional) {
|
|
60
|
-
const exp = FRACTIONAL.indexOf(unit);
|
|
61
|
-
return val / Math.pow(increment, exp);
|
|
62
|
-
}
|
|
63
|
-
if (multiply) {
|
|
64
|
-
const exp = UNITS.indexOf(unit.toUpperCase());
|
|
65
|
-
return val * Math.pow(increment, exp);
|
|
66
|
-
}
|
|
67
|
-
// Unrecognized unit character
|
|
68
|
-
return val;
|
|
69
|
-
}
|
package/lib/src/utils/yaml.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import yaml from 'js-yaml';
|
|
2
|
-
import { isObject } from 'lodash-es';
|
|
3
|
-
import { generateSchemaTypeValue } from './schema';
|
|
4
|
-
export function generateYamlBySchema(defaultValue, schema) {
|
|
5
|
-
const typeObject = generateSchemaTypeValue(schema);
|
|
6
|
-
function makeAnnotations(obj, key) {
|
|
7
|
-
const result = {};
|
|
8
|
-
if (isObject(obj[key])) {
|
|
9
|
-
result[`#${key}`] = {};
|
|
10
|
-
Object.keys(obj[key]).forEach(prop => {
|
|
11
|
-
result[`#${key}`] = {
|
|
12
|
-
...result[`#${key}`],
|
|
13
|
-
...makeAnnotations(obj[key], prop),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
result[`#${key}`] = obj[key];
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
function merge(obj1, obj2, merged = {}) {
|
|
23
|
-
for (const key in obj1) {
|
|
24
|
-
merged[key] = obj1[key];
|
|
25
|
-
}
|
|
26
|
-
for (const key in obj2) {
|
|
27
|
-
if (key in obj1) {
|
|
28
|
-
if (isObject(obj2[key]) && isObject(obj1[key])) {
|
|
29
|
-
merged[key] = merge(obj1[key], obj2[key]);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
merged = {
|
|
34
|
-
...merged,
|
|
35
|
-
...makeAnnotations(obj2, key),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return merged;
|
|
40
|
-
}
|
|
41
|
-
const merged = merge(defaultValue, typeObject);
|
|
42
|
-
const content = yaml.dump(merged);
|
|
43
|
-
return content.replace(/(')(#.+?)(')/g, '$2').replace(/( +)(#)/g, '$2$1');
|
|
44
|
-
}
|
package/lib/vite.config.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import linaria from '@linaria/vite';
|
|
3
|
-
import react from '@vitejs/plugin-react';
|
|
4
|
-
import { defineConfig } from 'vite';
|
|
5
|
-
import commonjs from 'vite-plugin-commonjs';
|
|
6
|
-
// import { getProxyConfig } from './tools/proxy-k8s';
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
plugins: [commonjs(), react(), linaria()],
|
|
9
|
-
server: {
|
|
10
|
-
host: '0.0.0.0',
|
|
11
|
-
proxy: {
|
|
12
|
-
// '/proxy-k8s': getProxyConfig(),
|
|
13
|
-
'/api': {
|
|
14
|
-
target: process.env.API_HOST || 'http://192.168.28.26',
|
|
15
|
-
ws: true,
|
|
16
|
-
headers: {
|
|
17
|
-
'x-skip-auth-verify': 'true',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
optimizeDeps: {
|
|
23
|
-
exclude: ['monaco-yaml/yaml.worker.js']
|
|
24
|
-
},
|
|
25
|
-
build: {
|
|
26
|
-
minify: false,
|
|
27
|
-
lib: {
|
|
28
|
-
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
29
|
-
name: 'dovetail',
|
|
30
|
-
},
|
|
31
|
-
rollupOptions: {
|
|
32
|
-
external: [
|
|
33
|
-
'@cloudtower/eagle',
|
|
34
|
-
'@cloudtower/icons-react',
|
|
35
|
-
'@refinedev/core',
|
|
36
|
-
'@refinedev/inferencer',
|
|
37
|
-
'antd',
|
|
38
|
-
'i18next',
|
|
39
|
-
'ky',
|
|
40
|
-
'lodash-es',
|
|
41
|
-
'mitt',
|
|
42
|
-
'qs',
|
|
43
|
-
'react',
|
|
44
|
-
'react-dom',
|
|
45
|
-
'react-router-dom',
|
|
46
|
-
'sunflower-antd',
|
|
47
|
-
'monaco-editor',
|
|
48
|
-
'monaco-yaml',
|
|
49
|
-
'js-yaml',
|
|
50
|
-
'k8s-api-provider',
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
resolve: {
|
|
55
|
-
preserveSymlinks: true,
|
|
56
|
-
alias: {
|
|
57
|
-
src: path.resolve(__dirname, 'src'),
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
});
|