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 a8b57f1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 57 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dashboard-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
echo "${{ secrets.AZURE_BLOB_STORAGE_ACCOUNT }}" >> ./web/dashboard/.env
echo "${{ secrets.AZURE_BLOB_STORAGE_SECRET }}" >> ./web/dashboard/.env
echo "${{ secrets.NEXT_AUTH_SECRET }}" >> ./web/dashboard/.env
echo "AZURE_CONTAINER_NAME=remote-components-aem-demo" >> ./web/dashboard/.env
echo "DRIZZLE_DATABASE_TYPE=neon" >> ./web/dashboard/.env
echo "DRIZZLE_DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require" >> ./web/dashboard/.env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const dynamicSlots = {
dynamiczonetwo: dynamic({}),
};

const schema = component({ name: 'TestReactHelloWorld', version: '0.0.87' }, dialogSchema, dynamicSlots);
const schema = component({ name: 'TestReactHelloWorld', version: '0.0.86' }, dialogSchema, dynamicSlots);

type Props = Output<typeof schema>

Expand Down
5 changes: 2 additions & 3 deletions web/dashboard/src/components/launches/table/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ export const columns = [
cell:
({ row }) => <div className="flex gap-2">
{row.original.new ?
<Badge variant={'success'}>{row.getValue('version').from}</Badge> :
<Badge variant={'success'}>{row.original.is_active.from}</Badge> :
row.original.is_active.to === row.original.is_active.from ?
<span className="text-muted-foreground">{row.original.is_active.to ? 'Active' : 'Inactive'}</span> :
<>
<Badge
variant={'destructive'}>{row.getValue('active').to ? 'Active' : 'Inactive'}</Badge>
<Badge variant={'destructive'}>{row.getValue('active').to ? 'Active' : 'Inactive'}</Badge>
<ArrowRight className="text-slate-300" size={20} />
<Badge variant={'success'}>{row.getValue('active').from ? 'Active' : 'Inactive'}</Badge>
</>
Expand Down
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 a8b57f1

Please sign in to comment.