Skip to content
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

refactor: add support for new abstractions at the workspace level #12

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/smart/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</template>

<script setup lang="ts" generic="T extends any">
import { computed, inject } from "vue"
import { inject } from "vue"
import SmartTreeBranch from "./TreeBranch.vue"
import SmartSpinner from "./Spinner.vue"
import { SmartTreeAdapter, TreeNode } from "~/helpers/treeAdapter"
Expand All @@ -68,5 +68,5 @@ const props = defineProps<{
/**
* Fetch the root nodes from the adapter by passing the node id as null
*/
const rootNodes = computed(() => props.adapter.getChildren(null).value)
const rootNodes = props.adapter.getChildren(null)
</script>
6 changes: 2 additions & 4 deletions src/components/smart/TreeBranch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
>
<SmartTreeBranch
v-for="childNode in childNodes.data"
:key="childNode.id"
:key="`${childNode.id}-${childNode.data.type}`"
:node-item="childNode"
:adapter="adapter"
>
Expand Down Expand Up @@ -114,9 +114,7 @@ const highlightNode = ref(false)
/**
* Fetch the child nodes from the adapter by passing the node id of the current node
*/
const childNodes = computed(
() => props.adapter.getChildren(props.nodeItem.id).value,
)
const childNodes = props.adapter.getChildren(props.nodeItem.id, props.nodeItem.data.type)

const toggleNodeChildren = () => {
if (!childrenRendered.value) childrenRendered.value = true
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/treeAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export interface SmartTreeAdapter<T> {
/**
*
* @param nodeID - id of the node to get children for
* @param nodeType - Type of the node (`collection` | `request`)
* @returns - Ref that contains the children of the node. It is reactive and will be updated when the children are changed.
*/
getChildren: (nodeID: string | null) => Ref<ChildrenResult<T>>
getChildren: (nodeID: string | null, nodeType?: string) => Ref<ChildrenResult<T>>
}