<template>
    <div>
        <p class="grid-element" @click="() => showViewPopup = true">{{ deployment.metadata.name }}</p>
        <p class="grid-element">{{ deployment.metadata.namespace }}</p>
        <p class="grid-element">{{ calcAge(deployment.metadata.creationTimestamp) }}</p>
        <p class="grid-element">{{ deployment.spec.replicas }}</p>
        <div class="grid-element action-buttons">
            <ActionButton @click="() => showLogsPopup = true">text_snippet</ActionButton>
            <ActionButton>autorenew</ActionButton>
            <ActionButton @click="() => rescaleDeploymentPopup.open()">height</ActionButton>
        </div>
        <RescaleDeploymentPopup ref="rescaleDeploymentPopup" :deployment="deployment"></RescaleDeploymentPopup>
        <DeploymentViewPopup v-if="showViewPopup" :deployment="deployment" @close="() => showViewPopup = false"></DeploymentViewPopup>
        <DeploymentLogPopup v-if="showLogsPopup" :deployment="deployment" @close="() => showLogsPopup = false"></DeploymentLogPopup>
    </div>
</template>

<script setup lang="ts">
import { Deployment } from '~/classes/Deployment';
import { calcAge } from '~/classes/Pod';
import RescaleDeploymentPopup from '../RescaleDeploymentPopup.vue';
import DeploymentViewPopup from "~/components/deployment/view/DeploymentViewPopup.vue";
import DeploymentLogPopup from "~/components/inspect/logs/DeploymentLogPopup.vue";

defineProps<{
    deployment: Deployment
}>();

const rescaleDeploymentPopup = ref();
const showViewPopup = ref(false);
const showLogsPopup = ref(false);
</script>