mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-12 11:47:11 +00:00
feat(ui): make the core stack flow usable on mobile (#1327)
* feat(ui): make the core stack flow usable on mobile Below the md breakpoint the app collapses to a single full-width column: the stack list is full-screen, tapping a stack opens a full-screen detail with a Health / Logs / Compose segmented control (Logs first) and a back button, and a bottom tab bar switches Stacks, Fleet, Schedules, and Settings. Compose is read-only on a phone with a prompt to edit on desktop. Desktop (md and up) is unchanged: the mobile shell is gated behind a useIsMobile hook plus max-md/md variants, and the stack-detail blocks are shared with the desktop two-pane view so it renders identically. Also generalizes the unsaved-changes guard so leaving a dirty editor (back, tab bar, hamburger) prompts before discarding; adds 44px touch targets on list rows, filter chips, and actions; makes log and shell modals full-screen on mobile; and offsets toasts and the deploy pill above the bottom tab bar. * fix(ui): keep mobile nav in sync when opening views from outside the bottom bar On a phone the sidebar activity actions, the node switcher's Manage Nodes, the profile Settings entry, and the dashboard configuration links set the active view without flipping the mobile surface to content, so the user stayed on the stack list and never saw the destination. Route these through the mobile-aware navigation and settings helpers (a no-op on desktop).
This commit is contained in:
@@ -341,6 +341,10 @@ export function useStackActions(options: UseStackActionsOptions) {
|
||||
} catch (error) {
|
||||
if (isAbortError(error) || signal.aborted) return;
|
||||
console.error('Failed to load file:', error);
|
||||
// Surface the failure so a tap that cannot load (offline, dead remote
|
||||
// node, 5xx) is not a silent no-op, especially on mobile where the row
|
||||
// tap optimistically opens the detail surface.
|
||||
toast.error(`Could not open "${filename.replace(/\.(ya?ml)$/, '')}". Check your connection and try again.`);
|
||||
stackListState.setSelectedFile(null);
|
||||
editorState.setContent('');
|
||||
editorState.setOriginalContent('');
|
||||
@@ -890,18 +894,40 @@ export function useStackActions(options: UseStackActionsOptions) {
|
||||
}
|
||||
};
|
||||
|
||||
// Guard a navigation that would leave (and discard) a dirty editor: back to
|
||||
// the list, Home, or any bottom-tab / hamburger / command-palette
|
||||
// destination. When the editor is dirty the navigation is stashed and the
|
||||
// unsaved-changes dialog opens; discardAndLoadPending runs it on confirm.
|
||||
// When clean it runs immediately.
|
||||
const attemptLeaveEditor = (perform: () => void) => {
|
||||
if (stackListState.selectedFile && hasUnsavedChanges()) {
|
||||
overlayState.setPendingLeaveAction({ run: perform });
|
||||
return;
|
||||
}
|
||||
perform();
|
||||
};
|
||||
|
||||
const cancelPendingUnsavedLoad = () => {
|
||||
overlayState.setPendingUnsavedLoad(null);
|
||||
overlayState.setPendingUnsavedNode(null);
|
||||
overlayState.setPendingLeaveAction(null);
|
||||
};
|
||||
|
||||
const discardAndLoadPending = () => {
|
||||
const leave = overlayState.pendingLeaveAction;
|
||||
const target = overlayState.pendingUnsavedLoad;
|
||||
const targetNode = overlayState.pendingUnsavedNode;
|
||||
editorState.setContent(editorState.originalContent);
|
||||
editorState.setEnvContent(editorState.originalEnvContent);
|
||||
overlayState.setPendingUnsavedLoad(null);
|
||||
overlayState.setPendingUnsavedNode(null);
|
||||
overlayState.setPendingLeaveAction(null);
|
||||
// A stashed "leave editor" navigation takes precedence; it already knows
|
||||
// how to tear down editor state (resetEditorState) and move the surface.
|
||||
if (leave) {
|
||||
leave.run();
|
||||
return;
|
||||
}
|
||||
if (target === NODE_SWITCH_PENDING_TOKEN) {
|
||||
if (targetNode) setActiveNode(targetNode);
|
||||
return;
|
||||
@@ -1060,6 +1086,7 @@ export function useStackActions(options: UseStackActionsOptions) {
|
||||
serviceAction,
|
||||
updateStack,
|
||||
deleteStack,
|
||||
attemptLeaveEditor,
|
||||
cancelPendingUnsavedLoad,
|
||||
discardAndLoadPending,
|
||||
requestDeleteStack,
|
||||
|
||||
Reference in New Issue
Block a user