Skip to content

Commit ce16f0a

Browse files
committed
Added end of 2.0 beta notification (#164)
1 parent ee2d660 commit ce16f0a

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins {
1414
}
1515

1616
group 'com.intellij.lang.jsgraphql'
17-
version '2.0.0'
17+
version '2.0.0-end-of-beta'
1818

1919
apply plugin: 'java'
2020

js-graphql-intellij-plugin.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id="js-graphql-intellij-plugin" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.intellij.lang.jsgraphql" external.system.module.version="2.0.0" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="js-graphql-intellij-plugin" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.intellij.lang.jsgraphql" external.system.module.version="2.0.0-end-of-beta" type="JAVA_MODULE" version="4">
33
<component name="NewModuleRootManager" inherit-compiler-output="true">
44
<exclude-output />
55
<content url="file://$MODULE_DIR$">

resources/META-INF/plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<idea-plugin>
1111
<id>com.intellij.lang.jsgraphql</id>
1212
<name>JS GraphQL</name>
13-
<version>2.0.0</version>
13+
<version>2.0.0-end-of-beta</version>
1414
<vendor>Jim Kynde Meyer - [email protected]</vendor>
1515

1616
<description><![CDATA[
@@ -109,6 +109,7 @@
109109

110110
<!-- Startup -->
111111
<postStartupActivity implementation="com.intellij.lang.jsgraphql.endpoint.ide.startup.GraphQLStartupActivity" />
112+
<postStartupActivity implementation="com.intellij.lang.jsgraphql.endpoint.ide.startup.GraphQLBetaEndedStartupActivity" />
112113
<postStartupActivity implementation="com.intellij.lang.jsgraphql.ide.project.graphqlconfig.GraphQLConfigProjectStartupActivity" />
113114
<postStartupActivity implementation="com.intellij.lang.jsgraphql.ide.project.relay.GraphQLRelayModernEnableStartupActivity" />
114115

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2019-present, Jim Kynde Meyer
3+
* All rights reserved.
4+
* <p>
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
package com.intellij.lang.jsgraphql.endpoint.ide.startup;
9+
10+
import com.intellij.lang.jsgraphql.icons.JSGraphQLIcons;
11+
import com.intellij.notification.Notification;
12+
import com.intellij.notification.NotificationAction;
13+
import com.intellij.notification.NotificationType;
14+
import com.intellij.notification.Notifications;
15+
import com.intellij.openapi.actionSystem.AnActionEvent;
16+
import com.intellij.openapi.application.ApplicationManager;
17+
import com.intellij.openapi.options.ShowSettingsUtil;
18+
import com.intellij.openapi.project.Project;
19+
import com.intellij.openapi.startup.StartupActivity;
20+
import org.apache.commons.httpclient.HttpClient;
21+
import org.apache.commons.httpclient.methods.GetMethod;
22+
import org.apache.commons.httpclient.params.HttpClientParams;
23+
import org.jetbrains.annotations.NotNull;
24+
25+
public class GraphQLBetaEndedStartupActivity implements StartupActivity {
26+
@Override
27+
public void runActivity(@NotNull Project project) {
28+
29+
ApplicationManager.getApplication().executeOnPooledThread(() -> {
30+
31+
final HttpClientParams params = new HttpClientParams();
32+
final HttpClient httpClient = new HttpClient(params);
33+
final GetMethod method = new GetMethod("https://plugins.jetbrains.com/plugins/list?pluginId=8097");
34+
35+
try {
36+
final int responseCode = httpClient.executeMethod(method);
37+
if (responseCode == 200) {
38+
final String responseBody = method.getResponseBodyAsString();
39+
if (responseBody != null && responseBody.contains("<version>2.0")) { // HACK but good enough to detect the end the beta :D
40+
// 2.0 made available by JetBrains
41+
final Notification notification = new Notification("GraphQL", JSGraphQLIcons.Logos.GraphQL, "Thank you for testing the GraphQL plugin", null, "The 2.0 beta is over. Please remove the custom GraphQL repository URL in \"Plugins\" > \"Manage plugin repositories\" to get upcoming updates.", NotificationType.INFORMATION, null);
42+
notification.setImportant(true).addAction(new NotificationAction("Edit plugin settings") {
43+
@Override
44+
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
45+
ShowSettingsUtil.getInstance().showSettingsDialog(project, "Plugins");
46+
}
47+
});
48+
49+
Notifications.Bus.notify(notification);
50+
}
51+
52+
}
53+
54+
} catch (Exception ignored) {
55+
}
56+
57+
});
58+
59+
}
60+
}

0 commit comments

Comments
 (0)