Skip to content

Commit

Permalink
chore: Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Oct 19, 2024
1 parent 7e55312 commit 8396429
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 188 deletions.
8 changes: 5 additions & 3 deletions apps/frontend/src/app/[locale]/(main)/(layout)/error.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use client';

import { ErrorView } from 'vitnode-frontend/views/theme/views/error/error-view';
import { WrapperError } from 'vitnode-frontend/views/theme/views/error/wrapper-error';

export default function Error() {
return <ErrorView code="500" />;
export default function Error(
props: React.ComponentProps<typeof WrapperError>,
) {
return <WrapperError {...props} />;
}
8 changes: 5 additions & 3 deletions apps/frontend/src/app/[locale]/admin/(auth)/error.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use client';

import { ErrorView } from 'vitnode-frontend/views/theme/views/error/error-view';
import { WrapperError } from 'vitnode-frontend/views/theme/views/error/wrapper-error';

export default function Error() {
return <ErrorView code="500" />;
export default function Error(
props: React.ComponentProps<typeof WrapperError>,
) {
return <WrapperError {...props} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import {
getPaginationTool,
SearchParamsPagination,
} from '@/graphql/get-pagination-tool';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Files__Show,
Admin__Core_Files__ShowQuery,
Expand Down Expand Up @@ -36,16 +32,8 @@ export interface FilesAdvancedCoreAdminViewProps {
searchParams: Promise<SearchParamsPagination>;
}

const permission = {
plugin_code: 'core',
group: 'advanced',
permission: 'can_manage_advanced_files',
};

export const generateMetadataFilesAdvancedCoreAdmin =
async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.core.advanced.files');

return {
Expand All @@ -56,8 +44,6 @@ export const generateMetadataFilesAdvancedCoreAdmin =
export const FilesAdvancedCoreAdminView = async ({
searchParams,
}: FilesAdvancedCoreAdminViewProps) => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const variables = await getPaginationTool({
searchParams,
defaultPageSize: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import {
getPaginationTool,
SearchParamsPagination,
} from '@/graphql/get-pagination-tool';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Plugins__Show,
Admin__Core_Plugins__ShowQuery,
Expand Down Expand Up @@ -37,15 +33,7 @@ const getData = async (variables: Admin__Core_Plugins__ShowQueryVariables) => {
return data;
};

const permission = {
plugin_code: 'core',
group: 'can_manage_plugins',
permission: '',
};

export const generateMetadataPluginsAdmin = async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.core.plugins');

return {
Expand All @@ -56,8 +44,6 @@ export const generateMetadataPluginsAdmin = async (): Promise<Metadata> => {
export const PluginsAdminView = async ({
searchParams,
}: PluginsAdminViewProps) => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const variables = await getPaginationTool({
searchParams,
sortByEnum: ShowAdminPluginsSortingColumnEnum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { DateFormat } from '@/components/date-format';
import { Badge } from '@/components/ui/badge';
import { Card } from '@/components/ui/card';
import { HeaderContent } from '@/components/ui/header-content';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import { CONFIG } from '@/helpers/config-with-env';
import { redirect } from '@/navigation';
import { ExternalLink } from 'lucide-react';
Expand All @@ -25,17 +21,9 @@ interface Props {
}>;
}

const permission = {
plugin_code: 'core',
group: 'can_manage_plugins',
permission: '',
};

export async function generateMetadataDevPluginAdminLayout({
params,
}: Props): Promise<Metadata> {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const { code } = await params;
const data = await getPluginDataAdmin({ code });
if (data.admin__core_plugins__show.edges.length === 0) return {};
Expand All @@ -51,8 +39,6 @@ export async function generateMetadataDevPluginAdminLayout({
}

export const DevPluginAdminLayout = async ({ params, children }: Props) => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const { code, locale } = await params;
if (!CONFIG.node_development) redirect({ href: '/admin', locale });
const [data, t] = await Promise.all([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { Card } from '@/components/ui/card';
import { HeaderContent } from '@/components/ui/header-content';
import { fetcher } from '@/graphql/fetcher';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Email_Settings__Show,
Admin__Core_Email_Settings__ShowQuery,
Expand All @@ -27,16 +23,8 @@ const getData = async () => {
return data;
};

const permission = {
plugin_code: 'core',
group: 'settings',
permission: 'can_manage_settings_email',
};

export const generateMetadataEmailSettingsAdmin =
async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin_core.nav');

return {
Expand All @@ -45,8 +33,6 @@ export const generateMetadataEmailSettingsAdmin =
};

export const EmailSettingsAdminView = async () => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const [t, data] = await Promise.all([
getTranslations('admin.core.settings.email'),
getData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import {
getPaginationTool,
SearchParamsPagination,
} from '@/graphql/get-pagination-tool';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Email__Logs,
Admin__Core_Email__LogsQuery,
Expand All @@ -30,16 +26,8 @@ const getData = async (variables: Admin__Core_Email__LogsQueryVariables) => {
return data;
};

const permission = {
plugin_code: 'core',
group: 'settings',
permission: 'can_manage_settings_email',
};

export const generateMetadataLogsEmailSettingsAdmin =
async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.core.settings.email.logs');

return {
Expand All @@ -52,8 +40,6 @@ export const LogsEmailSettingsAdminView = async ({
}: {
searchParams: Promise<SearchParamsPagination>;
}) => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const variables = await getPaginationTool({
searchParams,
defaultPageSize: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { TranslationsProvider } from '@/components/translations-provider';
import { Card } from '@/components/ui/card';
import { HeaderContent } from '@/components/ui/header-content';
import { fetcher } from '@/graphql/fetcher';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Manifest_Metadata__Show,
Admin__Core_Manifest_Metadata__ShowQuery,
Expand All @@ -28,16 +24,8 @@ const getData = async () => {
return data;
};

const permission = {
plugin_code: 'core',
group: 'settings',
permission: 'can_manage_settings_metadata',
};

export const generateMetadataManifestMetadataCoreAdmin =
async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.core.metadata.manifest');

return {
Expand All @@ -46,8 +34,6 @@ export const generateMetadataManifestMetadataCoreAdmin =
};

export const ManifestMetadataCoreAdminView = async () => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const [t, data] = await Promise.all([
getTranslations('admin.core.metadata.manifest'),
getData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { TranslationsProvider } from '@/components/translations-provider';
import { Card } from '@/components/ui/card';
import { HeaderContent } from '@/components/ui/header-content';
import { fetcher } from '@/graphql/fetcher';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Security__Captcha__Show,
Admin__Core_Security__Captcha__ShowQuery,
Expand All @@ -24,16 +20,8 @@ const getData = async () => {
return data;
};

const permission = {
plugin_code: 'core',
group: 'settings',
permission: 'can_manage_settings_security',
};

export const generateMetadataCaptchaSecurityAdmin =
async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.core.settings.security.captcha');

return {
Expand All @@ -42,8 +30,6 @@ export const generateMetadataCaptchaSecurityAdmin =
};

export const CaptchaSecurityAdminView = async () => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const [t, data] = await Promise.all([
getTranslations('admin.core.settings.security.captcha'),
getData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,12 @@ import { TranslationsProvider } from '@/components/translations-provider';
import { Card } from '@/components/ui/card';
import { HeaderContent } from '@/components/ui/header-content';
import { getGlobalData } from '@/graphql/get-global-data';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import { Metadata } from 'next';
import { getTranslations } from 'next-intl/server';

import { ContentEditorAdmin } from './content';

const permission = {
plugin_code: 'core',
group: 'styles',
permission: 'can_manage_styles_editor',
};

export const generateMetadataEditorAdmin = async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.core.styles.editor');

return {
Expand All @@ -28,8 +16,6 @@ export const generateMetadataEditorAdmin = async (): Promise<Metadata> => {
};

export const EditorAdminView = async () => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const [t, data] = await Promise.all([
getTranslations('admin.core.styles.editor'),
getGlobalData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import {
getPaginationTool,
SearchParamsPagination,
} from '@/graphql/get-pagination-tool';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Groups__Show,
Admin__Core_Groups__ShowQuery,
Expand Down Expand Up @@ -38,16 +34,8 @@ export interface GroupsMembersAdminViewProps {
searchParams: Promise<SearchParamsPagination>;
}

const permission = {
plugin_code: 'members',
group: 'can_manage_groups',
permission: '',
};

export const generateMetadataGroupsMembersAdmin =
async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.members.groups');

return {
Expand All @@ -58,8 +46,6 @@ export const generateMetadataGroupsMembersAdmin =
export const GroupsMembersAdminView = async ({
searchParams,
}: GroupsMembersAdminViewProps) => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const variables = await getPaginationTool({
searchParams,
sortByEnum: ShowAdminGroupsSortingColumnEnum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
getPaginationTool,
SearchParamsPagination,
} from '@/graphql/get-pagination-tool';
import {
checkAdminPermissionPage,
checkAdminPermissionPageMetadata,
} from '@/graphql/get-session-admin-data';
import {
Admin__Core_Staff_Administrators__Show,
Admin__Core_Staff_Administrators__ShowQuery,
Expand All @@ -36,16 +32,8 @@ const getData = async (
return data;
};

const permission = {
plugin_code: 'members',
group: 'staff',
permission: 'can_manage_staff_administrators',
};

export const generateMetadataAdministratorsStaffAdmin =
async (): Promise<Metadata> => {
const perm = await checkAdminPermissionPageMetadata(permission);
if (perm) return perm;
const t = await getTranslations('admin.members.staff.administrators');

return {
Expand All @@ -58,8 +46,6 @@ export const AdministratorsStaffAdminView = async ({
}: {
searchParams: Promise<SearchParamsPagination>;
}) => {
const perm = await checkAdminPermissionPage(permission);
if (perm) return perm;
const variables = await getPaginationTool({
searchParams,
sortByEnum: ShowAdminStaffAdministratorsSortingColumnEnum,
Expand Down
Loading

0 comments on commit 8396429

Please sign in to comment.