Skip to content

Commit

Permalink
fix: remove group to display all the components
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com>
  • Loading branch information
fgmadeira committed Sep 30, 2024
1 parent 3420efb commit 8ea1fad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function ComponentsDialog({ components, environment, project, environment

function handleEnvironment(environmentId: string | null) {
return () => {
const params = new URLSearchParams(searchParams);
const params = new URLSearchParams(searchParams.toString());
if (environmentId) {
params.set('env', environmentId);
}
Expand All @@ -78,7 +78,7 @@ export function ComponentsDialog({ components, environment, project, environment

function handleLaunch(environmentId: string | null) {
return () => {
const params = new URLSearchParams(searchParams);
const params = new URLSearchParams(searchParams.toString());
if (environmentId) {
params.set('env', environmentId);
}
Expand Down
54 changes: 3 additions & 51 deletions web/dashboard/src/data/projects/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export async function getEnvironmentsById(
...getTableColumns(environments),
components: sql`COALESCE(
jsonb_agg(
jsonb_build_object(
DISTINCT jsonb_build_object(
'id', ${components.id},
'name', ${components.name},
'title', ${components.title},
Expand All @@ -155,24 +155,15 @@ export async function getEnvironmentsById(
eq(componentVersions.id, projectComponentConfig.component_version)
)
.groupBy(
environments.id,
components.id,
componentVersions.version,
projectComponentConfig.id,
projectComponentConfig.is_active
environments.id
)
.where(
and(
eq(environments.id, id),
await userIsMember(userId, environments.project_id)
)
)
.orderBy(
sql`${projectComponentConfig.is_active} DESC NULLS LAST`,
sql`${componentVersions.version} NULLS LAST`,
components.name
);


const safe = environmentWithComponentsSchema.safeParse(select[0]);
if (!safe.success) {
return actionZodError(
Expand All @@ -188,45 +179,6 @@ export async function getEnvironmentsById(
}
}

export async function getProjectsWithComponents(
userId: string | undefined | null
): ActionResponse<ProjectWithComponent[]> {
if (!userId) {
return actionError('No user provided.');
}

try {
const select = await db.query.projects.findMany({
where: userIsMember(userId),
with: {
components: {
columns: {
is_active: true,
component_version: true
},
with: {
component: true,
version: true
}
}
}
});

const safe = z.array(projectWithComponentSchema).safeParse(select);
if (!safe.success) {
return actionZodError(
'There\'s an issue with the project records.',
safe.error
);
}

return actionSuccess(safe.data);
} catch (error) {
console.error(error);
return actionError('Failed to fetch project from database.');
}
}

export async function getEnvironmentComponents(
id: string | undefined | null,
userId: string | undefined | null
Expand Down

0 comments on commit 8ea1fad

Please sign in to comment.