|
|
|
@ -1,14 +1,15 @@
|
|
|
|
'use client'
|
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
|
|
import React, { useCallback, useState } from 'react'
|
|
|
|
import React, { useCallback, useState } from 'react'
|
|
|
|
import { useContext } from 'use-context-selector'
|
|
|
|
|
|
|
|
import Modal from '@/app/components/base/modal'
|
|
|
|
import Modal from '@/app/components/base/modal'
|
|
|
|
import I18n from '@/context/i18n'
|
|
|
|
|
|
|
|
import type { PluginDeclaration } from '../../types'
|
|
|
|
import type { PluginDeclaration } from '../../types'
|
|
|
|
import { InstallStep } from '../../types'
|
|
|
|
import { InstallStep } from '../../types'
|
|
|
|
import Uploading from './steps/uploading'
|
|
|
|
import Uploading from './steps/uploading'
|
|
|
|
import Install from './steps/install'
|
|
|
|
import Install from './steps/install'
|
|
|
|
import Installed from './steps/installed'
|
|
|
|
import Installed from './steps/installed'
|
|
|
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const i18nPrefix = 'plugin.installModal'
|
|
|
|
|
|
|
|
|
|
|
|
type InstallFromLocalPackageProps = {
|
|
|
|
type InstallFromLocalPackageProps = {
|
|
|
|
file: File
|
|
|
|
file: File
|
|
|
|
@ -18,12 +19,18 @@ type InstallFromLocalPackageProps = {
|
|
|
|
|
|
|
|
|
|
|
|
const InstallFromLocalPackage: React.FC<InstallFromLocalPackageProps> = ({
|
|
|
|
const InstallFromLocalPackage: React.FC<InstallFromLocalPackageProps> = ({
|
|
|
|
file,
|
|
|
|
file,
|
|
|
|
onClose
|
|
|
|
onClose,
|
|
|
|
}) => {
|
|
|
|
}) => {
|
|
|
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const [step, setStep] = useState<InstallStep>(InstallStep.uploading)
|
|
|
|
const [step, setStep] = useState<InstallStep>(InstallStep.uploading)
|
|
|
|
const { locale } = useContext(I18n)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [uniqueIdentifier, setUniqueIdentifier] = useState<string | null>(null)
|
|
|
|
const [uniqueIdentifier, setUniqueIdentifier] = useState<string | null>(null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getTitle = useCallback(() => {
|
|
|
|
|
|
|
|
if (step === InstallStep.installed)
|
|
|
|
|
|
|
|
return t(`${i18nPrefix}.installedSuccessfully`)
|
|
|
|
|
|
|
|
return t(`${i18nPrefix}.installPlugin`)
|
|
|
|
|
|
|
|
}, [])
|
|
|
|
const [manifest, setManifest] = useState<PluginDeclaration | null>({
|
|
|
|
const [manifest, setManifest] = useState<PluginDeclaration | null>({
|
|
|
|
name: 'Notion Sync',
|
|
|
|
name: 'Notion Sync',
|
|
|
|
description: 'Sync your Notion notes with Dify',
|
|
|
|
description: 'Sync your Notion notes with Dify',
|
|
|
|
@ -51,7 +58,7 @@ const InstallFromLocalPackage: React.FC<InstallFromLocalPackageProps> = ({
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div className='flex pt-6 pl-6 pb-3 pr-14 items-start gap-2 self-stretch'>
|
|
|
|
<div className='flex pt-6 pl-6 pb-3 pr-14 items-start gap-2 self-stretch'>
|
|
|
|
<div className='self-stretch text-text-primary title-2xl-semi-bold'>
|
|
|
|
<div className='self-stretch text-text-primary title-2xl-semi-bold'>
|
|
|
|
Install plugin
|
|
|
|
{getTitle()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{step === InstallStep.uploading && (
|
|
|
|
{step === InstallStep.uploading && (
|
|
|
|
|