<template>
  <SecretGroupTreeItem :path="group.path" :name="group.group_name">
    <template v-if="group.children && group.children.length > 0">
      <template v-for="child in group.children" :key="child.id">
        <SecretGroup :key="child.id" :group="child" v-if="group.path !== except" />
      </template>
    </template>
    <template v-for="entry in group.entries" :key="entry.name">
      <SecretGroupTreeEntry :name="entry.name" :groupPath="groupPath" />
    </template>
  </SecretGroupTreeItem>
</template>
<script setup lang="ts">
import { toRef } from 'vue'
import type { ClientSecretGroup } from '@/client'
import SecretGroup from '@/components/secrets/SecretGroup.vue'
import SecretGroupTreeItem from '@/components/secrets/SecretGroupTreeItem.vue'
import SecretGroupTreeEntry from '@/components/secrets/SecretGroupTreeEntry.vue'

const props = defineProps<{ group: ClientSecretGroup; except?: string }>()

const groupPath = toRef(() => props.group.path)
</script>
