Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(working-directory): keep the folder picker's buttons on one row (#22296)

AmAzing-cdbd4bb75fa1
diff --git a/src/features/WorkingDirectory/AddWorkingDirModal.tsx b/src/features/WorkingDirectory/AddWorkingDirModal.tsx
index 465424a55b4..c0872c4941c 100644
--- a/src/features/WorkingDirectory/AddWorkingDirModal.tsx
+++ b/src/features/WorkingDirectory/AddWorkingDirModal.tsx
@@ -70,8 +70,15 @@ const AddWorkingDirContent = ({
}
};
- const environmentSelect = withEnvironment ? (
- <EnvironmentSelect disabled={loading} value={environmentId} onChange={setEnvironmentId} />
+ // A row of its own, not beside the footer's buttons: next to them it pushed
+ // the buttons onto a second line in longer languages.
+ const environmentRow = withEnvironment ? (
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Text style={{ flex: 'none' }} type={'secondary'}>
+ {tPlugin('workingDirectory.environment.label')}
+ </Text>
+ <EnvironmentSelect disabled={loading} value={environmentId} onChange={setEnvironmentId} />
+ </Flexbox>
) : undefined;
if (!manual && deviceId) {
@@ -80,8 +87,8 @@ const AddWorkingDirContent = ({
defaultPath={value.trim() || undefined}
deviceId={deviceId}
error={error}
- footerExtra={environmentSelect}
loading={loading}
+ pickExtra={environmentRow}
onCancel={close}
onSelect={handleSubmit}
onManual={(path) => {
@@ -114,8 +121,8 @@ const AddWorkingDirContent = ({
/>
{error ? <Text style={{ color: cssVar.colorError, fontSize: 12 }}>{error}</Text> : null}
</Flexbox>
+ {environmentRow}
<Flexbox horizontal align={'center'} gap={8} justify={'flex-end'} wrap={'wrap'}>
- {environmentSelect}
{deviceId && (
<Button
disabled={loading}
diff --git a/src/features/WorkingDirectory/DirectoryBrowser.test.tsx b/src/features/WorkingDirectory/DirectoryBrowser.test.tsx
index b1f9a9fce6a..39ed6cfa967 100644
--- a/src/features/WorkingDirectory/DirectoryBrowser.test.tsx
+++ b/src/features/WorkingDirectory/DirectoryBrowser.test.tsx
@@ -44,4 +44,25 @@ describe('DirectoryBrowser', () => {
expect(screen.getByText('held')).toBeInTheDocument();
expect(screen.getByText('workingDirectory.useFolder').closest('button')).not.toBeDisabled();
});
+
+ it('should keep what a pick carries along off the footer buttons row', () => {
+ // Beside the buttons, an environment select pushed them onto a second line
+ // in English, where the labels run longer.
+ render(
+ <DirectoryBrowser
+ loading={false}
+ pickExtra={<span>environment</span>}
+ source={sourceWith({})}
+ onCancel={vi.fn()}
+ onManual={vi.fn()}
+ onSelect={vi.fn()}
+ />,
+ );
+
+ const footer = screen
+ .getByText('workingDirectory.enterPathManually')
+ .closest('button')!.parentElement!;
+ expect(screen.getByText('environment')).toBeInTheDocument();
+ expect(footer).not.toContainElement(screen.getByText('environment'));
+ });
});
diff --git a/src/features/WorkingDirectory/DirectoryBrowser.tsx b/src/features/WorkingDirectory/DirectoryBrowser.tsx
index b7d50d83416..3797a779153 100644
--- a/src/features/WorkingDirectory/DirectoryBrowser.tsx
+++ b/src/features/WorkingDirectory/DirectoryBrowser.tsx
@@ -24,13 +24,16 @@ export interface DirectoryBrowserProps {
/** Above the address bar; the device wording when absent, nothing when `null`. */
description?: ReactNode;
error?: string;
- /** Beside the footer's buttons — what a pick carries along, such as an environment. */
- footerExtra?: ReactNode;
loading: boolean;
onCancel: () => void;
/** Switch to typing a path; absent where a path cannot be typed. */
onManual?: (path: string) => void;
onSelect: (path: string) => void;
+ /**
+ * What a pick carries along, such as an environment: a row of its own above
+ * the footer, so the buttons stay on one line however long its labels run.
+ */
+ pickExtra?: ReactNode;
source: DirectorySource;
}
@@ -73,11 +76,11 @@ export const DirectoryBrowser = ({
defaultPath,
description,
error: submitError,
- footerExtra,
loading,
onCancel,
onManual,
onSelect,
+ pickExtra,
source,
}: DirectoryBrowserProps) => {
const { t } = useTranslation('device');
@@ -263,6 +266,7 @@ export const DirectoryBrowser = ({
</>
)}
</Flexbox>
+ {pickExtra}
{submitError && <SubmitError detail={submitError} />}
{blockedReason && canUseDirectory && (
<Text fontSize={12} type={'warning'}>
@@ -278,7 +282,6 @@ export const DirectoryBrowser = ({
<span />
)}
<Flexbox horizontal align={'center'} gap={8}>
- {footerExtra}
<Button disabled={loading} onClick={onCancel}>
{tCommon('cancel')}
</Button>
diff --git a/src/features/WorkingDirectory/EnvironmentSelect.tsx b/src/features/WorkingDirectory/EnvironmentSelect.tsx
index 301cbd90839..6b108366072 100644
--- a/src/features/WorkingDirectory/EnvironmentSelect.tsx
+++ b/src/features/WorkingDirectory/EnvironmentSelect.tsx
@@ -49,7 +49,6 @@ const EnvironmentSelect = memo<EnvironmentSelectProps>(
disabled={disabled}
loading={isLoading}
placeholder={t('workingDirectory.environment.none')}
- size={'small'}
style={{ minWidth: 168 }}
value={value}
options={environments.map((environment) => ({
diff --git a/src/features/WorkingDirectory/RemoteDirectoryBrowser.tsx b/src/features/WorkingDirectory/RemoteDirectoryBrowser.tsx
index b3caef453d4..69013f42afb 100644
--- a/src/features/WorkingDirectory/RemoteDirectoryBrowser.tsx
+++ b/src/features/WorkingDirectory/RemoteDirectoryBrowser.tsx
@@ -9,11 +9,11 @@ interface RemoteDirectoryBrowserProps {
defaultPath?: string;
deviceId: string;
error?: string;
- footerExtra?: ReactNode;
loading: boolean;
onCancel: () => void;
onManual: (path: string) => void;
onSelect: (path: string) => void;
+ pickExtra?: ReactNode;
}
/** {@link DirectoryBrowser} over a connected device's folders. */