Skip to content

Commit

Permalink
[Poke] See the list of datasource views for a given space (#9630)
Browse files Browse the repository at this point in the history
* [Poke] See the list of datasource views for a given space

Description
---
As per title

Risks
---
na

Deploy
---
front

* clean
  • Loading branch information
philipperolet authored Dec 24, 2024
1 parent 07dbff7 commit b655f50
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
31 changes: 18 additions & 13 deletions front/components/poke/data_source_views/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,32 @@ import { usePokeDataSourceViews } from "@app/poke/swr/data_source_views";

interface DataSourceViewsDataTableProps {
owner: LightWorkspaceType;
spaceId?: string;
}

function prepareDataSourceViewsForDisplay(
owner: LightWorkspaceType,
dataSourceViews: DataSourceViewType[]
dataSourceViews: DataSourceViewType[],
spaceId?: string
) {
return dataSourceViews.map((dsv) => {
return {
...dsv,
dataSourceLink: `/poke/${owner.sId}/data_sources/${dsv.dataSource.sId}`,
dataSourceName: getDisplayNameForDataSource(dsv.dataSource),
dataSourceViewLink: `/poke/${owner.sId}/spaces/${dsv.spaceId}/data_source_views/${dsv.sId}`,
editedAt: dsv.editedByUser?.editedAt ?? undefined,
editedBy: dsv.editedByUser?.fullName ?? undefined,
name: dsv.sId,
};
});
return dataSourceViews
.map((dsv) => {
return {
...dsv,
dataSourceLink: `/poke/${owner.sId}/data_sources/${dsv.dataSource.sId}`,
dataSourceName: getDisplayNameForDataSource(dsv.dataSource),
dataSourceViewLink: `/poke/${owner.sId}/spaces/${dsv.spaceId}/data_source_views/${dsv.sId}`,
editedAt: dsv.editedByUser?.editedAt ?? undefined,
editedBy: dsv.editedByUser?.fullName ?? undefined,
name: dsv.sId,
};
})
.filter((dsv) => !spaceId || dsv.spaceId === spaceId);
}

export function DataSourceViewsDataTable({
owner,
spaceId,
}: DataSourceViewsDataTableProps) {
return (
<PokeDataTableConditionalFetch
Expand All @@ -39,7 +44,7 @@ export function DataSourceViewsDataTable({
{(data) => (
<PokeDataTable
columns={makeColumnsForDataSourceViews()}
data={prepareDataSourceViewsForDisplay(owner, data)}
data={prepareDataSourceViewsForDisplay(owner, data, spaceId)}
/>
)}
</PokeDataTableConditionalFetch>
Expand Down
6 changes: 4 additions & 2 deletions front/pages/poke/[wId]/spaces/[spaceId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
import type { InferGetServerSidePropsType } from "next";
import type { ReactElement } from "react";

import { DataSourceViewsDataTable } from "@app/components/poke/data_source_views/table";
import { MembersDataTable } from "@app/components/poke/members/table";
import { ViewSpaceViewTable } from "@app/components/poke/spaces/view";
import { getMembers } from "@app/lib/api/workspace";
Expand Down Expand Up @@ -67,7 +68,7 @@ export const getServerSideProps = withSuperUserAuthRequirements<{
};
});

export default function DataSourceViewPage({
export default function SpacePage({
members,
owner,
space,
Expand All @@ -77,11 +78,12 @@ export default function DataSourceViewPage({
<ViewSpaceViewTable space={space} />
<div className="flex grow flex-col">
<MembersDataTable members={members} owner={owner} readonly />
<DataSourceViewsDataTable owner={owner} spaceId={space.sId} />
</div>
</div>
);
}

DataSourceViewPage.getLayout = (page: ReactElement) => {
SpacePage.getLayout = (page: ReactElement) => {
return <PokeLayout>{page}</PokeLayout>;
};

0 comments on commit b655f50

Please sign in to comment.