Skip to content

Commit

Permalink
fix: fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
bowen tan authored and bowen tan committed Oct 23, 2024
1 parent 9e00bb5 commit bf2ff4e
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 54 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
- name: Install deps
run: yarn install --frozen-lockfile
timeout-minutes: 15
- name: Lint
run: cd packages/refine && yarn lint
- name: Test
run: cd packages/refine && yarn jest
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion packages/refine/src/components/Form/useFieldsConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ResourceModel } from 'src/models';
import { useList, useShow } from '@refinedev/core';
import { ResourceModel } from 'src/models';
import { ResourceConfig } from 'src/types';

function useFieldsConfig<Model extends ResourceModel>(config?: ResourceConfig<Model>, resourceId?: string) {
Expand Down
4 changes: 2 additions & 2 deletions packages/refine/src/components/Form/useYamlForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import { FormInstance, FormProps } from 'antd/lib/form';
import yaml from 'js-yaml';
import { JSONSchema7 } from 'json-schema';
import { Unstructured } from 'k8s-api-provider';
import { get, uniq } from 'lodash-es';
import React, { useRef, useState, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { RefineFormValidator } from 'src/components/Form/type';
import { type YamlEditorHandle, type YamlEditorProps } from 'src/components/YamlEditor';
import useK8sYamlEditor from 'src/hooks/useK8sYamlEditor';
import { useSchema } from 'src/hooks/useSchema';
import { pruneBeforeEdit } from 'src/utils/k8s';
import { generateYamlBySchema } from 'src/utils/yaml';
import { useForm as useFormSF } from 'sunflower-antd';
import { useGlobalStore } from '../../hooks/useGlobalStore';
import { RefineFormValidator } from 'src/components/Form/type'
import { get, uniq } from 'lodash-es';

type EditorProps = YamlEditorProps & {
ref: React.RefObject<YamlEditorHandle>;
Expand Down
8 changes: 0 additions & 8 deletions packages/refine/src/components/InternalBaseTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ function Table<Data extends { id: string; }>(props: InternalTableProps<Data>) {
const auxiliaryLineRef = useRef(null);
const wrapperRef = useRef(null);

const pagination = useMemo(
() => ({
current: currentPage,
pageSize: defaultSize,
onChange: onPageChange,
}),
[currentPage, defaultSize, onPageChange]
);
const finalColumns = useMemo(() => {
if (RowMenu) {
const actionColumn: Column<Data> = {
Expand Down
5 changes: 2 additions & 3 deletions packages/refine/src/components/PVCDistributeStorage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Fields, Form, Units } from '@cloudtower/eagle';
import { useResource, useUpdate } from '@refinedev/core';
import { isNil } from 'lodash-es';
import React, { useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { EditField } from 'src/components/EditField';
Expand Down Expand Up @@ -101,8 +100,8 @@ export const DistributeStorageForm = React.forwardRef<DistributeStorageFormHandl
distributeStorage: validators.distributeStorage(v)
});
},
onBlur: () => { },
onFocus: () => { },
onBlur: () => undefined,
onFocus: () => undefined,
}}
min={1}
meta={{}}
Expand Down
71 changes: 37 additions & 34 deletions packages/refine/src/components/PodLog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SegmentControl, Select, AntdOption, Checkbox, Button } from '@cloudtower/eagle';
import {
SuspendedPause16GradientBlueIcon,
RecoverContinue16GradientBlueIcon
RecoverContinue16GradientBlueIcon,
} from '@cloudtower/icons-react';
import { css } from '@linaria/core';
import { LogViewer } from '@patternfly/react-log-viewer';
Expand Down Expand Up @@ -48,7 +48,6 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => {
const [currentItemCount, setCurrentItemCount] = useState(0);
const [paused, setPaused] = useState(false);
const [wrap, setWrap] = useState(false);
const [linesBehind, setLinesBehind] = useState(0);
const logViewerRef = useRef<{ scrollToBottom: () => void }>(null);
const abortControllerRef = useRef<AbortController | null>(null);

Expand All @@ -63,10 +62,6 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => {
if (logViewerRef && logViewerRef.current) {
logViewerRef.current.scrollToBottom();
}
} else if (logs.length !== currentItemCount) {
setLinesBehind(logs.length - currentItemCount);
} else {
setLinesBehind(0);
}
}, [paused, logs, currentItemCount]);

Expand All @@ -92,11 +87,11 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => {
}
};

