|
1 |
| -import { useCallback, useState } from 'react' |
| 1 | +import { useState } from 'react' |
2 | 2 | import { useQuery } from 'react-query'
|
3 | 3 | import Card from '@/components/Card'
|
4 |
| -import { createBento, listBentos } from '@/services/bento' |
| 4 | +import { listBentos } from '@/services/bento' |
5 | 5 | import { usePage } from '@/hooks/usePage'
|
6 |
| -import { ICreateBentoSchema } from '@/schemas/bento' |
7 |
| -import BentoForm from '@/components/BentoForm' |
8 | 6 | import useTranslation from '@/hooks/useTranslation'
|
| 7 | +import { useCurrentThemeType } from '@/hooks/useCurrentThemeType' |
9 | 8 | import { Button, SIZE as ButtonSize } from 'baseui/button'
|
10 | 9 | import User from '@/components/User'
|
11 | 10 | import { Modal, ModalHeader, ModalBody } from 'baseui/modal'
|
| 11 | +import SyntaxHighlighter from 'react-syntax-highlighter' |
| 12 | +import { dark, docco } from 'react-syntax-highlighter/dist/esm/styles/hljs' |
12 | 13 | import { resourceIconMapping } from '@/consts'
|
13 | 14 | import qs from 'qs'
|
14 | 15 | import { useQ } from '@/hooks/useQ'
|
15 | 16 | import { useFetchOrganizationMembers } from '@/hooks/useFetchOrganizationMembers'
|
16 | 17 | import FilterInput from './FilterInput'
|
17 | 18 | import FilterBar from './FilterBar'
|
18 | 19 | import BentoList from './BentoList'
|
| 20 | +import Link from './Link' |
19 | 21 |
|
20 | 22 | export interface IBentoListCardProps {
|
21 | 23 | bentoRepositoryName: string
|
22 | 24 | }
|
23 | 25 |
|
24 | 26 | export default function BentoListCard({ bentoRepositoryName }: IBentoListCardProps) {
|
25 | 27 | const [page] = usePage()
|
| 28 | + const themeType = useCurrentThemeType() |
26 | 29 | const { q, updateQ } = useQ()
|
27 | 30 | const membersInfo = useFetchOrganizationMembers()
|
28 | 31 | const queryKey = `fetchBentos:${bentoRepositoryName}:${qs.stringify(page)}`
|
29 | 32 | const bentosInfo = useQuery(queryKey, () => listBentos(bentoRepositoryName, page))
|
30 | 33 | const [isCreateBentoVersionOpen, setIsCreateBentoVersionOpen] = useState(false)
|
31 |
| - const handleCreateBentoVersion = useCallback( |
32 |
| - async (data: ICreateBentoSchema) => { |
33 |
| - await createBento(bentoRepositoryName, data) |
34 |
| - await bentosInfo.refetch() |
35 |
| - setIsCreateBentoVersionOpen(false) |
36 |
| - }, |
37 |
| - [bentoRepositoryName, bentosInfo] |
38 |
| - ) |
39 | 34 | const [t] = useTranslation()
|
| 35 | + const highlightTheme = themeType === 'dark' ? dark : docco |
40 | 36 |
|
41 | 37 | return (
|
42 | 38 | <Card
|
@@ -153,7 +149,30 @@ export default function BentoListCard({ bentoRepositoryName }: IBentoListCardPro
|
153 | 149 | >
|
154 | 150 | <ModalHeader>{t('create sth', [t('version')])}</ModalHeader>
|
155 | 151 | <ModalBody>
|
156 |
| - <BentoForm onSubmit={handleCreateBentoVersion} /> |
| 152 | + <div> |
| 153 | + <p> |
| 154 | + 1. {t('Create an [API-token] and login your BentoML CLI. prefix')} |
| 155 | + <Link href='/api_tokens' target='_blank'> |
| 156 | + {t('api token')} |
| 157 | + </Link> |
| 158 | + {t('Create an [API-token] and login your BentoML CLI. suffix')} |
| 159 | + </p> |
| 160 | + <p> |
| 161 | + 2. {t('Push new Bento to Yatai with the `bentoml push` CLI command. prefix')} |
| 162 | + <SyntaxHighlighter |
| 163 | + language='bash' |
| 164 | + style={highlightTheme} |
| 165 | + customStyle={{ |
| 166 | + margin: 0, |
| 167 | + display: 'inline', |
| 168 | + padding: 2, |
| 169 | + }} |
| 170 | + > |
| 171 | + bentoml push |
| 172 | + </SyntaxHighlighter> |
| 173 | + {t('Push new Bento to Yatai with the `bentoml push` CLI command. suffix')} |
| 174 | + </p> |
| 175 | + </div> |
157 | 176 | </ModalBody>
|
158 | 177 | </Modal>
|
159 | 178 | </Card>
|
|
0 commit comments