[settings-sync] IJPL-200618, IJPL-200113: Improve "Confirm Disabling" dialog UI

Custom dialog for proper margins and title size

GitOrigin-RevId: 25d86ba70a8f2fd8c2b2ceb99e7bbec2098e8304
This commit is contained in:
Aleksandra Olemskaia
2025-09-01 18:43:42 +00:00
committed by intellij-monorepo-bot
parent b852da6c0c
commit 8f5a387193
2 changed files with 61 additions and 31 deletions
@@ -69,7 +69,7 @@ enable.dialog.error.no.provider=Settings provider {0} is not available
enable.dialog.error.cant.check=Cannot initialize settings provider {0}
disable.dialog.title=Confirm Disabling Backup and Sync
# {0} - account type, i.e. JetBrains or Google
disable.dialog.text=This will disable Backup and Sync for this installation,\nleaving the data stored on the {0} account intact.\nThis change will take effect immediately.
disable.dialog.text=This will disable Backup and Sync for this installation,<br>leaving the data stored on the {0} account intact.<br>This change will take effect immediately.
# {0} - account type, i.e. JetBrains or Google
disable.dialog.remove.data.box=Remove data from {0} account and disable for all IDEs
disable.dialog.disable.button=Disable
@@ -437,35 +437,18 @@ internal class SettingsSyncConfigurable(private val coroutineScope: CoroutineSco
private fun showDisableSyncDialog(): DisableSyncType {
val providerName = selectedUser()?.providerName ?: ""
val intResult = if (SettingsSyncStatusTracker.getInstance().currentStatus is SettingsSyncStatusTracker.SyncStatus.ActionRequired) {
Messages.showDialog(
message("disable.dialog.text", providerName),
message("disable.dialog.title"),
arrayOf(Messages.getCancelButton(), message("disable.dialog.disable.button")),
1,
1,
Messages.getQuestionIcon(), null
)
} else {
Messages.showCheckboxMessageDialog(
message("disable.dialog.text", providerName),
message("disable.dialog.title"),
arrayOf(Messages.getCancelButton(), message("disable.dialog.disable.button")),
message("disable.dialog.remove.data.box", providerName),
false,
1,
1,
Messages.getQuestionIcon()
) { index: Int, checkbox: JCheckBox ->
if (index == 1) {
if (checkbox.isSelected) 2 else 1
}
else {
0
}
val showRemoveDataCheckBox = SettingsSyncStatusTracker.getInstance().currentStatus != SettingsSyncStatusTracker.SyncStatus.UserActionRequired
val disableSyncDialog = DisableSyncDialog(configPanel, providerName, showRemoveDataCheckBox)
return if (disableSyncDialog.showAndGet()) {
if (disableSyncDialog.removeDataSelected) {
DisableSyncType.DISABLE_AND_REMOVE_DATA
} else {
DisableSyncType.DISABLE
}
}
return DisableSyncType.entries.find { it.value == intResult } ?: DisableSyncType.DONT_DISABLE
else {
DisableSyncType.DONT_DISABLE
}
}
private fun disableCurrentSyncDialog() : Boolean {
@@ -887,6 +870,11 @@ internal class SettingsSyncConfigurable(private val coroutineScope: CoroutineSco
init()
}
override fun createContentPaneBorder(): Border {
val insets = JButton().insets
return JBUI.Borders.empty(20, 20, 20 - insets.bottom, 20 - insets.right)
}
override fun createCenterPanel(): JComponent {
return panel {
row {
@@ -894,7 +882,7 @@ internal class SettingsSyncConfigurable(private val coroutineScope: CoroutineSco
panel {
row {
text(message("enable.dialog.source.option.title")).applyToComponent {
font = JBFont.h3()
font = JBFont.h4()
}
}
row {
@@ -917,6 +905,48 @@ internal class SettingsSyncConfigurable(private val coroutineScope: CoroutineSco
arrayOf(cancelAction, okAction)
}
private class DisableSyncDialog(parent: JComponent, val providerName: String, val showRemoveDataCheckBox: Boolean) : DialogWrapper(parent, false) {
init {
title = message("title.settings.sync")
init()
}
var removeDataSelected = false
override fun createContentPaneBorder(): Border {
val insets = JButton().insets
return JBUI.Borders.empty(20, 20, 20 - insets.bottom, 20 - insets.right)
}
override fun createCenterPanel(): JComponent {
return panel {
row {
icon(AllIcons.General.QuestionDialog).align(AlignY.TOP)
panel {
row {
text(message("disable.dialog.title")).applyToComponent {
font = JBFont.h4()
}
}
row {
text(message("disable.dialog.text", providerName))
}
row {
if (showRemoveDataCheckBox) {
checkBox(message("disable.dialog.remove.data.box", providerName))
.bindSelected(::removeDataSelected)
}
}
}
}
}
}
override fun createActions(): Array<Action> =
arrayOf(cancelAction, okAction)
}
private class AddAccountDialog(parent: JComponent) : DialogWrapper(parent, false) {
var providerCode: String = ""
@@ -928,7 +958,7 @@ internal class SettingsSyncConfigurable(private val coroutineScope: CoroutineSco
override fun createContentPaneBorder(): Border {
val insets = JButton().insets
return JBUI.Borders.empty(14, 20, 20 - insets.bottom, 20 - insets.right)
return JBUI.Borders.empty(20, 20, 20 - insets.bottom, 20 - insets.right)
}
override fun createCenterPanel(): JComponent {
@@ -938,7 +968,7 @@ internal class SettingsSyncConfigurable(private val coroutineScope: CoroutineSco
panel {
row {
text(message("enable.sync.choose.data.provider.title")).applyToComponent {
font = JBFont.h3()
font = JBFont.h4()
}
}
val availableProviders = RemoteCommunicatorHolder.getAvailableProviders().filter { it.isAvailable() }