mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-14 23:21:08 +00:00
fix(web): reset token dialog state on reopen, fix pagination and download button
- Reset form fields and mutation state when create-token dialog reopens - Fix delete pagination: check items.length === 0 (post-delete) instead of 1 - Restrict skill download to PUBLISHED versions only
This commit is contained in:
parent
bd8ef13cbb
commit
bd86d51f4e
3 changed files with 15 additions and 3 deletions
|
|
@ -114,7 +114,18 @@ export function CreateTokenDialog({ children, existingNames = [] }: CreateTokenD
|
|||
const minDateTime = toLocalDateTimeInputValue(new Date())
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<Dialog open={open} onOpenChange={(nextOpen) => {
|
||||
if (nextOpen) {
|
||||
setCreatedToken(null)
|
||||
setName('')
|
||||
setNameError(null)
|
||||
setExpirationMode('never')
|
||||
setCustomExpiresAt('')
|
||||
setExpiresAtError(null)
|
||||
createMutation.reset()
|
||||
}
|
||||
setOpen(nextOpen)
|
||||
}}>
|
||||
<DialogTrigger asChild>{children}</DialogTrigger>
|
||||
<DialogContent>
|
||||
{!createdToken ? (
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ export function TokenList() {
|
|||
return { previousPages }
|
||||
},
|
||||
onSuccess: () => {
|
||||
if (tokenPage && tokenPage.items.length === 1 && page > 0) {
|
||||
if (tokenPage && tokenPage.items.length === 0 && page > 0) {
|
||||
setPage(page - 1)
|
||||
}
|
||||
setDeleteDialog({ open: false })
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ export function SkillDetailPage() {
|
|||
const governanceVisible = hasRole('SKILL_ADMIN') || hasRole('SUPER_ADMIN')
|
||||
const isPendingPreview = skill?.viewingVersionStatus === 'PENDING_REVIEW'
|
||||
const canInteract = skill?.canInteract ?? true
|
||||
const isVersionDownloadable = selectedVersionEntry?.status === 'PUBLISHED'
|
||||
|
||||
const refreshSkill = () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['skills', namespace, slug] })
|
||||
|
|
@ -690,7 +691,7 @@ export function SkillDetailPage() {
|
|||
variant="outline"
|
||||
size="lg"
|
||||
onClick={handleDownload}
|
||||
disabled={!selectedVersionEntry || skill.status === 'ARCHIVED' || isPendingPreview}
|
||||
disabled={!selectedVersionEntry || skill.status === 'ARCHIVED' || !isVersionDownloadable}
|
||||
>
|
||||
<svg className="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue