-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add system vault navigation * Move DataSourceOrView to type.
- Loading branch information
Showing
5 changed files
with
194 additions
and
12 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
78 changes: 78 additions & 0 deletions
78
.../pages/w/[wId]/data-sources/vaults/[vaultId]/categories/[category]/data_sources/index.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,78 @@ | ||
import type { | ||
DataSourceOrViewCategory, | ||
UserType, | ||
VaultType, | ||
} from "@dust-tt/types"; | ||
import { isDataSourceOrViewCategory } from "@dust-tt/types"; | ||
import type { InferGetServerSidePropsType } from "next"; | ||
import type { ReactElement } from "react"; | ||
|
||
import type { VaultLayoutProps } from "@app/components/vaults/VaultLayout"; | ||
import { VaultLayout } from "@app/components/vaults/VaultLayout"; | ||
import config from "@app/lib/api/config"; | ||
import { withDefaultUserAuthRequirements } from "@app/lib/iam/session"; | ||
import { VaultResource } from "@app/lib/resources/vault_resource"; | ||
|
||
export const getServerSideProps = withDefaultUserAuthRequirements< | ||
VaultLayoutProps & { | ||
category: DataSourceOrViewCategory; | ||
user: UserType; | ||
vault: VaultType; | ||
} | ||
>(async (context, auth) => { | ||
const owner = auth.getNonNullableWorkspace(); | ||
const user = auth.getNonNullableUser(); | ||
const subscription = auth.subscription(); | ||
|
||
if (!subscription) { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
|
||
const vault = await VaultResource.fetchById( | ||
auth, | ||
context.query.vaultId as string | ||
); | ||
if (!vault) { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
|
||
const dataSourceOrViewCategory = context.query.category; | ||
if ( | ||
typeof dataSourceOrViewCategory !== "string" || | ||
!isDataSourceOrViewCategory(dataSourceOrViewCategory) | ||
) { | ||
return { | ||
notFound: true, | ||
}; | ||
} | ||
|
||
return { | ||
props: { | ||
category: dataSourceOrViewCategory, | ||
gaTrackingId: config.getGaTrackingId(), | ||
owner, | ||
subscription, | ||
user, | ||
vault: vault.toJSON(), | ||
}, | ||
}; | ||
}); | ||
|
||
export default function Vault({ | ||
category, | ||
vault, | ||
}: InferGetServerSidePropsType<typeof getServerSideProps>) { | ||
return ( | ||
<> | ||
Manage {category} connections in vault {vault.name} | ||
</> | ||
); | ||
} | ||
|
||
Vault.getLayout = (page: ReactElement, pageProps: any) => { | ||
return <VaultLayout pageProps={pageProps}>{page}</VaultLayout>; | ||
}; |
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