Skip to content

Commit 7669e9b

Browse files
committed
add disabled env mode
1 parent 49ae359 commit 7669e9b

File tree

11 files changed

+148
-96
lines changed

11 files changed

+148
-96
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Kubernetes Run Configuration Env
22

3-
![Build](https://github.com/ssharaev/intelij-k8s-env-plugin/workflows/Build/badge.svg)
3+
![Build](https://github.com/ssharaev/intellij-k8s-env-plugin/workflows/Build/badge.svg)
44
[![Version](https://img.shields.io/jetbrains/plugin/v/26165.svg)](https://plugins.jetbrains.com/plugin/26165)
55
[![Downloads](https://img.shields.io/jetbrains/plugin/d/26165.svg)](https://plugins.jetbrains.com/plugin/26165)
66

@@ -31,7 +31,7 @@ Also, you can replace your variable values using regexp.
3131

3232
- Manually:
3333

34-
Download the [latest release](https://github.com/ssharaev/intelij-k8s-env-plugin/releases/latest) and install it manually using
34+
Download the [latest release](https://github.com/ssharaev/intellij-k8s-env-plugin/releases/latest) and install it manually using
3535
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>⚙️</kbd> > <kbd>Install plugin from disk...</kbd>
3636

3737
# License

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = "com.ssharaev"
9-
version = providers.gradleProperty("pluginVersion")
9+
version = "0.1.0"
1010

1111
repositories {
1212
mavenCentral()
@@ -47,8 +47,8 @@ tasks {
4747
}
4848

4949
patchPluginXml {
50-
sinceBuild.set(providers.gradleProperty("pluginSinceBuild").get())
51-
untilBuild.set(providers.gradleProperty("pluginUntilBuild").get())
50+
sinceBuild.set("233")
51+
untilBuild.set(provider { null })
5252
changeNotes = provider {
5353
changelog.renderItem(changelog.getLatest()
5454
.withHeader(false)

gradle.properties

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
2-
32
pluginName = Kubernetes Run Configuration Env
43
pluginRepositoryUrl = https://github.com/ssharaev/intellij-k8s-env-plugin
5-
pluginVersion = 0.1.0
6-
7-
pluginSinceBuild = 233
8-
pluginUntilBuild = 245.*
94

105
# Gradle Releases -> https://github.com/gradle/gradle/releases
116
gradleVersion = 8.10.2

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "intellij-k8s-env-plugin"

src/main/java/com/ssharaev/k8s/env/plugin/model/EnvMode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
public enum EnvMode {
1111
CONFIGMAP_AND_SECRET("Configmaps and secrets"),
1212
POD_ENV("Pod environment"),
13-
POD_VAULT("Pod vault environment");
13+
POD_VAULT("Pod vault environment"),
14+
DISABLED("Disabled");
1415

1516
private final String beautyName;
1617

src/main/java/com/ssharaev/k8s/env/plugin/model/PluginSettings.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ public class PluginSettings {
2121
@NotNull
2222
@Builder.Default
2323
private EnvMode envMode = EnvMode.CONFIGMAP_AND_SECRET;
24-
@Builder.Default
25-
private String namespace = "default";
24+
@Nullable
25+
private String namespace;
26+
@NotNull
2627
@Builder.Default
2728
private List<String> configmapNames = List.of();
29+
@NotNull
2830
@Builder.Default
2931
private List<String> secretNames = List.of();
3032
@Nullable
3133
private String podName;
3234

35+
@NotNull
3336
@Builder.Default
3437
private List<ReplacementEntity> replacementEntities = List.of();
3538

src/main/java/com/ssharaev/k8s/env/plugin/services/RunConfigurationEditorService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ public void validateConfiguration(@NotNull RunConfigurationBase<?> configuration
8484
return;
8585
}
8686
try {
87-
validatePluginSettings(PluginSettingsProvider.getPluginSetting(configuration));
88-
enableK8sEnvProvider(configuration);
87+
PluginSettings pluginSetting = PluginSettingsProvider.getPluginSetting(configuration);
88+
validatePluginSettings(pluginSetting);
89+
if (pluginSetting.getEnvMode() != EnvMode.DISABLED) {
90+
enableK8sEnvProvider(configuration);
91+
}
8992
} catch (Exception e) {
9093
NotificationService.notifyWarn(NOTIFICATION_TITLE, e.getMessage());
9194
disableK8sEnvProvider(configuration);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.ssharaev.k8s.env.plugin.ui;
2+
3+
import com.intellij.ui.components.JBLabel;
4+
import com.intellij.util.ui.FormBuilder;
5+
import com.intellij.util.ui.JBUI;
6+
import com.intellij.util.ui.UIUtil;
7+
8+
import javax.swing.JComponent;
9+
import javax.swing.JPanel;
10+
11+
public class HideableElement<T extends JComponent> {
12+
private final T component;
13+
private final JBLabel label;
14+
private final JBLabel tooltip;
15+
16+
public HideableElement(String labelText, String tooltipText, T component) {
17+
this.component = component;
18+
this.label = new JBLabel(labelText);
19+
if (tooltipText != null) {
20+
this.tooltip = new JBLabel(tooltipText, UIUtil.ComponentStyle.SMALL, UIUtil.FontColor.BRIGHTER);
21+
this.tooltip.setBorder(JBUI.Borders.emptyLeft(10));
22+
} else {
23+
this.tooltip = null;
24+
}
25+
}
26+
27+
public HideableElement(String labelText, T component) {
28+
this(labelText, null, component);
29+
}
30+
31+
public void addToBuilder(FormBuilder builder) {
32+
builder.addLabeledComponent(label, component, 1, false)
33+
.addComponentFillVertically(new JPanel(), 0);
34+
if (tooltip != null) {
35+
builder.addComponentToRightColumn(tooltip, 1);
36+
}
37+
}
38+
39+
public void hide() {
40+
this.component.setVisible(false);
41+
this.label.setVisible(false);
42+
if (tooltip != null) {
43+
this.tooltip.setVisible(false);
44+
}
45+
}
46+
47+
public void show() {
48+
this.component.setVisible(true);
49+
this.label.setVisible(true);
50+
if (tooltip != null) {
51+
this.tooltip.setVisible(true);
52+
}
53+
}
54+
55+
protected T getComponent() {
56+
return component;
57+
}
58+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.ssharaev.k8s.env.plugin.ui;
2+
3+
import com.intellij.ui.components.JBTextField;
4+
5+
public class InputTextElement extends HideableElement<JBTextField> {
6+
7+
public InputTextElement(String labelText, String tooltipText, JBTextField component) {
8+
super(labelText, tooltipText, component);
9+
}
10+
11+
public String getText() {
12+
return getComponent().getText();
13+
}
14+
15+
public void setText(String text) {
16+
getComponent().setText(text);
17+
}
18+
}

src/main/java/com/ssharaev/k8s/env/plugin/ui/InputTextPanel.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)