|
| 1 | +import { FC, useState } from 'react'; |
| 2 | +import { Plus, Trash2 } from 'lucide-react'; |
| 3 | +import { cn } from '@/lib/utils'; |
| 4 | + |
| 5 | +const HelmTemplate: FC = () => { |
| 6 | + const [environments, setEnvironments] = useState([ |
| 7 | + { |
| 8 | + name: '', |
| 9 | + value: '', |
| 10 | + namePlaceholder: 'ENV1', |
| 11 | + valuePlaceholder: 'Hi', |
| 12 | + }, |
| 13 | + ]); |
| 14 | + const [stateless, setStateless] = useState(false); |
| 15 | + const [ingress, setIngress] = useState(false); |
| 16 | + |
| 17 | + const handleAddEnvironment = () => { |
| 18 | + setEnvironments((prev) => [ |
| 19 | + ...prev, |
| 20 | + { |
| 21 | + name: '', |
| 22 | + value: '', |
| 23 | + namePlaceholder: `ENV${prev.length + 1}`, |
| 24 | + valuePlaceholder: 'Hi', |
| 25 | + }, |
| 26 | + ]); |
| 27 | + }; |
| 28 | + |
| 29 | + const handleRemoveEnvironment = (index: number) => { |
| 30 | + setEnvironments((prev) => prev.filter((_, i) => i !== index)); |
| 31 | + }; |
| 32 | + |
| 33 | + return ( |
| 34 | + <div className="scrollbar-thin flex h-[calc(100%-56px)] w-full items-center justify-center overflow-y-auto"> |
| 35 | + <form className="flex h-full w-full max-w-[768px] flex-col justify-center"> |
| 36 | + <div className="flex flex-col w-full mb-4"> |
| 37 | + <label htmlFor="api_version" className="mb-1"> |
| 38 | + Api Version |
| 39 | + </label> |
| 40 | + <input |
| 41 | + id="api_version" |
| 42 | + placeholder="2" |
| 43 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 44 | + /> |
| 45 | + </div> |
| 46 | + <h1 className="mb-4 text-2xl font-bold">Pods</h1> |
| 47 | + <div className="flex flex-col mb-4"> |
| 48 | + <label htmlFor="pods_name" className="mb-1"> |
| 49 | + Name |
| 50 | + </label> |
| 51 | + <input |
| 52 | + id="pods_name" |
| 53 | + placeholder="2" |
| 54 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 55 | + /> |
| 56 | + </div> |
| 57 | + <div className="flex flex-col mb-4"> |
| 58 | + <label htmlFor="pods_image" className="mb-1"> |
| 59 | + Image |
| 60 | + </label> |
| 61 | + <input |
| 62 | + id="pods_image" |
| 63 | + placeholder="nginx" |
| 64 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 65 | + /> |
| 66 | + </div> |
| 67 | + <div className="flex flex-col mb-4"> |
| 68 | + <label htmlFor="pods_target_port" className="mb-1"> |
| 69 | + Target Port |
| 70 | + </label> |
| 71 | + <input |
| 72 | + id="pods_target_port" |
| 73 | + placeholder="nginx" |
| 74 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 75 | + /> |
| 76 | + </div> |
| 77 | + <div className="flex flex-col mb-2"> |
| 78 | + <label htmlFor="pods_replicas" className="mb-1"> |
| 79 | + Replicas |
| 80 | + </label> |
| 81 | + <input |
| 82 | + id="pods_replicas" |
| 83 | + placeholder="1" |
| 84 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 85 | + /> |
| 86 | + </div> |
| 87 | + <h2 className="mb-2 text-lg font-bold">Persistence</h2> |
| 88 | + <div className="flex flex-col mb-7"> |
| 89 | + <label htmlFor="pods_persistence_size" className="mb-1"> |
| 90 | + Size |
| 91 | + </label> |
| 92 | + <input |
| 93 | + id="pods_persistence_size" |
| 94 | + placeholder="iG1" |
| 95 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 96 | + /> |
| 97 | + </div> |
| 98 | + <div className="flex flex-col mb-2"> |
| 99 | + <label htmlFor="pods_accessModes" className="mb-1"> |
| 100 | + Access Modes |
| 101 | + </label> |
| 102 | + <input |
| 103 | + id="pods_accessModes" |
| 104 | + placeholder="ReadWriteOnce" |
| 105 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 106 | + /> |
| 107 | + </div> |
| 108 | + <div className="flex items-center mt-5 mb-2"> |
| 109 | + <h3 className="text-lg font-bold">Environments</h3> |
| 110 | + <button className="ml-4 btn btn-xs" onClick={handleAddEnvironment}> |
| 111 | + Add <Plus className="size-3" /> |
| 112 | + </button> |
| 113 | + </div> |
| 114 | + <div className="grid grid-cols-2 gap-4"> |
| 115 | + {environments.map((env, index) => ( |
| 116 | + <div |
| 117 | + className="flex items-center border border-gray-500 divide-x divide-gray-500 rounded-md" |
| 118 | + key={index} |
| 119 | + > |
| 120 | + <input |
| 121 | + value={env.name} |
| 122 | + placeholder={env.namePlaceholder} |
| 123 | + className="w-full h-12 px-2 outline-none rounded-s-md" |
| 124 | + /> |
| 125 | + <input |
| 126 | + value={env.value} |
| 127 | + placeholder={env.valuePlaceholder} |
| 128 | + className={cn('h-12 w-full px-2 outline-none', { |
| 129 | + 'rounded-e-md': index === 0, |
| 130 | + })} |
| 131 | + /> |
| 132 | + {index > 0 && ( |
| 133 | + <button |
| 134 | + onClick={() => handleRemoveEnvironment(index)} |
| 135 | + className="btn btn-error rounded-e-md rounded-s-none" |
| 136 | + > |
| 137 | + <Trash2 /> |
| 138 | + </button> |
| 139 | + )} |
| 140 | + </div> |
| 141 | + ))} |
| 142 | + </div> |
| 143 | + <div className="flex justify-between mb-2 mt-7"> |
| 144 | + <label htmlFor="pods_stateless" className="mb-1"> |
| 145 | + Stateless |
| 146 | + </label> |
| 147 | + <input |
| 148 | + id="pods_stateless" |
| 149 | + type="checkbox" |
| 150 | + className={cn('toggle border-gray-500 bg-gray-500', { |
| 151 | + 'bg-orange-base hover:bg-orange-base/70': stateless, |
| 152 | + })} |
| 153 | + onChange={() => setStateless(!stateless)} |
| 154 | + /> |
| 155 | + </div> |
| 156 | + <h4 className="mt-5 text-lg font-bold">Ingress</h4> |
| 157 | + <div className="flex justify-between mt-3 mb-2"> |
| 158 | + <label htmlFor="pods_ingress_enabled" className="mb-1"> |
| 159 | + Enabled |
| 160 | + </label> |
| 161 | + <input |
| 162 | + id="pods_ingress_enabled" |
| 163 | + type="checkbox" |
| 164 | + className={cn('toggle border-gray-500 bg-gray-500', { |
| 165 | + 'bg-orange-base hover:bg-orange-base/70': ingress, |
| 166 | + })} |
| 167 | + onChange={() => setIngress(!ingress)} |
| 168 | + /> |
| 169 | + </div> |
| 170 | + <div className="flex flex-col mt-3 mb-2"> |
| 171 | + <label htmlFor="pods_ingress_host" className="mb-1"> |
| 172 | + Host |
| 173 | + </label> |
| 174 | + <input |
| 175 | + id="pods_ingress_host" |
| 176 | + placeholder="www.example.com" |
| 177 | + className="w-full px-3 py-2 rounded-md outline-none" |
| 178 | + /> |
| 179 | + </div> |
| 180 | + <button className="w-full mt-3 text-white btn bg-orange-base hover:bg-orange-base/70"> |
| 181 | + Submit |
| 182 | + </button> |
| 183 | + </form> |
| 184 | + </div> |
| 185 | + ); |
| 186 | +}; |
| 187 | + |
| 188 | +export default HelmTemplate; |
0 commit comments