Skip to content

Commit 97cd0f0

Browse files
authored
fix: access the settings page for the auth. wizard (#105)
The Settings menu is only available after we successfully authenticate. This can be somewhat problematic if we want to configure something like coder cli path, or certificate path before doing the authentication. A new "Settings" button at the bottom of the page can now access the Settings page. Toolbox is a bit inflexible with the API because: - I could not find a way to delimit or separate the Settings button from the Back and Sign In/Connect button - we can't put a button or anything else in the top right corner, the traditional place for a settings icon. - resolves #90
1 parent db08dfa commit 97cd0f0

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
- rendering glitches when a Workspace is stopped while SSH connection is alive
1212
- misleading message saying that there are no workspaces rendered during manual authentication
13+
- Coder Settings can now be accessed from the authentication wizard
1314

1415
## 0.2.0 - 2025-04-24
1516

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class CoderRemoteProvider(
296296
if (autologin && lastDeploymentURL.isNotBlank() && (lastToken.isNotBlank() || !settings.requireTokenAuth)) {
297297
try {
298298
AuthWizardState.goToStep(WizardStep.LOGIN)
299-
return AuthWizardPage(context, true, ::onConnect)
299+
return AuthWizardPage(context, settingsPage, true, ::onConnect)
300300
} catch (ex: Exception) {
301301
errorBuffer.add(ex)
302302
}
@@ -306,7 +306,7 @@ class CoderRemoteProvider(
306306
firstRun = false
307307

308308
// Login flow.
309-
val authWizard = AuthWizardPage(context, false, ::onConnect)
309+
val authWizard = AuthWizardPage(context, settingsPage, false, ::onConnect)
310310
// We might have navigated here due to a polling error.
311311
errorBuffer.forEach {
312312
authWizard.notify("Error encountered", it)

src/main/kotlin/com/coder/toolbox/views/AuthWizardPage.kt

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ import kotlinx.coroutines.flow.update
1212

1313
class AuthWizardPage(
1414
private val context: CoderToolboxContext,
15+
private val settingsPage: CoderSettingsPage,
1516
initialAutoLogin: Boolean = false,
1617
onConnect: (
1718
client: CoderRestClient,
1819
cli: CoderCLIManager,
1920
) -> Unit,
20-
) : CoderPage(context, context.i18n.ptrl("Authenticate to Coder")) {
21+
) : CoderPage(context, context.i18n.ptrl("Authenticate to Coder"), false) {
2122
private val shouldAutoLogin = MutableStateFlow(initialAutoLogin)
22-
23+
private val settingsAction = Action(context.i18n.ptrl("Settings"), actionBlock = {
24+
context.ui.showUiPage(settingsPage)
25+
})
2326
private val signInStep = SignInStep(context, this::notify)
2427
private val tokenStep = TokenStep(context)
2528
private val connectStep = ConnectStep(context, shouldAutoLogin, this::notify, this::displaySteps, onConnect)
@@ -47,7 +50,8 @@ class AuthWizardPage(
4750
if (signInStep.onNext()) {
4851
displaySteps()
4952
}
50-
})
53+
}),
54+
settingsAction
5155
)
5256
}
5357
signInStep.onVisible()
@@ -64,6 +68,7 @@ class AuthWizardPage(
6468
displaySteps()
6569
}
6670
}),
71+
settingsAction,
6772
Action(context.i18n.ptrl("Back"), closesPage = false, actionBlock = {
6873
tokenStep.onBack()
6974
displaySteps()
@@ -79,6 +84,7 @@ class AuthWizardPage(
7984
}
8085
actionButtons.update {
8186
listOf(
87+
settingsAction,
8288
Action(context.i18n.ptrl("Back"), closesPage = false, actionBlock = {
8389
connectStep.onBack()
8490
shouldAutoLogin.update {

0 commit comments

Comments
 (0)