-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ai.notebooks): backup tabs (#14358)
* feat(ai.notebooks): backup tabs * feat(ai.notebooks): fix sonar issue REF:DATATR-1640 * Feat/pci ai notebooks modal tracking (#14553) * feat(ai.notebooks): modal and tracking * feat(ai.notebooks): resolve conflit & fix sonar issue * feat(ai.notebooks): fix pr comments * feat(ai.notebooks): fix pr comments REF:DATATR-1744 Signed-off-by: Arthur Bullet <[email protected]>
- Loading branch information
Showing
59 changed files
with
1,079 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-ai-notebooks/public/translations/pci-ai-notebooks/notebooks/notebook/Messages_fr_FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...books/public/translations/pci-ai-notebooks/notebooks/notebook/backups/Messages_fr_FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"breadcrumb": "Backups", | ||
"title": "Sauvegardes", | ||
"description": "Vous trouverez ci-dessous la liste de vos sauvegardes. Vous pouvez créer un nouveau notebook à partir du chacune d'entre elles", | ||
"tableHeaderId": "Id", | ||
"tableHeaderCreationDate": "Date de création", | ||
"tableHeaderUpdateDate": "Date de modification", | ||
"backupDropdownMenuLabel": "Action", | ||
"tableActionFork": "Fork", | ||
"forkBackupTitle": "Commander un notebook depuis un backup", | ||
"forkBackupDescription": "Utiliser le backup {{id}} créé le {{date}} pour commander un nouveau notebook?", | ||
"forkButtonCancel": "Annuler", | ||
"forkBackupButtonConfirm": "Commander", | ||
"forkToastErrorTitle": "Une erreur est survenue", | ||
"forkToastSuccessTitle": "Succés", | ||
"forkToastSuccessDescription": "votre notebook a été créé avec succès" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/manager/apps/pci-ai-notebooks/src/components/route-modal/RouteModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
} from '../ui/dialog'; | ||
import { Skeleton } from '../ui/skeleton'; | ||
|
||
interface RouteModalProps { | ||
backUrl?: string; | ||
isLoading?: boolean; | ||
children: React.ReactNode | React.ReactNode[]; | ||
onClose?: () => void; | ||
} | ||
const RouteModal = ({ | ||
backUrl, | ||
isLoading = false, | ||
children, | ||
onClose, | ||
}: RouteModalProps) => { | ||
const navigate = useNavigate(); | ||
const onOpenChange = (open: boolean) => { | ||
if (!open) { | ||
if (onClose) { | ||
onClose(); | ||
return; | ||
} | ||
if (backUrl) navigate(backUrl); | ||
} | ||
}; | ||
|
||
return ( | ||
<Dialog defaultOpen onOpenChange={onOpenChange}> | ||
{isLoading ? ( | ||
<DialogContent> | ||
<DialogHeader> | ||
<Skeleton className="w-3/5 h-5" /> | ||
</DialogHeader> | ||
<DialogDescription className="flex flex-col gap-2"> | ||
<Skeleton className="w-4/5 h-4" /> | ||
<Skeleton className="w-100 h-4" /> | ||
<Skeleton className="w-2/3 h-4" /> | ||
<Skeleton className="w-4/5 h-4" /> | ||
<Skeleton className="w-1/3 h-4" /> | ||
<Skeleton className="w-4/5 h-4" /> | ||
</DialogDescription> | ||
<DialogFooter className="flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 flex justify-end mt-2"> | ||
<Skeleton className="w-20 h-10" /> | ||
<Skeleton className="w-20 h-10" /> | ||
</DialogFooter> | ||
</DialogContent> | ||
) : ( | ||
children | ||
)} | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default RouteModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 1 addition & 10 deletions
11
packages/manager/apps/pci-ai-notebooks/src/configuration/tracking.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,2 @@ | ||
const APP_TRACKING_PREFIX = 'PublicCloud::databases_analytics::databases'; | ||
export const APP_TRACKING_PREFIX = 'PublicCloud::ai::notebooks'; | ||
export const PCI_LEVEL2 = '86'; | ||
export const TRACKING = { | ||
onboarding: { | ||
page: () => `${APP_TRACKING_PREFIX}::databases::onboarding`, | ||
createDatabaseClick: () => | ||
`${APP_TRACKING_PREFIX}::page::button::create_databases`, | ||
guideClick: (guideName: string) => | ||
`${APP_TRACKING_PREFIX}::page::tile-tutorial::go-to-${guideName}`, | ||
}, | ||
}; |
34 changes: 34 additions & 0 deletions
34
packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/backups/backups.api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { apiClient } from '@ovh-ux/manager-core-api'; | ||
import * as ai from '@/types/cloud/project/ai'; | ||
import { NotebookData } from '@/data/api'; | ||
|
||
export const getBackups = async ({ projectId, notebookId }: NotebookData) => | ||
apiClient.v6 | ||
.get(`/cloud/project/${projectId}/ai/notebook/${notebookId}/backup`) | ||
.then((res) => res.data as ai.notebook.Backup[]); | ||
|
||
export interface BackupData extends NotebookData { | ||
backupId: string; | ||
} | ||
|
||
export const getBackup = async ({ | ||
projectId, | ||
notebookId, | ||
backupId, | ||
}: BackupData) => | ||
apiClient.v6 | ||
.get( | ||
`/cloud/project/${projectId}/ai/notebook/${notebookId}/backup/${backupId}`, | ||
) | ||
.then((res) => res.data as ai.notebook.Backup); | ||
|
||
export const forkBackup = async ({ | ||
projectId, | ||
notebookId, | ||
backupId, | ||
}: BackupData) => | ||
apiClient.v6 | ||
.post( | ||
`/cloud/project/${projectId}/ai/notebook/${notebookId}/backup/${backupId}/fork`, | ||
) | ||
.then((res) => res.data as ai.notebook.Notebook); |
40 changes: 40 additions & 0 deletions
40
...es/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/backups/useForkBackup.hook.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { useParams } from 'react-router-dom'; | ||
import { AIError } from '@/data/api'; | ||
import * as ai from '@/types/cloud/project/ai'; | ||
import { | ||
BackupData, | ||
forkBackup, | ||
} from '@/data/api/ai/notebook/backups/backups.api'; | ||
|
||
interface UseForkBackup { | ||
onError: (cause: AIError) => void; | ||
onSuccess: (notebook: ai.notebook.Notebook) => void; | ||
} | ||
|
||
export function useForkBackup({ onError, onSuccess }: UseForkBackup) { | ||
const queryClient = useQueryClient(); | ||
const { projectId } = useParams(); | ||
const mutation = useMutation({ | ||
mutationFn: (forkInfo: BackupData) => { | ||
return forkBackup(forkInfo); | ||
}, | ||
onError, | ||
onSuccess: (data) => { | ||
// invalidate notebooks list to avoid displaying | ||
// old list | ||
queryClient.invalidateQueries({ | ||
queryKey: [projectId, 'ai/notebook'], | ||
refetchType: 'none', | ||
}); | ||
onSuccess(data); | ||
}, | ||
}); | ||
|
||
return { | ||
forkBackup: (forkInfo: BackupData) => { | ||
return mutation.mutate(forkInfo); | ||
}, | ||
...mutation, | ||
}; | ||
} |
26 changes: 26 additions & 0 deletions
26
...ges/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/backups/useGetBackup.hook.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'; | ||
import * as ai from '@/types/cloud/project/ai'; | ||
import { useQueryImmediateRefetch } from '@/hooks/api/useImmediateRefetch'; | ||
import { AIError } from '@/data/api'; | ||
import { getBackup } from '@/data/api/ai/notebook/backups/backups.api'; | ||
|
||
export function useGetBackup( | ||
projectId: string, | ||
notebookId: string, | ||
backupId: string, | ||
options: Omit<QueryObserverOptions, 'queryKey'> = {}, | ||
) { | ||
const queryKey = [ | ||
projectId, | ||
'ai', | ||
'notebook', | ||
notebookId, | ||
'backup', | ||
backupId, | ||
]; | ||
return useQueryImmediateRefetch({ | ||
queryKey, | ||
queryFn: () => getBackup({ projectId, notebookId, backupId }), | ||
...options, | ||
}) as UseQueryResult<ai.notebook.Backup, AIError>; | ||
} |
18 changes: 18 additions & 0 deletions
18
...es/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/backups/useGetBackups.hook.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'; | ||
import * as ai from '@/types/cloud/project/ai'; | ||
import { useQueryImmediateRefetch } from '@/hooks/api/useImmediateRefetch'; | ||
import { AIError } from '@/data/api'; | ||
import { getBackups } from '@/data/api/ai/notebook/backups/backups.api'; | ||
|
||
export function useGetBackups( | ||
projectId: string, | ||
notebookId: string, | ||
options: Omit<QueryObserverOptions, 'queryKey'> = {}, | ||
) { | ||
const queryKey = [projectId, 'ai', 'notebook', notebookId, 'backup']; | ||
return useQueryImmediateRefetch({ | ||
queryKey, | ||
queryFn: () => getBackups({ projectId, notebookId }), | ||
...options, | ||
}) as UseQueryResult<ai.notebook.Backup[], AIError>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.