Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add refer option to export conversation.json using API #271

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "Invalid File Format",
"Export from official export file": "Export from official export file",
"Export from API": "Export from API",
"Refer": "Refer",
"Available variables": "Available variables",
"Conversation Timestamp": "Conversation Timestamp",
"Conversation Timestamp Description": "Will show on the page.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "Formato de archivo inválido",
"Export from official export file": "Exportar desde archivo de exportación oficial",
"Export from API": "Exportar desde API",
"Refer": "Referir",
"Available variables": "Variables Disponibles",
"Conversation Timestamp": "Marca de Tiempo",
"Conversation Timestamp Description": "Aparecerá en la página.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "Format de fichier invalide",
"Export from official export file": "Exporter depuis un fichier officiel",
"Export from API": "Exporter depuis l'API",
"Refer": "Référer",
"Available variables": "Variables disponibles",
"Conversation Timestamp": "Horodatage de la conversation",
"Conversation Timestamp Description": "S'affichera sur la page.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "Format File Tidak Valid",
"Export from official export file": "Ekspor dari file ekspor resmi",
"Export from API": "Ekspor dari API",
"Refer": "Rujuk",
"Available variables": "Variabel yang Tersedia",
"Conversation Timestamp": "Timestamp Percakapan",
"Conversation Timestamp Description": "Akan ditampilkan pada halaman.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "無効なファイル形式",
"Export from official export file": "公式エクスポートファイルからエクスポートする",
"Export from API": "APIからエクスポートする",
"Refer": "参照",
"Available variables": "使用可能な変数",
"Conversation Timestamp": "会話のタイムスタンプ",
"Conversation Timestamp Description": "ページに表示されます。",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "Неверный формат файла",
"Export from official export file": "Экспорт из официального файла",
"Export from API": "Экспорт из API",
"Refer": "Ссылка",
"Available variables": "Доступные переменные",
"Conversation Timestamp": "Временная метка разговора",
"Conversation Timestamp Description": "Будет отображаться на странице.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "Dosya Biçimi Geçersiz",
"Export from official export file": "Resmi dışa aktarma dosyasından dışa aktar",
"Export from API": "API'den dışa aktar",
"Refer": "Başvur",
"Available variables": "Kullanılabilir değişkenler",
"Conversation Timestamp": "Konuşma zaman bilgisi",
"Conversation Timestamp Description": "Sayfada gösterilir.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "无效的文件格式",
"Export from official export file": "从官方导出文件导出",
"Export from API": "从 API 导出",
"Refer": "参考",
"Available variables": "可用变量",
"Conversation Timestamp": "对话时间戳",
"Conversation Timestamp Description": "会显示在页面上。",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"Invalid File Format": "無效的檔案格式",
"Export from official export file": "從官方匯出檔案匯出",
"Export from API": "從 API 匯出",
"Refer": "參考",
"Available variables": "可用變數",
"Conversation Timestamp": "對話時間戳",
"Conversation Timestamp Description": "會顯示在頁面上。",
Expand Down
16 changes: 12 additions & 4 deletions src/ui/ExportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ConversationSelect: FC<ConversationSelectProps> = ({
)
}

type ExportSource = 'API' | 'Local'
type ExportSource = 'API' | 'Local' | 'Refer'

interface DialogContentProps {
format: string
Expand Down Expand Up @@ -121,10 +121,11 @@ const DialogContent: FC<DialogContentProps> = ({ format }) => {
}
setSelected([])
setExportSource('Local')
setLoading(false)
setLocalConversations(data)
}
fileReader.readAsText(file)
}, [t, setExportSource, setLocalConversations])
}, [t, setExportSource, setLoading, setLocalConversations])

useEffect(() => {
const off = requestQueue.on('progress', (progress) => {
Expand Down Expand Up @@ -206,7 +207,7 @@ const DialogContent: FC<DialogContentProps> = ({ format }) => {
}, [disabled, selected, localConversations, exportAllOptions, exportType, format, metaList])

const exportAll = useMemo(() => {
return exportSource === 'API' ? exportAllFromApi : exportAllFromLocal
return exportSource !== 'Local' ? exportAllFromApi : exportAllFromLocal
}, [exportSource, exportAllFromApi, exportAllFromLocal])

const deleteAll = useCallback(() => {
Expand Down Expand Up @@ -263,6 +264,13 @@ const DialogContent: FC<DialogContentProps> = ({ format }) => {
<IconUpload className="w-4 h-4" />
</button>
)}
{exportSource !== 'API' && (
<CheckBox
label={t('Refer')}
checked={exportSource === 'Refer'}
onCheckedChange={checked => setExportSource(checked ? 'Refer' : 'Local')}
/>
)}
</div>
<input
type="file"
Expand All @@ -271,7 +279,7 @@ const DialogContent: FC<DialogContentProps> = ({ format }) => {
ref={fileInputRef}
onChange={onUpload}
/>
{exportSource === 'API' && (
{exportSource !== 'Local' && (
<div className="flex items-center text-gray-600 dark:text-gray-300 flex justify-between mb-3">
{t('Export from API')}
</div>
Expand Down
Loading