Skip to content

Commit

Permalink
Merge pull request #199 from webzard-io/feat/resources
Browse files Browse the repository at this point in the history
fix: change some styles
  • Loading branch information
tanbowensg authored Nov 18, 2024
2 parents 2c05fa9 + 4e9c7dd commit 67f587a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/refine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dovetail-v2/refine",
"version": "0.1.16",
"version": "0.1.18-alpha.1",
"type": "module",
"files": [
"dist",
Expand Down
4 changes: 2 additions & 2 deletions packages/refine/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ function App() {
const globalStore = useMemo(() => {
return new GlobalStore(
{
apiUrl: '/api/sks-proxy/api/v1/clusters/yangfeng-test/proxy',
watchWsApiUrl: 'api/sks-ws/sks-proxy/api/v1/clusters/yangfeng-test/proxy',
apiUrl: '/api/sks-proxy/api/v1/clusters/vm-workload/proxy',
watchWsApiUrl: 'api/sks-ws/sks-proxy/api/v1/clusters/vm-workload/proxy',
prefix: 'default',
plugins: ProviderPlugins,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/refine/src/components/Form/RefineFormContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const RefineFormContent = <Model extends ResourceModel>(props: Props<Mode
key={c.key}
label={c.label}
colon={false}
labelCol={{ flex: '0 0 216px' }}
labelCol={{ flex: `0 0 ${config?.formConfig?.labelWidth || '216px'}` }}
help={fieldState.error?.message}
validateStatus={fieldState.invalid ? 'error' : undefined}
>
Expand Down
7 changes: 5 additions & 2 deletions packages/refine/src/components/ResourceLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Link } from '@cloudtower/eagle';
import { css } from '@linaria/core';
import { useGo, useNavigation } from '@refinedev/core';

import React from 'react';
import { ValueDisplay } from '../ValueDisplay';


type Props = {
resourceKind: string;
Expand Down Expand Up @@ -30,9 +31,11 @@ export const ResourceLink: React.FC<Props> = props => {
});
};

return (
return resourceId ? (
<Link className={LinkStyle} onClick={onClick} title={resourceId}>
{resourceId}
</Link>
) : (
<ValueDisplay value="" />
);
};
4 changes: 2 additions & 2 deletions packages/refine/src/components/ShowContent/ShowContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ export const ShowContent = <Model extends ResourceModel>(props: Props<Model>) =>
);
const tabs = (
<Tabs
tabs={(showConfig.tabs || []).map(tab => {
tabs={(showConfig.tabs || []).map((tab, tabIndex) => {
return {
title: tab.title,
key: tab.key,
children: (
<div
className={cx(
TabContentStyle,
tab.groups.length <= 1 && FullTabContentStyle
tab.groups.length <= 1 && tabIndex !== 0 && FullTabContentStyle
)}
>
{tab.groups?.map(group => {
Expand Down
17 changes: 8 additions & 9 deletions packages/refine/src/hooks/useEagleTable/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
PersistentVolumeModel,
PersistentVolumeClaimModel,
} from '../../models';
import { parseSi } from '../../utils/unit';

const DashedTitleStyle = css`
border-bottom: 1px dashed rgba(107, 128, 167, 0.6);
Expand Down Expand Up @@ -147,12 +146,12 @@ export const NameSpaceColumnRenderer = <Model extends ResourceModel>(

export const StateDisplayColumnRenderer = <
Model extends
| WorkloadModel
| CronJobModel
| PodModel
| ServiceModel
| DaemonSetModel
| JobModel,
| WorkloadModel
| CronJobModel
| PodModel
| ServiceModel
| DaemonSetModel
| JobModel,
>(
i18n: I18nType
): Column<Model> => {
Expand Down Expand Up @@ -645,13 +644,13 @@ export const PVCapacityColumnRenderer = <Model extends PersistentVolumeModel>(
return {
key: 'capacity',
display: true,
dataIndex: ['spec', 'capacity', 'storage'],
dataIndex: ['storageBytes'],
title: i18n.t('dovetail.capacity'),
width: 120,
sortable: true,
align: 'right',
render(value) {
return <Units.Byte rawValue={parseSi(value)} decimals={1} />;
return <Units.Byte rawValue={value} decimals={2} />;
},
};
};
Expand Down
6 changes: 6 additions & 0 deletions packages/refine/src/models/persistent-volume.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { GlobalStore, Unstructured } from 'k8s-api-provider';
import type { PersistentVolume } from 'kubernetes-types/core/v1';
import { get } from 'lodash-es';
import { ResourceState } from 'src/constants';
import { parseSi } from '../utils/unit';
import { ResourceModel } from './resource-model';

type RequiredPersistentVolume = Required<PersistentVolume> & Unstructured;
Expand Down Expand Up @@ -47,4 +49,8 @@ export class PersistentVolumeModel extends ResourceModel {
get pvcNamespace() {
return this._rawYaml.spec.claimRef?.namespace;
}

get storageBytes() {
return parseSi(get(this._rawYaml, ['spec', 'capacity', 'storage']));
}
}
1 change: 1 addition & 0 deletions packages/refine/src/types/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export type ResourceConfig<Model extends ResourceModel = ResourceModel> = {
transformApplyValues?: (values: Record<string, unknown>) => Model['_rawYaml'];
formTitle?: string | ((action: 'create' | 'edit') => string);
formDesc?: string | ((action: 'create' | 'edit') => string);
labelWidth?: string;
formatError?: (errorBody: unknown) => string;
refineCoreProps?: UseFormProps['refineCoreProps'];
useFormProps?: UseFormProps;
Expand Down

0 comments on commit 67f587a

Please sign in to comment.