hide settings sync from import

GitOrigin-RevId: 631d2d1a7ae63e3edc78041a00b07887db1db97b
This commit is contained in:
Sergey Pak
2024-05-29 17:27:59 +02:00
committed by intellij-monorepo-bot
parent bc4ffad3b5
commit 4cc274c946
7 changed files with 17 additions and 12 deletions

View File

@@ -35,7 +35,7 @@ class SyncChooserAction(controller: ImportSettingsController, syncDataProvider:
override fun update(e: AnActionEvent) {
e.presentation.isVisible = false
if (!service.isSyncEnabled.value) {
if (!service.isSyncEnabled || !service.hasDataToSync.value) {
return
}
super.update(e)

View File

@@ -41,7 +41,7 @@ class OtherOptions(private val controller: ImportSettingsController, private val
jb = addActionList(jbProducts, jbDataProvider, ImportSettingsBundle.message("other.options.sub.title.installed"))
}
if(syncDataProvider.settingsService.isSyncEnabled.value) {
if (syncDataProvider.settingsService.isSyncEnabled && syncDataProvider.settingsService.hasDataToSync.value) {
syncDataProvider.other?.let { products ->
addActionList(products, syncDataProvider, ImportSettingsBundle.message("other.options.sub.title.setting.sync")).let {
if (it.isNotEmpty()) {

View File

@@ -33,6 +33,7 @@ class ProductChooserPage(val controller: ImportSettingsController, override val
private val lifetime = controller.lifetime.createNested().intersect(this.createLifetime())
private val syncDataProvider = SyncActionsDataProvider.createProvider(lifetime)
/*
private val accountLabel = JLabel("user.name").apply {
icon = AllIcons.General.User
@@ -42,10 +43,11 @@ class ProductChooserPage(val controller: ImportSettingsController, override val
text = it?.loginName
}
settService.isSyncEnabled.advise(lifetime) {
settService.hasDataToSync.advise(lifetime) {
isVisible = it
}
}
*/
private val pane = object: JPanel(VerticalLayout(JBUI.scale(26), SwingConstants.CENTER)) {
override fun getComponentGraphics(g: Graphics?): Graphics {
@@ -102,7 +104,7 @@ class ProductChooserPage(val controller: ImportSettingsController, override val
at.setReservePlaceAutoPopupIcon(false)
at.targetComponent = pane
add(accountLabel, BorderLayout.WEST)
//add(accountLabel, BorderLayout.WEST)
add(at.component, BorderLayout.EAST)
border = JBUI.Borders.empty(0, 20, 10, 7)

View File

@@ -19,6 +19,8 @@ class SyncStateAction : ChooseProductActionButton() {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT
override fun actionPerformed(e: AnActionEvent) {
if (!settingsService.isSyncEnabled)
return
when (syncService.syncState.value) {
SyncService.SYNC_STATE.UNLOGGED -> {
syncService.tryToLogin()
@@ -29,7 +31,7 @@ class SyncStateAction : ChooseProductActionButton() {
}
override fun update(e: AnActionEvent) {
e.presentation.isVisible = !settingsService.isSyncEnabled.value
e.presentation.isVisible = settingsService.isSyncEnabled && !settingsService.hasDataToSync.value
if(!e.presentation.isVisible) {
return
}

View File

@@ -177,7 +177,7 @@ class SyncActionsDataProvider private constructor(lifetime: Lifetime) : ActionsD
private fun updateSyncMap() {
val service = settingsService.getSyncService()
if (!settingsService.isSyncEnabled.value) {
if (!settingsService.isSyncEnabled || !settingsService.hasDataToSync.value) {
map = null
return
}

View File

@@ -56,7 +56,9 @@ interface SettingsService {
val jbAccount: IPropertyView<JBAccountInfoService.JBAData?>
val isSyncEnabled: IPropertyView<Boolean>
val isSyncEnabled: Boolean
val hasDataToSync: IPropertyView<Boolean>
val doClose: ISignal<Unit>
@@ -155,7 +157,10 @@ class SettingsServiceImpl(private val coroutineScope: CoroutineScope) : Settings
}
// override val isSyncEnabled = jbAccount.compose(unloggedSyncHide()) { account, reg -> !reg || account != null }
override val isSyncEnabled = jbAccount.compose(getSyncService().syncState) { account, state -> account != null && state == SyncService.SYNC_STATE.LOGGED }
override val hasDataToSync = Property(false)
//override val hasDataToSync = jbAccount.compose(getSyncService().syncState) { account, state -> account != null && state == SyncService.SYNC_STATE.LOGGED }
override val isSyncEnabled = System.getProperty("import.settings.sync.enabled").toBoolean()
init {
if (useMockDataForStartupWizard) {

View File

@@ -47,10 +47,6 @@ internal class SyncServiceImpl(private val coroutineScope: CoroutineScope) : Syn
override val syncState = Property(SyncService.SYNC_STATE.UNLOGGED)
init {
loadAmbientSyncState()
}
private val accountInfoService: JBAccountInfoService?
get() = JBAccountInfoService.getInstance()