Skip to content

Commit 8d40eb1

Browse files
committed
feat: manage showAggregateTabs from CDP admin, default false + backfill curated
- Replaces the earlier hand-written migration with one scaffolded via ./scripts/cli scaffold create-migration, per repo convention. - showAggregateTabs now defaults to false for all collections, then backfills to true for curated (LF Foundation) collections only (ssoUserId IS NULL) - the tab-gating logic lives entirely in this column now, not split between it and a CURATED type check on the insights frontend. - Adds an editable "Show aggregate tabs" toggle to the CDP admin collection add/edit form, defaulting to true for new collections (admin-created collections are always curated), following the exact same DAL/model/form pattern already used for the sibling starred field. Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent 2fdaf56 commit 8d40eb1

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

backend/src/database/migrations/V1782500000__addShowAggregateTabsColumnToCollectionsTable.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Add the showAggregateTabs column to the collections table, defaulting to false.
2+
ALTER TABLE collections
3+
ADD COLUMN "showAggregateTabs" boolean DEFAULT false NOT NULL;
4+
5+
-- Only LF Foundation (curated) collections get the in-depth aggregate tabs by default.
6+
-- ssoUserId is only set for community/user-curated collections (see V1772438175), so
7+
-- ssoUserId IS NULL identifies curated collections.
8+
UPDATE collections
9+
SET "showAggregateTabs" = true
10+
WHERE "ssoUserId" IS NULL;

frontend/src/modules/admin/modules/collections/components/lf-collection-add.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@
186186
</lf-field>
187187
</article>
188188
</div>
189+
190+
<!-- Show aggregate tabs -->
191+
<article class="mb-6">
192+
<lf-field label-text="Show aggregate tabs">
193+
<div class="flex items-center gap-2">
194+
<lf-switch v-model="form.showAggregateTabs" size="small" />
195+
<span class="text-2xs text-gray-400">Show in-depth aggregate metric tabs on the public collection page</span>
196+
</div>
197+
</lf-field>
198+
</article>
189199
</div>
190200
<lf-collection-add-projects-tab
191201
v-if="activeTab === 'projects'"
@@ -221,6 +231,7 @@ import LfTabs from '@/ui-kit/tabs/Tabs.vue';
221231
import LfTab from '@/ui-kit/tabs/Tab.vue';
222232
import LfInput from '@/ui-kit/input/Input.vue';
223233
import LfTextarea from '@/ui-kit/textarea/Textarea.vue';
234+
import LfSwitch from '@/ui-kit/switch/Switch.vue';
224235
import LfField from '@/ui-kit/field/Field.vue';
225236
import LfFieldMessages from '@/ui-kit/field-messages/FieldMessages.vue';
226237
@@ -260,6 +271,7 @@ const form = reactive<CollectionFormModel>({
260271
color: '',
261272
projects: [],
262273
starred: false,
274+
showAggregateTabs: true,
263275
});
264276
265277
const rules = {
@@ -327,6 +339,7 @@ const onSubmit = () => {
327339
starred: project?.starred || false,
328340
})),
329341
starred: !!form.starred,
342+
showAggregateTabs: !!form.showAggregateTabs,
330343
categoryId: form.categoryId,
331344
slug: form.name.toLowerCase().replace(/ /g, '-'),
332345
};

frontend/src/modules/admin/modules/collections/models/collection.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface CollectionModel {
1414
projects: InsightsProjectModel[];
1515
category: Category & {categoryGroupType: string, categoryGroupName: string};
1616
starred?: boolean;
17+
showAggregateTabs?: boolean;
1718
}
1819

1920
export interface CollectionRequest {
@@ -25,6 +26,7 @@ export interface CollectionRequest {
2526
color?: string;
2627
slug: string;
2728
starred: boolean;
29+
showAggregateTabs: boolean;
2830
projects: {
2931
id: string;
3032
starred: boolean;
@@ -40,4 +42,5 @@ export interface CollectionFormModel {
4042
color: string;
4143
projects: InsightsProjectModel[];
4244
starred: boolean;
45+
showAggregateTabs: boolean;
4346
}

services/libs/data-access-layer/src/collections/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface ICreateCollection {
2121
name: string
2222
slug?: string
2323
starred: boolean
24+
showAggregateTabs?: boolean
2425
isPrivate?: boolean
2526
ssoUserId?: string | null
2627
logoUrl?: string | null
@@ -93,6 +94,7 @@ export enum CollectionField {
9394
SLUG = 'slug',
9495
SSO_USER_ID = 'ssoUserId',
9596
STARRED = 'starred',
97+
SHOW_AGGREGATE_TABS = 'showAggregateTabs',
9698
UPDATED_AT = 'updatedAt',
9799
DELETED_AT = 'deletedAt',
98100
}
@@ -144,12 +146,13 @@ export async function createCollection(
144146
logoUrl: null,
145147
imageUrl: null,
146148
color: null,
149+
showAggregateTabs: true,
147150
...collection,
148151
}
149152
return qx.selectOne(
150153
`
151-
INSERT INTO collections (name, description, slug, "categoryId", starred, "logoUrl", "imageUrl", color)
152-
VALUES ($(name), $(description), $(slug), $(categoryId), $(starred), $(logoUrl), $(imageUrl), $(color))
154+
INSERT INTO collections (name, description, slug, "categoryId", starred, "logoUrl", "imageUrl", color, "showAggregateTabs")
155+
VALUES ($(name), $(description), $(slug), $(categoryId), $(starred), $(logoUrl), $(imageUrl), $(color), $(showAggregateTabs))
153156
RETURNING *
154157
`,
155158
data,

0 commit comments

Comments
 (0)