hidden resource
This commit is contained in:
@@ -24,6 +24,10 @@ export const ConfigContext = React.createContext<AppConfig | null>(null);
|
||||
function Dashboard({ basePath }: { basePath: string }) {
|
||||
const config = React.useContext(ConfigContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const resources = config?.resources || [];
|
||||
const visibleResources = resources.filter((res) => !res.hidden);
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Typography variant="h4" gutterBottom>
|
||||
@@ -41,7 +45,7 @@ function Dashboard({ basePath }: { basePath: string }) {
|
||||
mt: 4,
|
||||
}}
|
||||
>
|
||||
{config?.resources.map((res) => (
|
||||
{visibleResources.map((res) => (
|
||||
<Paper
|
||||
key={res.name}
|
||||
sx={{
|
||||
@@ -69,6 +73,9 @@ function AdminApp({ basePath }: { basePath: string }) {
|
||||
const config = React.useContext(ConfigContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const resources = config?.resources || [];
|
||||
const visibleResources = resources.filter((res) => !res.hidden);
|
||||
|
||||
if (!currentUser) {
|
||||
return (
|
||||
<AuthPage
|
||||
@@ -89,7 +96,7 @@ function AdminApp({ basePath }: { basePath: string }) {
|
||||
username={currentUser.username}
|
||||
onLogout={logout}
|
||||
onSelectResource={(name) => navigate(`/admin/${name}`)}
|
||||
resources={config?.resources || []}
|
||||
resources={visibleResources}
|
||||
>
|
||||
<Routes>
|
||||
<Route path="/" element={<Dashboard basePath={basePath} />} />
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface ResourceConfig {
|
||||
primaryKey: string;
|
||||
fields: Record<string, ResourceField>;
|
||||
pagination?: boolean;
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
export interface AppConfig {
|
||||
|
||||
@@ -12,4 +12,5 @@ export interface FieldOverride {
|
||||
export interface ResourceOverride {
|
||||
fields?: Record<string, FieldOverride>;
|
||||
pagination?: boolean;
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ export async function loadConfigFromOpenApi(baseUrl: string, configuration: Reco
|
||||
primaryKey: "id", // Strict default, no heuristics
|
||||
fields,
|
||||
pagination: resourceOverride.pagination,
|
||||
hidden: resourceOverride.hidden,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user