mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-09-03 22:25:30 +00:00
feat: update environment file selection logic and enhance editor UI with helpful tips
This commit is contained in:
@@ -1039,7 +1039,7 @@ export default function EditorLayout() {
|
|||||||
</TabsList>
|
</TabsList>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
{activeTab === 'env' && envFiles.length > 0 && (
|
{activeTab === 'env' && envFiles.length > 1 && (
|
||||||
<Select value={selectedEnvFile} onValueChange={changeEnvFile} disabled={isEditing || isFileLoading}>
|
<Select value={selectedEnvFile} onValueChange={changeEnvFile} disabled={isEditing || isFileLoading}>
|
||||||
<SelectTrigger className="h-9 text-xs bg-muted border-none min-w-[200px]">
|
<SelectTrigger className="h-9 text-xs bg-muted border-none min-w-[200px]">
|
||||||
<SelectValue placeholder="Select environment file" />
|
<SelectValue placeholder="Select environment file" />
|
||||||
@@ -1078,35 +1078,45 @@ export default function EditorLayout() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 min-h-0">
|
<div className="flex-1 min-h-0 flex flex-col">
|
||||||
{!isFileLoading && (
|
{activeTab === 'env' && (
|
||||||
<Editor
|
<div className="bg-blue-500/10 border-b border-blue-500/20 px-4 py-2 flex items-center gap-2 text-xs text-blue-400">
|
||||||
height="100%"
|
<span className="font-semibold">💡 Pro Tip:</span>
|
||||||
language={activeTab === 'compose' ? 'yaml' : 'plaintext'}
|
<span>
|
||||||
theme={isDarkMode ? 'vs-dark' : 'vs'}
|
Variables defined here are automatically available for substitution in your compose.yaml (e.g., <code className="bg-background px-1 rounded text-[10px]">${'{}'}VAR</code>). To pass them directly into your container, you must add <code className="bg-background px-1 rounded text-[10px]">env_file: - .env</code> to your service definition.
|
||||||
value={activeTab === 'compose' ? safeContent : safeEnvContent}
|
</span>
|
||||||
onChange={(value) => {
|
|
||||||
if (!isEditing) return; // Prevent changes in view mode
|
|
||||||
if (activeTab === 'compose') {
|
|
||||||
setContent(value || '');
|
|
||||||
} else {
|
|
||||||
setEnvContent(value || '');
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
options={{
|
|
||||||
minimap: { enabled: false },
|
|
||||||
fontSize: 14,
|
|
||||||
padding: { top: 10 },
|
|
||||||
scrollBeyondLastLine: false,
|
|
||||||
readOnly: !isEditing,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{isFileLoading && (
|
|
||||||
<div className="flex items-center justify-center h-full text-muted-foreground">
|
|
||||||
Loading...
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<div className="flex-1 min-h-0">
|
||||||
|
{!isFileLoading && (
|
||||||
|
<Editor
|
||||||
|
height="100%"
|
||||||
|
language={activeTab === 'compose' ? 'yaml' : 'plaintext'}
|
||||||
|
theme={isDarkMode ? 'vs-dark' : 'vs'}
|
||||||
|
value={activeTab === 'compose' ? safeContent : safeEnvContent}
|
||||||
|
onChange={(value) => {
|
||||||
|
if (!isEditing) return; // Prevent changes in view mode
|
||||||
|
if (activeTab === 'compose') {
|
||||||
|
setContent(value || '');
|
||||||
|
} else {
|
||||||
|
setEnvContent(value || '');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
options={{
|
||||||
|
minimap: { enabled: false },
|
||||||
|
fontSize: 14,
|
||||||
|
padding: { top: 10 },
|
||||||
|
scrollBeyondLastLine: false,
|
||||||
|
readOnly: !isEditing,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{isFileLoading && (
|
||||||
|
<div className="flex items-center justify-center h-full text-muted-foreground">
|
||||||
|
Loading...
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user