frontend/src/components/PersistentVolumesCreateMethodSelector.vue
<!-- PersistentVolumesCreateMethodSelector.vue -->
<template>
<div v-if="show" class="modal-overlay" @click="closeModal">
<div class="modal-content method-selector" @click.stop>
<div class="modal-header">
<h3>Create Persistent Volume</h3>
<button class="close-button" @click="closeModal">×</button>
</div>
<div class="modal-body">
<p class="description">
Choose how you would like to create your Persistent Volume:
</p>
<div class="method-options">
<div
class="method-option"
@click="selectMethod('guided')"
:class="{ selected: selectedMethod === 'guided' }"
>
<div class="method-icon">
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/>
</svg>
</div>
<div class="method-content">
<h4>Guided Form</h4>
<p>Use a step-by-step form with validation and helpful hints. Recommended for beginners.</p>
<ul class="method-features">
<li>Form validation</li>
<li>Field descriptions</li>
<li>Storage type selection</li>
<li>Access mode guidance</li>
</ul>
</div>
</div>
<div
class="method-option"
@click="selectMethod('yaml')"
:class="{ selected: selectedMethod === 'yaml' }"
>
<div class="method-icon">
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
<path d="M14,17H7V15H14M17,13H7V11H17M17,9H7V7H17M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z"/>
</svg>
</div>
<div class="method-content">
<h4>YAML Editor</h4>
<p>Write or paste YAML directly. Provides full control and flexibility for advanced users.</p>
<ul class="method-features">
<li>Full YAML control</li>
<li>Template loading</li>
<li>Syntax validation</li>
<li>Copy/paste support</li>
</ul>
</div>
</div>
</div>
<div class="volume-types-info">
<h4>Supported Volume Types:</h4>
<div class="volume-types">
<span class="volume-type">HostPath</span>
<span class="volume-type">NFS</span>
<span class="volume-type">AWS EBS</span>
<span class="volume-type">Azure Disk</span>
<span class="volume-type">GCE PD</span>
<span class="volume-type">iSCSI</span>
<span class="volume-type">Local</span>
<span class="volume-type">CSI</span>
</div>
</div>
</div>
<div class="modal-footer">
<button
class="cancel-button"
@click="closeModal"
>
Cancel
</button>
<button
class="continue-button"
@click="continueWithMethod"
:disabled="!selectedMethod"
>
Continue
</button>
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
export default defineComponent({
name: 'PersistentVolumesCreateMethodSelector',
props: {
show: {
type: Boolean,
required: true
}
},
emits: ['close', 'method-selected'],
setup(props, { emit }) {
const selectedMethod = ref<string>('');
const selectMethod = (method: string) => {
selectedMethod.value = method;
};
const closeModal = () => {
selectedMethod.value = '';
emit('close');
};
const continueWithMethod = () => {
if (selectedMethod.value) {
emit('method-selected', selectedMethod.value);
selectedMethod.value = '';
}
};
return {
selectedMethod,
selectMethod,
closeModal,
continueWithMethod
};
}
});
</script>
<style src="@/assets/css/MenuDialog.css" scoped></style>
<style scoped>
.method-selector {
max-width: 700px;
width: 90vw;
}
.description {
color: #ccc;
margin-bottom: 1.5rem;
text-align: center;
font-size: 1rem;
}
.method-options {
display: flex;
flex-direction: column;
gap: 1rem;
margin-bottom: 2rem;
}
.method-option {
display: flex;
align-items: flex-start;
gap: 1rem;
padding: 1.5rem;
border: 2px solid #444;
border-radius: 8px;
background-color: #2d2d2d;
cursor: pointer;
transition: all 0.2s ease;
}
.method-option:hover {
border-color: #007acc;
background-color: #333;
}
.method-option.selected {
border-color: #007acc;
background-color: #1a3a5c;
}
.method-icon {
flex-shrink: 0;
width: 48px;
height: 48px;
display: flex;
align-items: center;
justify-content: center;
background-color: #007acc;
border-radius: 8px;
color: white;
}
.method-option.selected .method-icon {
background-color: #0099ff;
}
.method-content {
flex: 1;
}
.method-content h4 {
margin: 0 0 0.5rem 0;
color: #ffffff;
font-size: 1.2rem;
}
.method-content p {
margin: 0 0 1rem 0;
color: #ccc;
line-height: 1.4;
}
.method-features {
list-style: none;
padding: 0;
margin: 0;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.method-features li {
background-color: #444;
color: #ccc;
padding: 0.25rem 0.5rem;
border-radius: 4px;
font-size: 0.85rem;
}
.method-option.selected .method-features li {
background-color: #007acc;
color: white;
}
.volume-types-info {
background-color: #333;
border: 1px solid #444;
border-radius: 6px;
padding: 1rem;
margin-bottom: 1rem;
}
.volume-types-info h4 {
margin: 0 0 0.75rem 0;
color: #ffffff;
font-size: 1rem;
}
.volume-types {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.volume-type {
background-color: #007acc;
color: white;
padding: 0.25rem 0.75rem;
border-radius: 12px;
font-size: 0.85rem;
font-weight: 500;
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 0.5rem;
padding: 1rem 1.5rem;
border-top: 1px solid #444;
}
.cancel-button {
padding: 0.5rem 1rem;
border: 1px solid #666;
background-color: transparent;
color: #ccc;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
}
.cancel-button:hover {
background-color: #444;
border-color: #777;
}
.continue-button {
padding: 0.5rem 1rem;
border: 1px solid #007acc;
background-color: #007acc;
color: white;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
}
.continue-button:hover:not(:disabled) {
background-color: #005a9e;
border-color: #005a9e;
}
.continue-button:disabled {
opacity: 0.6;
cursor: not-allowed;
}
/* Responsive design */
@media (max-width: 768px) {
.method-selector {
width: 95vw;
max-width: none;
}
.method-options {
gap: 0.75rem;
}
.method-option {
padding: 1rem;
flex-direction: column;
text-align: center;
}
.method-icon {
align-self: center;
margin-bottom: 0.5rem;
}
.method-features {
justify-content: center;
}
.volume-types {
justify-content: center;
}
}
</style>