Skip to content

Commit

Permalink
Replaced waitlist registration action with mirrord for Teams action (#…
Browse files Browse the repository at this point in the history
…221)

* Replaced action

* Changelog entry

* Changed button text

* Added notifications about mirrord for Teams

* Changelog entry

* Changelog merged
  • Loading branch information
Razz4780 authored Dec 21, 2023
1 parent ebfeaaf commit e8d1200
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 134 deletions.
2 changes: 2 additions & 0 deletions changelog.d/+mirrord-for-teams-action.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Replaced waitlist registration action with mirrord for Teams actions.
Added occasional notifications about mirrord for Teams.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.util.indexing.*
import com.intellij.util.io.EnumeratorStringDescriptor
import com.intellij.util.io.KeyDescriptor
import java.util.Collections
import java.util.*
import javax.swing.JComponent

const val FEEDBACK_URL = "https://mirrord.dev/feedback"
const val MIRRORD_FOR_TEAMS_URL = "https://mirrord.dev/docs/teams/introduction/"

fun VirtualFile.relativePath(project: Project): String {
return calcRelativeToProjectPath(this, project, includeFilePath = true, keepModuleAlwaysOnTheLeft = true)
Expand Down Expand Up @@ -105,10 +106,9 @@ class MirrordDropDown : ComboBoxAction(), DumbAware {
}
}

private class WaitlistSignupAction : AnAction("Join the waitlist") {
private class NavigateToMirrodForTeamsIntroAction : AnAction("Try it now") {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
MirrordWaitlistDialog(project).show()
BrowserUtil.browse(MIRRORD_FOR_TEAMS_URL)
}
}

Expand All @@ -130,7 +130,7 @@ class MirrordDropDown : ComboBoxAction(), DumbAware {
add(SelectActiveConfigAction())
add(SettingsAction())
addSeparator("mirrord for Teams")
add(WaitlistSignupAction())
add(NavigateToMirrodForTeamsIntroAction())
addSeparator("Feedback")
add(FeedbackAction())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class MirrordExecManager(private val service: MirrordProjectService) {
null
}

service.runCounter.bump(target?.startsWith("deploy") ?: false)

val executionInfo = mirrordApi.exec(
cli,
target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class MirrordProjectService(val project: Project) : Disposable {

val versionCheck: MirrordVersionCheck = MirrordVersionCheck(this)

val runCounter: MirrordRunCounter = MirrordRunCounter(this)

fun mirrordApi(environment: Map<String, String>?): MirrordApi {
return MirrordApi(this, environment)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.metalbear.mirrord

import com.intellij.ide.util.PropertiesComponent
import com.intellij.notification.NotificationType

private const val NOTIFY_AFTER: Int = 100
private const val NOTIFY_EVERY: Int = 30
private const val COUNTER_KEY: String = "mirrordForTeamsCounter"

private const val DEPLOYMENT_EXEC_MESSAGE: String = "When targeting multi-pod deployments, mirrord impersonates the first pod in the deployment. Support for multi-pod impersonation requires the mirrord operator, which is part of mirrord for Teams."
private const val REGULAR_EXEC_MESSAGE: String = "For more features of mirrord, including multi-pod impersonation, check out mirrord for Teams."
class MirrordRunCounter(private val service: MirrordProjectService) {
private fun showNotification(message: String) {
service.notifier.notification(message, NotificationType.INFORMATION).withLink("Try it now", MIRRORD_FOR_TEAMS_URL).withDontShowAgain(MirrordSettingsState.NotificationId.MIRRORD_FOR_TEAMS).fire()
}
fun bump(isDeploymentExec: Boolean) {
val pc = PropertiesComponent.getInstance()

val previousRuns = pc.getInt(COUNTER_KEY, 0)
pc.setValue(COUNTER_KEY, (previousRuns + 1).toString())

if (isDeploymentExec) {
this.showNotification(DEPLOYMENT_EXEC_MESSAGE)
} else if (previousRuns >= NOTIFY_AFTER) {
if (previousRuns == NOTIFY_AFTER || (previousRuns - NOTIFY_AFTER) % NOTIFY_EVERY == 0) {
this.showNotification(REGULAR_EXEC_MESSAGE)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.metalbear.mirrord

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.components.service

@State(name = "MirrordSettingsState", storages = [Storage("mirrord.xml")])
open class MirrordSettingsState : PersistentStateComponent<MirrordSettingsState.MirrordState> {
Expand Down Expand Up @@ -29,7 +32,8 @@ open class MirrordSettingsState : PersistentStateComponent<MirrordSettingsState.
POSSIBLY_OUTDATED_BINARY_USED("possibly outdated mirrord binary is used"),
ACTIVE_CONFIG_MOVED("active mirrord config is moved"),
AGENT_VERSION_MISMATCH("agent version does not match version of the local mirrord installation"),
PLUGIN_REVIEW("mirrord occasionally asks for plugin review")
PLUGIN_REVIEW("mirrord occasionally asks for plugin review"),
MIRRORD_FOR_TEAMS("mirrord occasionally informs about mirrord for Teams")
}

class MirrordState {
Expand Down

This file was deleted.

0 comments on commit e8d1200

Please sign in to comment.