chore(web): new lint setup (#30020)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-23 16:58:55 +08:00
committed by GitHub
parent 9701a2994b
commit f2842da397
3356 changed files with 85046 additions and 81278 deletions

View File

@ -1,23 +1,23 @@
'use client'
import React, { useCallback, useState } from 'react'
import Modal from '@/app/components/base/modal'
import type { PluginDeclaration, UpdateFromGitHubPayload } from '../../types'
import type { Item } from '@/app/components/base/select'
import type { InstallState } from '@/app/components/plugins/types'
import { useGitHubReleases } from '../hooks'
import { convertRepoToUrl, parseGitHubUrl } from '../utils'
import type { PluginDeclaration, UpdateFromGitHubPayload } from '../../types'
import { InstallStepFromGitHub } from '../../types'
import Toast from '@/app/components/base/toast'
import SetURL from './steps/setURL'
import SelectPackage from './steps/selectPackage'
import Installed from '../base/installed'
import Loaded from './steps/loaded'
import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon'
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import useRefreshPluginList from '../hooks/use-refresh-plugin-list'
import Modal from '@/app/components/base/modal'
import Toast from '@/app/components/base/toast'
import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon'
import { cn } from '@/utils/classnames'
import { InstallStepFromGitHub } from '../../types'
import Installed from '../base/installed'
import { useGitHubReleases } from '../hooks'
import useHideLogic from '../hooks/use-hide-logic'
import useRefreshPluginList from '../hooks/use-refresh-plugin-list'
import { convertRepoToUrl, parseGitHubUrl } from '../utils'
import Loaded from './steps/loaded'
import SelectPackage from './steps/selectPackage'
import SetURL from './steps/setURL'
const i18nPrefix = 'plugin.installFromGitHub'
@ -60,12 +60,12 @@ const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({ updatePayload, on
const packages: Item[] = state.selectedVersion
? (state.releases
.find(release => release.tag_name === state.selectedVersion)
?.assets
.map(asset => ({
value: asset.name,
name: asset.name,
})) || [])
.find(release => release.tag_name === state.selectedVersion)
?.assets
.map(asset => ({
value: asset.name,
name: asset.name,
})) || [])
: []
const getTitle = useCallback(() => {
@ -172,62 +172,66 @@ const InstallFromGitHub: React.FC<InstallFromGitHubProps> = ({ updatePayload, on
border-components-panel-border bg-components-panel-bg p-0`)}
closable
>
<div className='flex items-start gap-2 self-stretch pb-3 pl-6 pr-14 pt-6'>
<div className='flex grow flex-col items-start gap-1'>
<div className='title-2xl-semi-bold self-stretch text-text-primary'>
<div className="flex items-start gap-2 self-stretch pb-3 pl-6 pr-14 pt-6">
<div className="flex grow flex-col items-start gap-1">
<div className="title-2xl-semi-bold self-stretch text-text-primary">
{getTitle()}
</div>
<div className='system-xs-regular self-stretch text-text-tertiary'>
<div className="system-xs-regular self-stretch text-text-tertiary">
{!([InstallStepFromGitHub.uploadFailed, InstallStepFromGitHub.installed, InstallStepFromGitHub.installFailed].includes(state.step)) && t('plugin.installFromGitHub.installNote')}
</div>
</div>
</div>
{([InstallStepFromGitHub.uploadFailed, InstallStepFromGitHub.installed, InstallStepFromGitHub.installFailed].includes(state.step))
? <Installed
payload={manifest}
isFailed={[InstallStepFromGitHub.uploadFailed, InstallStepFromGitHub.installFailed].includes(state.step)}
errMsg={errorMsg}
onCancel={onClose}
/>
: <div className={`flex flex-col items-start justify-center self-stretch px-6 py-3 ${state.step === InstallStepFromGitHub.installed ? 'gap-2' : 'gap-4'}`}>
{state.step === InstallStepFromGitHub.setUrl && (
<SetURL
repoUrl={state.repoUrl}
onChange={value => setState(prevState => ({ ...prevState, repoUrl: value }))}
onNext={handleUrlSubmit}
? (
<Installed
payload={manifest}
isFailed={[InstallStepFromGitHub.uploadFailed, InstallStepFromGitHub.installFailed].includes(state.step)}
errMsg={errorMsg}
onCancel={onClose}
/>
)
: (
<div className={`flex flex-col items-start justify-center self-stretch px-6 py-3 ${state.step === InstallStepFromGitHub.installed ? 'gap-2' : 'gap-4'}`}>
{state.step === InstallStepFromGitHub.setUrl && (
<SetURL
repoUrl={state.repoUrl}
onChange={value => setState(prevState => ({ ...prevState, repoUrl: value }))}
onNext={handleUrlSubmit}
onCancel={onClose}
/>
)}
{state.step === InstallStepFromGitHub.selectPackage && (
<SelectPackage
updatePayload={updatePayload!}
repoUrl={state.repoUrl}
selectedVersion={state.selectedVersion}
versions={versions}
onSelectVersion={item => setState(prevState => ({ ...prevState, selectedVersion: item.value as string }))}
selectedPackage={state.selectedPackage}
packages={packages}
onSelectPackage={item => setState(prevState => ({ ...prevState, selectedPackage: item.value as string }))}
onUploaded={handleUploaded}
onFailed={handleUploadFail}
onBack={handleBack}
/>
)}
{state.step === InstallStepFromGitHub.readyToInstall && (
<Loaded
updatePayload={updatePayload!}
uniqueIdentifier={uniqueIdentifier!}
payload={manifest as any}
repoUrl={state.repoUrl}
selectedVersion={state.selectedVersion}
selectedPackage={state.selectedPackage}
onBack={handleBack}
onStartToInstall={handleStartToInstall}
onInstalled={handleInstalled}
onFailed={handleFailed}
/>
)}
</div>
)}
{state.step === InstallStepFromGitHub.selectPackage && (
<SelectPackage
updatePayload={updatePayload!}
repoUrl={state.repoUrl}
selectedVersion={state.selectedVersion}
versions={versions}
onSelectVersion={item => setState(prevState => ({ ...prevState, selectedVersion: item.value as string }))}
selectedPackage={state.selectedPackage}
packages={packages}
onSelectPackage={item => setState(prevState => ({ ...prevState, selectedPackage: item.value as string }))}
onUploaded={handleUploaded}
onFailed={handleUploadFail}
onBack={handleBack}
/>
)}
{state.step === InstallStepFromGitHub.readyToInstall && (
<Loaded
updatePayload={updatePayload!}
uniqueIdentifier={uniqueIdentifier!}
payload={manifest as any}
repoUrl={state.repoUrl}
selectedVersion={state.selectedVersion}
selectedPackage={state.selectedPackage}
onBack={handleBack}
onStartToInstall={handleStartToInstall}
onInstalled={handleInstalled}
onFailed={handleFailed}
/>
)}
</div>}
</Modal>
)
}

View File

@ -1,19 +1,18 @@
'use client'
import React, { useEffect } from 'react'
import Button from '@/app/components/base/button'
import { type Plugin, type PluginDeclaration, TaskStatus, type UpdateFromGitHubPayload } from '../../../types'
import Card from '../../../card'
import { pluginManifestToCardPluginProps } from '../../utils'
import { useTranslation } from 'react-i18next'
import { updateFromGitHub } from '@/service/plugins'
import { useInstallPackageFromGitHub } from '@/service/use-plugins'
import type { Plugin, PluginDeclaration, UpdateFromGitHubPayload } from '../../../types'
import { RiLoader2Line } from '@remixicon/react'
import { usePluginTaskList } from '@/service/use-plugins'
import checkTaskStatus from '../../base/check-task-status'
import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button'
import useCheckInstalled from '@/app/components/plugins/install-plugin/hooks/use-check-installed'
import { parseGitHubUrl } from '../../utils'
import { updateFromGitHub } from '@/service/plugins'
import { useInstallPackageFromGitHub, usePluginTaskList } from '@/service/use-plugins'
import Card from '../../../card'
import { TaskStatus } from '../../../types'
import checkTaskStatus from '../../base/check-task-status'
import Version from '../../base/version'
import { parseGitHubUrl, pluginManifestToCardPluginProps } from '../../utils'
type LoadedProps = {
updatePayload: UpdateFromGitHubPayload
@ -64,7 +63,8 @@ const Loaded: React.FC<LoadedProps> = ({
}, [hasInstalled])
const handleInstall = async () => {
if (isInstalling) return
if (isInstalling)
return
setIsInstalling(true)
onStartToInstall?.()
@ -142,33 +142,35 @@ const Loaded: React.FC<LoadedProps> = ({
return (
<>
<div className='system-md-regular text-text-secondary'>
<div className="system-md-regular text-text-secondary">
<p>{t(`${i18nPrefix}.readyToInstall`)}</p>
</div>
<div className='flex flex-wrap content-start items-start gap-1 self-stretch rounded-2xl bg-background-section-burn p-2'>
<div className="flex flex-wrap content-start items-start gap-1 self-stretch rounded-2xl bg-background-section-burn p-2">
<Card
className='w-full'
className="w-full"
payload={pluginManifestToCardPluginProps(payload as PluginDeclaration)}
titleLeft={!isLoading && <Version
hasInstalled={hasInstalled}
installedVersion={installedVersion}
toInstallVersion={toInstallVersion}
/>}
titleLeft={!isLoading && (
<Version
hasInstalled={hasInstalled}
installedVersion={installedVersion}
toInstallVersion={toInstallVersion}
/>
)}
/>
</div>
<div className='mt-4 flex items-center justify-end gap-2 self-stretch'>
<div className="mt-4 flex items-center justify-end gap-2 self-stretch">
{!isInstalling && (
<Button variant='secondary' className='min-w-[72px]' onClick={onBack}>
<Button variant="secondary" className="min-w-[72px]" onClick={onBack}>
{t('plugin.installModal.back')}
</Button>
)}
<Button
variant='primary'
className='flex min-w-[72px] space-x-0.5'
variant="primary"
className="flex min-w-[72px] space-x-0.5"
onClick={handleInstall}
disabled={isInstalling || isLoading}
>
{isInstalling && <RiLoader2Line className='h-4 w-4 animate-spin-slow' />}
{isInstalling && <RiLoader2Line className="h-4 w-4 animate-spin-slow" />}
<span>{t(`${i18nPrefix}.${isInstalling ? 'installing' : 'install'}`)}</span>
</Button>
</div>

View File

@ -1,11 +1,11 @@
'use client'
import React from 'react'
import type { Item } from '@/app/components/base/select'
import { PortalSelect } from '@/app/components/base/select'
import Button from '@/app/components/base/button'
import type { PluginDeclaration, UpdateFromGitHubPayload } from '../../../types'
import type { Item } from '@/app/components/base/select'
import React from 'react'
import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button'
import { PortalSelect } from '@/app/components/base/select'
import { useGitHubUpload } from '../../hooks'
const i18nPrefix = 'plugin.installFromGitHub'
@ -46,7 +46,8 @@ const SelectPackage: React.FC<SelectPackageProps> = ({
const { handleUpload } = useGitHubUpload()
const handleUploadPackage = async () => {
if (isUploading) return
if (isUploading)
return
setIsUploading(true)
try {
const repo = repoUrl.replace('https://github.com/', '')
@ -71,10 +72,10 @@ const SelectPackage: React.FC<SelectPackageProps> = ({
return (
<>
<label
htmlFor='version'
className='flex flex-col items-start justify-center self-stretch text-text-secondary'
htmlFor="version"
className="flex flex-col items-start justify-center self-stretch text-text-secondary"
>
<span className='system-sm-semibold'>{t(`${i18nPrefix}.selectVersion`)}</span>
<span className="system-sm-semibold">{t(`${i18nPrefix}.selectVersion`)}</span>
</label>
<PortalSelect
value={selectedVersion}
@ -82,14 +83,14 @@ const SelectPackage: React.FC<SelectPackageProps> = ({
items={versions}
installedValue={updatePayload?.originalPackageInfo.version}
placeholder={t(`${i18nPrefix}.selectVersionPlaceholder`) || ''}
popupClassName='w-[512px] z-[1001]'
triggerClassName='text-components-input-text-filled'
popupClassName="w-[512px] z-[1001]"
triggerClassName="text-components-input-text-filled"
/>
<label
htmlFor='package'
className='flex flex-col items-start justify-center self-stretch text-text-secondary'
htmlFor="package"
className="flex flex-col items-start justify-center self-stretch text-text-secondary"
>
<span className='system-sm-semibold'>{t(`${i18nPrefix}.selectPackage`)}</span>
<span className="system-sm-semibold">{t(`${i18nPrefix}.selectPackage`)}</span>
</label>
<PortalSelect
value={selectedPackage}
@ -97,23 +98,24 @@ const SelectPackage: React.FC<SelectPackageProps> = ({
items={packages}
readonly={!selectedVersion}
placeholder={t(`${i18nPrefix}.selectPackagePlaceholder`) || ''}
popupClassName='w-[512px] z-[1001]'
triggerClassName='text-components-input-text-filled'
popupClassName="w-[512px] z-[1001]"
triggerClassName="text-components-input-text-filled"
/>
<div className='mt-4 flex items-center justify-end gap-2 self-stretch'>
<div className="mt-4 flex items-center justify-end gap-2 self-stretch">
{!isEdit
&& <Button
variant='secondary'
className='min-w-[72px]'
onClick={onBack}
disabled={isUploading}
>
{t('plugin.installModal.back')}
</Button>
}
&& (
<Button
variant="secondary"
className="min-w-[72px]"
onClick={onBack}
disabled={isUploading}
>
{t('plugin.installModal.back')}
</Button>
)}
<Button
variant='primary'
className='min-w-[72px]'
variant="primary"
className="min-w-[72px]"
onClick={handleUploadPackage}
disabled={!selectedVersion || !selectedPackage || isUploading}
>

View File

@ -1,8 +1,8 @@
'use client'
import React from 'react'
import Button from '@/app/components/base/button'
import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button'
type SetURLProps = {
repoUrl: string
@ -16,33 +16,33 @@ const SetURL: React.FC<SetURLProps> = ({ repoUrl, onChange, onNext, onCancel })
return (
<>
<label
htmlFor='repoUrl'
className='flex flex-col items-start justify-center self-stretch text-text-secondary'
htmlFor="repoUrl"
className="flex flex-col items-start justify-center self-stretch text-text-secondary"
>
<span className='system-sm-semibold'>{t('plugin.installFromGitHub.gitHubRepo')}</span>
<span className="system-sm-semibold">{t('plugin.installFromGitHub.gitHubRepo')}</span>
</label>
<input
type='url'
id='repoUrl'
name='repoUrl'
type="url"
id="repoUrl"
name="repoUrl"
value={repoUrl}
onChange={e => onChange(e.target.value)}
className='shadows-shadow-xs system-sm-regular flex grow items-center gap-[2px]
className="shadows-shadow-xs system-sm-regular flex grow items-center gap-[2px]
self-stretch overflow-hidden text-ellipsis rounded-lg border border-components-input-border-active
bg-components-input-bg-active p-2 text-components-input-text-filled'
placeholder='Please enter GitHub repo URL'
bg-components-input-bg-active p-2 text-components-input-text-filled"
placeholder="Please enter GitHub repo URL"
/>
<div className='mt-4 flex items-center justify-end gap-2 self-stretch'>
<div className="mt-4 flex items-center justify-end gap-2 self-stretch">
<Button
variant='secondary'
className='min-w-[72px]'
variant="secondary"
className="min-w-[72px]"
onClick={onCancel}
>
{t('plugin.installModal.cancel')}
</Button>
<Button
variant='primary'
className='min-w-[72px]'
variant="primary"
className="min-w-[72px]"
onClick={onNext}
disabled={!repoUrl.trim()}
>