Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV2-2244 inject enterprise url from updater plugin #480

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/main/java/com/tabnine/general/StaticConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.tabnine.general.Utils.isUnitTestMode;
import static java.awt.Color.decode;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.NotificationDisplayType;
import com.intellij.notification.NotificationGroup;
import com.intellij.openapi.application.Application;
Expand All @@ -22,11 +23,20 @@
import java.util.*;
import javax.swing.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class StaticConfig {
// Must be identical to what is written under <id>com.tabnine.TabNine</id> in plugin.xml !!!
public static final String TABNINE_PLUGIN_ID_RAW =
Config.IS_ON_PREM ? "com.tabnine.TabNine-Enterprise" : "com.tabnine.TabNine";
public static final String TABNINE_ENTERPRISE_URL_PROPERTIES_KEY =
TABNINE_PLUGIN_ID_RAW + ".enterpriseUrl";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an entry in the settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// if the self-hosted updater injected the value, it'll be found here
@Nullable
public static final String TABNINE_ENTERPRISE_URL_DEFAULT_VALUE =
PropertiesComponent.getInstance().getValue(TABNINE_ENTERPRISE_URL_PROPERTIES_KEY);

public static final PluginId TABNINE_PLUGIN_ID = PluginId.getId(TABNINE_PLUGIN_ID_RAW);
public static final int MAX_COMPLETIONS = 5;
public static final String BINARY_PROTOCOL_VERSION = "4.4.223";
Expand Down Expand Up @@ -107,6 +117,11 @@ public static Optional<String> getTabnineEnterpriseHost() {
if (!path.isEmpty()) {
return Optional.of(path);
}

if (TABNINE_ENTERPRISE_URL_DEFAULT_VALUE != null) {
return Optional.of(TABNINE_ENTERPRISE_URL_DEFAULT_VALUE);
}

return Optional.ofNullable(System.getProperty(TABNINE_ENTERPRISE_HOST));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ class AppSettingsComponent {
.addLabeledComponent("Log level (requires restart): ", logLevelComponent, 1, false)

if (Config.IS_ON_PREM) {
panelBuilder.addLabeledComponent("Tabnine Enterprise URL (requires restart): ", cloud2UrlComponent, 1, false)
panelBuilder.addLabeledComponent(
"Tabnine Enterprise URL (requires restart): ",
cloud2UrlComponent,
1,
false
)
}
if (!isFixedDebounceConfigured()) {
panelBuilder
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/tabnine/userSettings/AppSettingsState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil
import com.tabnine.general.StaticConfig
import com.tabnine.inline.render.GraphicsUtils

val settingsDefaultColor = GraphicsUtils.niceContrastColor.rgb
Expand All @@ -26,7 +27,7 @@ class AppSettingsState : PersistentStateComponent<AppSettingsState?> {
var debounceTime: Long = 0
var autoImportEnabled: Boolean = true
var binariesFolderOverride: String = ""
var cloud2Url: String = ""
var cloud2Url: String = StaticConfig.TABNINE_ENTERPRISE_URL_DEFAULT_VALUE ?: ""

private var colorState = settingsDefaultColor

Expand Down