const fetchLogsByUrl = useCallback(async (url) => {
const fetchLogsByUrl = useCallback(async url => {
abortControllerRef.current = new AbortController();
const { signal } = abortControllerRef.current;

fetch(url, { signal }).then(async (response) => {
fetch(url, { signal }).then(async response => {
if (response.status !== 200) {
setLogs([]);
return;
Expand Down Expand Up @@ -158,7 +153,14 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => {
} else if (logType === 'previous') {
fetchLogsByUrl(`${url}&previous=true`);
}
}, [pod.metadata?.namespace, pod.metadata?.name, selectedContainer, logType, apiUrl, fetchLogsByUrl]);
}, [
pod.metadata?.namespace,
pod.metadata?.name,
selectedContainer,
logType,
apiUrl,
fetchLogsByUrl,
]);

const stopFetchingLogs = useCallback(() => {
if (abortControllerRef.current) {
Expand All @@ -182,15 +184,15 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => {
options={[
{
label: t('dovetail.realtime_log'),
value: 'realtime'
value: 'realtime',
},
{
label: t('dovetail.previous_log'),
value: 'previous'
value: 'previous',
},
]}
value={logType}
onChange={(value) => {
onChange={value => {
setLogType(value as 'realtime' | 'previous');
setLogs([]);
}}
Expand All @@ -202,7 +204,6 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => {
setSelectedContainer(newValue as string);
setLogs([]);
setPaused(false);
setLinesBehind(0);
},
value: selectedContainer,
}}
Expand All @@ -225,34 +226,36 @@ export const PodLog: React.FC<{ pod: PodModel }> = ({ pod }) => {

<Button
onClick={() => setPaused(prev => !prev)}
prefixIcon={paused ? <RecoverContinue16GradientBlueIcon /> : <SuspendedPause16GradientBlueIcon />}
prefixIcon={
paused ? (
<RecoverContinue16GradientBlueIcon />
) : (
<SuspendedPause16GradientBlueIcon />
)
}
size="middle"
>
{paused ? t('dovetail.resume') : t('dovetail.suspend')}
</Button>
</span>

</div>
<div className={ContentStyle}>
{
logType === 'previous' && !logs.length ? (
<ErrorContent
style={{ height: '100%' }}
errorText={t('dovetail.no_resource', { kind: t('dovetail.previous_log') })}
/>
) : (
<LogViewer
innerRef={logViewerRef}
height="100%"
hasLineNumbers={true}
data={logs}
theme="light"
isTextWrapped={wrap}
onScroll={onScroll}
/>
)
}

{logType === 'previous' && !logs.length ? (
<ErrorContent
style={{ height: '100%' }}
errorText={t('dovetail.no_resource', { kind: t('dovetail.previous_log') })}
/>
) : (
<LogViewer
innerRef={logViewerRef}
height="100%"
hasLineNumbers={true}
data={logs}
theme="light"
isTextWrapped={wrap}
onScroll={onScroll}
/>
)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/refine/src/pages/daemonsets/list/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IResourceComponentsProps } from '@refinedev/core';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { ListPage } from 'src/components/ListPage';
import { WorkloadDropdown } from 'src/components/Dropdowns/WorkloadDropdown';
import { ListPage } from 'src/components/ListPage';
import { useEagleTable } from 'src/hooks/useEagleTable';
import {
AgeColumnRenderer,
Expand Down
2 changes: 1 addition & 1 deletion packages/refine/src/pages/deployments/list/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IResourceComponentsProps } from '@refinedev/core';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { ListPage } from 'src/components/ListPage';
import { ReplicasDropdown } from 'src/components/Dropdowns/ReplicasDropdown';
import { ListPage } from 'src/components/ListPage';
import { useEagleTable } from 'src/hooks/useEagleTable';
import {
AgeColumnRenderer,
Expand Down
2 changes: 1 addition & 1 deletion packages/refine/src/pages/deployments/show/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IResourceComponentsProps } from '@refinedev/core';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { WorkloadDropdown } from '../../../components/Dropdowns/WorkloadDropdown';
import { PageShow } from '../../../components/PageShow';
import {
ImageField,
Expand All @@ -10,7 +11,6 @@ import {
ConditionsGroup,
EventsTab
} from '../../../components/ShowContent';
import { WorkloadDropdown } from '../../../components/Dropdowns/WorkloadDropdown';
import { WorkloadModel } from '../../../models';

export const DeploymentShow: React.FC<IResourceComponentsProps> = () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/refine/src/types/modal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ type ModalProps = {
};

declare module '@cloudtower/eagle' {
interface IModalProps extends ModalProps { }

export declare function pushModal<K extends keyof ModalProps>(
modal: ModalType<ModalProps[K]>
): void;
Expand Down
2 changes: 1 addition & 1 deletion packages/refine/src/types/resource.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UseFormProps } from '@refinedev/react-hook-form';
import { YamlFormProps } from '../components';
import { RefineFormField } from '../components/Form';
import { ShowConfig } from '../components/ShowContent';
import { Column, InternalTableProps } from '../components/InternalBaseTable';
import { ShowConfig } from '../components/ShowContent';
import { ResourceModel } from '../models';

export enum RESOURCE_GROUP {
Expand Down

0 comments on commit bf2ff4e

Please sign in to comment.