|
1 |
| -import { Plus, Minus, Server, Settings, Database, Key, Trash2, Copy, Globe, Shield, FileText } from 'lucide-react'; |
2 |
| -import type { DeploymentConfig, Container, ConfigMap, Secret, EnvVar } from '../types'; |
| 1 | +import { Plus, Minus, Server, Settings, Database, Key, Trash2, Copy, Globe, Shield, FileText, Users, X } from 'lucide-react'; |
| 2 | +import type { DeploymentConfig, Container, ConfigMap, Secret, EnvVar, ServiceAccount } from '../types'; |
3 | 3 |
|
4 | 4 | interface DeploymentFormProps {
|
5 | 5 | config: DeploymentConfig;
|
6 | 6 | onChange: (config: DeploymentConfig) => void;
|
7 | 7 | availableNamespaces: string[];
|
8 | 8 | availableConfigMaps: ConfigMap[];
|
9 | 9 | availableSecrets: Secret[];
|
| 10 | + availableServiceAccounts: ServiceAccount[]; |
| 11 | + onNavigateToServiceAccounts?: () => void; |
10 | 12 | }
|
11 | 13 |
|
12 |
| -export function DeploymentForm({ config, onChange, availableNamespaces, availableConfigMaps, availableSecrets }: DeploymentFormProps) { |
| 14 | +export function DeploymentForm({ config, onChange, availableNamespaces, availableConfigMaps, availableSecrets, availableServiceAccounts, onNavigateToServiceAccounts }: DeploymentFormProps) { |
13 | 15 | const updateConfig = (updates: Partial<DeploymentConfig>) => {
|
14 | 16 | onChange({ ...config, ...updates });
|
15 | 17 | };
|
@@ -330,6 +332,56 @@ export function DeploymentForm({ config, onChange, availableNamespaces, availabl
|
330 | 332 | ))}
|
331 | 333 | </select>
|
332 | 334 | </div>
|
| 335 | + |
| 336 | + <div className="sm:col-span-2"> |
| 337 | + <div className="flex items-center justify-between mb-2"> |
| 338 | + <label className="block text-sm font-medium text-gray-700"> |
| 339 | + Service Account |
| 340 | + </label> |
| 341 | + {onNavigateToServiceAccounts && ( |
| 342 | + <button |
| 343 | + type="button" |
| 344 | + onClick={onNavigateToServiceAccounts} |
| 345 | + className="inline-flex items-center px-2 py-1 text-xs bg-cyan-600 text-white rounded hover:bg-cyan-700 transition-colors duration-200" |
| 346 | + > |
| 347 | + <Plus className="w-3 h-3 mr-1" /> |
| 348 | + New Service Account |
| 349 | + </button> |
| 350 | + )} |
| 351 | + </div> |
| 352 | + <div className="flex space-x-2"> |
| 353 | + <select |
| 354 | + value={config.serviceAccount || ''} |
| 355 | + onChange={(e) => updateConfig({ serviceAccount: e.target.value || undefined })} |
| 356 | + className="flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm sm:text-base" |
| 357 | + > |
| 358 | + <option value="">Default (no service account)</option> |
| 359 | + {availableServiceAccounts |
| 360 | + .filter(sa => sa.namespace === config.namespace) |
| 361 | + .map(serviceAccount => ( |
| 362 | + <option key={serviceAccount.name} value={serviceAccount.name}> |
| 363 | + {serviceAccount.name} |
| 364 | + </option> |
| 365 | + ))} |
| 366 | + </select> |
| 367 | + {config.serviceAccount && ( |
| 368 | + <button |
| 369 | + type="button" |
| 370 | + onClick={() => updateConfig({ serviceAccount: undefined })} |
| 371 | + className="px-3 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 focus:ring-2 focus:ring-red-500 focus:border-transparent text-sm transition-colors duration-200" |
| 372 | + title="Remove service account" |
| 373 | + > |
| 374 | + <X className="w-4 h-4 text-gray-500 hover:text-red-600" /> |
| 375 | + </button> |
| 376 | + )} |
| 377 | + </div> |
| 378 | + {config.serviceAccount && ( |
| 379 | + <div className="mt-2 flex items-center space-x-2 text-xs text-gray-600"> |
| 380 | + <Users className="w-3 h-3 text-cyan-500" /> |
| 381 | + <span>Using service account: {config.serviceAccount}</span> |
| 382 | + </div> |
| 383 | + )} |
| 384 | + </div> |
333 | 385 | </div>
|
334 | 386 | </div>
|
335 | 387 |
|
|
0 commit comments