Skip to content

Commit c17a45f

Browse files
authored
Ensure that templates on home only occupy 1 row (#4546)
1 parent b64a426 commit c17a45f

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

packages/app/src/app/pages/NewDashboard/Components/VariableGrid/index.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,17 @@ export const VariableGrid = ({
310310
'skeleton-row',
311311
'blank-row-fill',
312312
'new-sandbox',
313+
'template',
314+
'sandbox',
313315
].includes(item.type)
314316
) {
315317
filledItems.push({ ...item, viewMode });
316318
}
317319

318320
if (item.type === 'header') {
319-
if (columnCount === 1) filledItems.push(item);
320-
else {
321+
if (columnCount === 1) {
322+
filledItems.push(item);
323+
} else {
321324
const { showMoreLink, showMoreLabel, ...fields } = item;
322325
filledItems.push(fields);
323326
let blanks = columnCount - 1;
@@ -333,7 +336,25 @@ export const VariableGrid = ({
333336
}
334337
} else if (item.type === 'new-sandbox' && viewMode === 'grid') {
335338
filledItems.push(item);
336-
} else if (item.type === 'sandbox') {
339+
} else if (item.type === 'sandbox' || item.type === 'template') {
340+
if (
341+
item.type === 'template' &&
342+
item.optional &&
343+
viewMode === 'grid'
344+
) {
345+
// If it's optional we don't show it if we're on the second row already
346+
const previousRowItem = items[index - columnCount];
347+
348+
if (
349+
previousRowItem?.type === 'template' ||
350+
previousRowItem?.type === 'new-sandbox'
351+
) {
352+
// Don't add if this one is optional and we're on the second row
353+
return;
354+
}
355+
}
356+
filledItems.push(item);
357+
337358
const nextItem = items[index + 1];
338359
if (nextItem && nextItem.type === 'header') {
339360
const currentIndex = filledItems.length - 1;

packages/app/src/app/pages/NewDashboard/Content/routes/Home/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Home = () => {
2626
}, [actions.dashboard, activeTeam]);
2727

2828
const templates: DashboardGridItem[] = (sandboxes.TEMPLATE_HOME || []).map(
29-
template => {
29+
(template, i) => {
3030
const { sandbox, ...templateValues } = template;
3131

3232
const dashboardTemplate: DashboardTemplate = {
@@ -35,6 +35,7 @@ export const Home = () => {
3535
template: templateValues,
3636
autoFork: true,
3737
noDrag: true,
38+
optional: i >= 3,
3839
};
3940

4041
return dashboardTemplate;

packages/app/src/app/pages/NewDashboard/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export type DashboardTemplate = {
3333
};
3434
noDrag?: boolean;
3535
autoFork?: boolean;
36+
/**
37+
* Whether this column should be hidden if it's on the second row of subsequent templates
38+
*/
39+
optional?: boolean;
3640
};
3741

3842
export type DashboardFolder = DELETE_ME_COLLECTION &

0 commit comments

Comments
 (0)