<script setup lang="ts">
import { useFilesPageContext } from '@/composables/files/filesPageContext'

const p = useFilesPageContext()
</script>

<template>
  <v-alert
    v-if="p.filesAccessHint"
    :type="p.filesAccessHint.type"
    variant="tonal"
    closable
    prominent
    density="comfortable"
    class="mb-4"
    icon="mdi-shield-lock-outline"
    @click:close="p.dismissFilesAccessHint"
  >
    <div class="d-flex flex-wrap align-center justify-space-between ga-2">
      <span>{{ p.filesAccessHint.text.split('目标机安装示例')[0].trim() }}</span>
      <v-btn
        v-if="p.sshUserForFiles && p.sshUserForFiles !== 'root'"
        size="small"
        variant="flat"
        color="primary"
        prepend-icon="mdi-auto-fix"
        :loading="p.setupSudoLoading"
        :disabled="p.setupSudoDone"
        @click.stop="p.setupFilesSudo"
      >
        {{ p.setupSudoDone ? '已配置' : '一键配置 sudo 权限' }}
      </v-btn>
    </div>
  </v-alert>
</template>
