-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added end of 2.0 beta notification (#164)
- Loading branch information
1 parent
ee2d660
commit ce16f0a
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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[ | ||
|
@@ -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" /> | ||
|
||
|
60 changes: 60 additions & 0 deletions
60
...ain/com/intellij/lang/jsgraphql/endpoint/ide/startup/GraphQLBetaEndedStartupActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
} | ||
|
||
}); | ||
|
||
} | ||
} |