-
Notifications
You must be signed in to change notification settings - Fork 0
Contextual discovery #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Contextual discovery #624
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1ecf738
Add outline processor for discovery
underscope 972f7cb
Add filtering type
underscope fe07d4c
Emit search input
underscope 12347d8
Init Topic picker
underscope 3b02082
Add outline based discovery
underscope eaf411b
Add outline processor for discovery
underscope 9d53106
Add filtering type
underscope 979b8e0
Emit search input
underscope df17615
Init Topic picker
underscope f3bc112
Add outline based discovery
underscope 16392b8
Merge branch 'feature/contextual-discovery' of https://github.com/tai…
underscope 44ca48e
🧹
underscope 43b6364
💄
underscope 678abb9
💄
underscope 07a47c7
Merge branch 'feature/asset-lib' into feature/contextual-discovery
underscope b60e807
Merge branch 'feature/asset-lib' into feature/contextual-discovery
underscope 56f55cd
Merge branch 'feature/asset-lib' into feature/contextual-discovery
underscope 8274295
Merge branch 'feature/asset-lib' into feature/contextual-discovery
underscope f0b9ead
Merge branch 'feature/asset-lib' into feature/contextual-discovery
underscope 7b47366
Merge branch 'feature/asset-lib' into feature/contextual-discovery
underscope aba427a
💄
underscope 107dc84
💄
underscope dad7320
Merge branch 'main' into feature/contextual-discovery
underscope File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
apps/frontend/app/components/repository/Assets/Discovery/TopicPicker/TopicList.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <template> | ||
| <VList class="topic-list pa-2" density="compact"> | ||
| <template v-for="item in items" :key="item.id"> | ||
| <VListSubheader | ||
| v-if="item.isGroup" | ||
| class="text-uppercase font-weight-bold" | ||
| > | ||
| {{ item.name }} | ||
| </VListSubheader> | ||
| <VListItem | ||
| v-else | ||
| :prepend-icon="item.isLeaf | ||
| ? 'mdi-file-document-outline' | ||
| : 'mdi-folder-outline'" | ||
| :value="item.id" | ||
| class="topic-list-item" | ||
| @click="emit('topic:select', item)" | ||
| > | ||
| <VListItemTitle class="text-body-2"> | ||
| {{ item.name }} | ||
| </VListItemTitle> | ||
| <VListItemSubtitle v-if="item.parentName" class="text-caption"> | ||
| {{ item.parentName }} | ||
| </VListItemSubtitle> | ||
| </VListItem> | ||
| </template> | ||
| </VList> | ||
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import type { TopicItem } from './types'; | ||
|
|
||
| defineProps<{ | ||
| items: TopicItem[]; | ||
| }>(); | ||
|
|
||
| const emit = defineEmits<{ | ||
| 'topic:select': [topic: TopicItem]; | ||
| }>(); | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .topic-list { | ||
| overflow-y: auto; | ||
| } | ||
|
|
||
| .topic-list-item { | ||
| cursor: pointer; | ||
|
|
||
| &:hover { | ||
| background: rgba(0, 0, 0, 0.04); | ||
| } | ||
| } | ||
| </style> | ||
68 changes: 68 additions & 0 deletions
68
apps/frontend/app/components/repository/Assets/Discovery/TopicPicker/index.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <template> | ||
| <VAutocomplete | ||
| :items="items" | ||
| :model-value="modelValue?.id ?? null" | ||
| color="primary-lighten-3" | ||
| density="default" | ||
| item-title="name" | ||
| item-value="id" | ||
| label="Outline topic" | ||
| min-width="550" | ||
| max-width="550" | ||
| placeholder="Browse topics..." | ||
| prepend-inner-icon="mdi-file-tree-outline" | ||
| variant="outlined" | ||
| clearable | ||
| hide-details | ||
| @update:model-value="onSelect" | ||
| > | ||
| <template #item="{ item, props: itemProps }"> | ||
| <VListItem v-bind="itemProps" color="primary-darken-4"> | ||
| <template #prepend> | ||
| <VIcon | ||
| :icon="item.raw.isLeaf | ||
| ? 'mdi-file-document-outline' | ||
| : 'mdi-folder-outline'" | ||
| size="small" | ||
| /> | ||
| </template> | ||
| <VListItemSubtitle v-if="item.raw.breadcrumb" class="text-caption"> | ||
| {{ item.raw.breadcrumb }} | ||
| </VListItemSubtitle> | ||
| </VListItem> | ||
| </template> | ||
| <template v-if="modelValue?.breadcrumb" #selection> | ||
| <div> | ||
| <div class="text-body-2">{{ modelValue.name }}</div> | ||
| <div class="text-caption text-primary-lighten-3"> | ||
| {{ modelValue.breadcrumb }} | ||
| </div> | ||
| </div> | ||
| </template> | ||
| </VAutocomplete> | ||
| </template> | ||
|
|
||
| <script lang="ts" setup> | ||
| import type { TopicItem } from './types'; | ||
| import { useOutlineTree } from './useOutlineTree'; | ||
|
|
||
| defineProps<{ | ||
| modelValue: TopicItem | null; | ||
| }>(); | ||
|
|
||
| const emit = defineEmits<{ | ||
| 'update:modelValue': [topic: TopicItem | null]; | ||
| 'topic:clear': []; | ||
| }>(); | ||
|
|
||
| const { items } = useOutlineTree(); | ||
|
|
||
| function onSelect(id: number | null) { | ||
| if (!id) { | ||
| emit('topic:clear'); | ||
| return; | ||
| } | ||
| const topic = items.value.find((it) => it.id === id); | ||
| if (topic) emit('update:modelValue', topic); | ||
| } | ||
| </script> |
12 changes: 12 additions & 0 deletions
12
apps/frontend/app/components/repository/Assets/Discovery/TopicPicker/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export interface TopicItem { | ||
| id: number; | ||
| name: string; | ||
| parentName?: string; | ||
| // Full ancestor breadcrumb (e.g. "Module 1 / Sub-module") | ||
| breadcrumb: string; | ||
| isGroup: boolean; | ||
| isLeaf: boolean; | ||
| depth: number; | ||
| // Full context path for building search queries. | ||
| context: string[]; | ||
| } |
61 changes: 61 additions & 0 deletions
61
apps/frontend/app/components/repository/Assets/Discovery/TopicPicker/useOutlineTree.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { activity as activityUtils } from '@tailor-cms/utils'; | ||
| import { schema as schemaConfig } from '@tailor-cms/config'; | ||
|
|
||
| import { useCurrentRepository } from '@/stores/current-repository'; | ||
| import type { TopicItem } from './types'; | ||
|
|
||
| const buildTopicMeta = ( | ||
| activity: any, | ||
| activityCollection: any[], | ||
| repositoryName: string, | ||
| ): TopicItem => { | ||
| const name = activity.data?.name || ''; | ||
| const isLeaf = schemaConfig.isEditable(activity.type); | ||
| const ancestors = activityUtils.getAncestors(activityCollection, activity); | ||
| const ancestorNames = ancestors.map((a: any) => a.data?.name).filter(Boolean); | ||
| return { | ||
| id: activity.id, | ||
| name, | ||
| isGroup: !isLeaf, | ||
| parentName: ancestorNames.at(-1), | ||
| breadcrumb: ancestorNames.toReversed().join(' / '), | ||
| isLeaf, | ||
| depth: ancestors.length, | ||
| context: [name, ...ancestorNames, repositoryName].filter(Boolean), | ||
| }; | ||
| }; | ||
|
|
||
| function flattenTree(nodes: any[]): TopicItem[] { | ||
| const result: TopicItem[] = []; | ||
| for (const node of nodes) { | ||
| if (node.topicMeta) result.push(node.topicMeta); | ||
| if (node.children?.length) { | ||
| result.push(...flattenTree(node.children)); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Derives a flat topic list from the repository outline. | ||
| * Uses shared toTreeFormat for hierarchy, schemaConfig.isEditable | ||
| * for leaf detection, and getAncestors for parent context. | ||
| */ | ||
| export function useOutlineTree() { | ||
| const store = useCurrentRepository(); | ||
| const hasOutline = computed(() => store.outlineActivities.length > 0); | ||
|
|
||
| const items = computed<TopicItem[]>(() => { | ||
| const activities = store.outlineActivities as any[]; | ||
| if (!activities.length) return []; | ||
| const repo = store.repository; | ||
| const tree = activityUtils.toTreeFormat(activities, { | ||
| processNodeFn: (activity: any) => ({ | ||
| topicMeta: buildTopicMeta(activity, activities, repo?.name || ''), | ||
| }), | ||
| }); | ||
| return flattenTree(tree); | ||
| }); | ||
|
|
||
| return { hasOutline, items }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.