Skip to content

Commit

Permalink
Added end of 2.0 beta notification (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimkyndemeyer committed Apr 6, 2019
1 parent ee2d660 commit ce16f0a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

group 'com.intellij.lang.jsgraphql'
version '2.0.0'
version '2.0.0-end-of-beta'

apply plugin: 'java'

Expand Down
2 changes: 1 addition & 1 deletion js-graphql-intellij-plugin.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
Expand Down
3 changes: 2 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<idea-plugin>
<id>com.intellij.lang.jsgraphql</id>
<name>JS GraphQL</name>
<version>2.0.0</version>
<version>2.0.0-end-of-beta</version>
<vendor>Jim Kynde Meyer - [email protected]</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -109,6 +109,7 @@

<!-- Startup -->
<postStartupActivity implementation="com.intellij.lang.jsgraphql.endpoint.ide.startup.GraphQLStartupActivity" />
<postStartupActivity implementation="com.intellij.lang.jsgraphql.endpoint.ide.startup.GraphQLBetaEndedStartupActivity" />
<postStartupActivity implementation="com.intellij.lang.jsgraphql.ide.project.graphqlconfig.GraphQLConfigProjectStartupActivity" />
<postStartupActivity implementation="com.intellij.lang.jsgraphql.ide.project.relay.GraphQLRelayModernEnableStartupActivity" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2019-present, Jim Kynde Meyer
* All rights reserved.
* <p>
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.intellij.lang.jsgraphql.endpoint.ide.startup;

import com.intellij.lang.jsgraphql.icons.JSGraphQLIcons;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationAction;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.jetbrains.annotations.NotNull;

public class GraphQLBetaEndedStartupActivity implements StartupActivity {
@Override
public void runActivity(@NotNull Project project) {

ApplicationManager.getApplication().executeOnPooledThread(() -> {

final HttpClientParams params = new HttpClientParams();
final HttpClient httpClient = new HttpClient(params);
final GetMethod method = new GetMethod("https://plugins.jetbrains.com/plugins/list?pluginId=8097");

try {
final int responseCode = httpClient.executeMethod(method);
if (responseCode == 200) {
final String responseBody = method.getResponseBodyAsString();
if (responseBody != null && responseBody.contains("<version>2.0")) { // HACK but good enough to detect the end the beta :D
// 2.0 made available by JetBrains
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);
notification.setImportant(true).addAction(new NotificationAction("Edit plugin settings") {
@Override
public void actionPerformed(@NotNull AnActionEvent e, @NotNull Notification notification) {
ShowSettingsUtil.getInstance().showSettingsDialog(project, "Plugins");
}
});

Notifications.Bus.notify(notification);
}

}

} catch (Exception ignored) {
}

});

}
}

0 comments on commit ce16f0a

Please sign in to comment.