-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #449 from aXenDeveloper/admin/diagnostic_tools
feat(frontend): Add diagnostic tools view in AdminCP
- Loading branch information
Showing
16 changed files
with
195 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
title: Diagnostic Tools | ||
description: How to use diagnostic tools to debug and monitor your app. | ||
--- |
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
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
7 changes: 7 additions & 0 deletions
7
packages/frontend/src/views/admin/views/core/diagnostic/actions/actions.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,7 @@ | ||
'use client'; | ||
|
||
import { ClearCacheActionDiagnostic } from './clear_cache/clear_cache'; | ||
|
||
export const ActionsDiagnosticTools = () => { | ||
return <ClearCacheActionDiagnostic />; | ||
}; |
40 changes: 40 additions & 0 deletions
40
packages/frontend/src/views/admin/views/core/diagnostic/actions/clear_cache/clear_cache.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 { EraserIcon } from 'lucide-react'; | ||
import { useTranslations } from 'next-intl'; | ||
import React from 'react'; | ||
|
||
import { | ||
AlertDialog, | ||
AlertDialogContent, | ||
AlertDialogTrigger, | ||
} from '@/components/ui/alert-dialog'; | ||
import { Button } from '@/components/ui/button'; | ||
import { Loader } from '@/components/ui/loader'; | ||
|
||
const Content = React.lazy(async () => | ||
import('./content').then(module => ({ | ||
default: module.ContentClearCacheActionDiagnostic, | ||
})), | ||
); | ||
|
||
export const ClearCacheActionDiagnostic = () => { | ||
const t = useTranslations('admin.core.diagnostic.clear_cache'); | ||
|
||
return ( | ||
<> | ||
<AlertDialog> | ||
<AlertDialogTrigger asChild> | ||
<Button> | ||
<EraserIcon /> | ||
{t('title')} | ||
</Button> | ||
</AlertDialogTrigger> | ||
|
||
<AlertDialogContent> | ||
<React.Suspense fallback={<Loader />}> | ||
<Content /> | ||
</React.Suspense> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
</> | ||
); | ||
}; |
42 changes: 42 additions & 0 deletions
42
packages/frontend/src/views/admin/views/core/diagnostic/actions/clear_cache/content.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,42 @@ | ||
import { useTranslations } from 'next-intl'; | ||
import { toast } from 'sonner'; | ||
|
||
import { | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
} from '@/components/ui/alert-dialog'; | ||
import { Button } from '@/components/ui/button'; | ||
import { mutationApi } from './hooks/mutation-api'; | ||
|
||
export const ContentClearCacheActionDiagnostic = () => { | ||
const t = useTranslations('admin.core.diagnostic.clear_cache'); | ||
const tCore = useTranslations('core'); | ||
|
||
return ( | ||
<> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle>{tCore('are_you_sure')}</AlertDialogTitle> | ||
<AlertDialogDescription>{t('desc')}</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel>{tCore('cancel')}</AlertDialogCancel> | ||
<AlertDialogAction asChild> | ||
<Button | ||
variant="destructive" | ||
onClick={async () => { | ||
await mutationApi(); | ||
|
||
toast.success(t('success')); | ||
}} | ||
> | ||
{t('confirm')} | ||
</Button> | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
.../frontend/src/views/admin/views/core/diagnostic/actions/clear_cache/hooks/mutation-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,7 @@ | ||
'use server'; | ||
|
||
import { revalidatePath } from 'next/cache'; | ||
|
||
export const mutationApi = async () => { | ||
revalidatePath('/', 'layout'); | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/frontend/src/views/admin/views/core/diagnostic/diagnostic-tools-view.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,24 @@ | ||
import { Metadata } from 'next'; | ||
import { useTranslations } from 'next-intl'; | ||
import { getTranslations } from 'next-intl/server'; | ||
|
||
import { HeaderContent } from '@/components/ui/header-content'; | ||
import { ActionsDiagnosticTools } from './actions/actions'; | ||
|
||
export const generateMetadataDiagnosticAdmin = async (): Promise<Metadata> => { | ||
const t = await getTranslations('admin.core.diagnostic'); | ||
|
||
return { | ||
title: t('title'), | ||
}; | ||
}; | ||
|
||
export const DiagnosticToolsView = () => { | ||
const t = useTranslations('admin.core.diagnostic'); | ||
|
||
return ( | ||
<HeaderContent h1={t('title')} desc={t('desc')}> | ||
<ActionsDiagnosticTools /> | ||
</HeaderContent> | ||
); | ||
}; |
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