Skip to content

Commit

Permalink
action replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
Razz4780 committed Dec 21, 2023
1 parent cda1458 commit 21e3dbe
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 116 deletions.
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
],
"icon": "images/icon.png",
"activationEvents": [
"onStartupFinished",
"onCommand:mirrord.waitlistSignup"
"onStartupFinished"
],
"extensionKind": [
"workspace"
Expand All @@ -45,9 +44,9 @@
"title": "Change settings"
},
{
"command": "mirrord.waitlistSignup",
"command": "mirrord.mirrordForTeams",
"category": "mirrord",
"title": "Sign up to the waitlist for mirrord for Teams"
"title": "Navigate to mirrord for Teams introduction"
},
{
"command": "mirrord.selectActiveConfig",
Expand All @@ -68,10 +67,10 @@
"configuration": {
"title": "mirrord",
"properties": {
"mirrord.promptWaitlistSignup": {
"mirrord.promptMirrordForTeams": {
"type": "boolean",
"default": true,
"description": "Show notifications about waitlist signup."
"description": "Show notifications about mirrord for Teams."
},
"mirrord.promptActiveConfigRemoved": {
"type": "boolean",
Expand Down Expand Up @@ -135,7 +134,7 @@
"when": "true"
},
{
"command": "mirrord.waitlistSignup",
"command": "mirrord.mirrordForTeams",
"when": "true"
},
{
Expand Down Expand Up @@ -230,7 +229,6 @@
"webpack-cli": "^5.0.1"
},
"dependencies": {
"axios": "^1.4.0",
"semver": "^7.5.4",
"toml": "^3.0.0",
"vscode-uri": "^3.0.7",
Expand Down
4 changes: 2 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from 'vscode';
import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
import { globalContext } from './extension';
import { tickWaitlistCounter } from './waitlist';
import { tickMirrordForTeamsCounter } from './mirrordForTeams';
import { NotificationBuilder } from './notification';
import { MirrordStatus } from './status';
import { EnvVars, VerifiedConfig } from './config';
Expand Down Expand Up @@ -295,7 +295,7 @@ export class MirrordAPI {
* Has 60 seconds timeout
*/
async binaryExecute(target: string | null, configFile: string | null, executable: string | null, configEnv: EnvVars): Promise<MirrordExecution> {
tickWaitlistCounter(!!target?.startsWith('deployment/'));
tickMirrordForTeamsCounter(!!target?.startsWith('deployment/'));
tickFeedbackCounter();

/// Create a promise that resolves when the mirrord process exits
Expand Down
37 changes: 37 additions & 0 deletions src/mirrordForTeams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as vscode from 'vscode';
import { globalContext } from './extension';
import { NotificationBuilder } from './notification';
import { MirrordStatus } from './status';

const RUN_COUNTER = 'mirrord-for-teams-counter';
const NOTIFICATION_STARTS_AT = 100;
const NOTIFICATION_REPEATS_EVERY = 30;

async function showMirrordForTeamsNotification(message: string) {
new NotificationBuilder()
.withMessage(message)
.withGenericAction("Read more", async () => {
await vscode.commands.executeCommand(MirrordStatus.mirrordForTeamsCommandId);
})
.withDisableAction("promptMirrordForTeams")
.info();
}

export function tickMirrordForTeamsCounter(isDeploymentExec: boolean) {
const counter = parseInt(globalContext.globalState.get(RUN_COUNTER) ?? '0') || 0;

if (isDeploymentExec) {
showMirrordForTeamsNotification(
'When targeting multi-pod deployments, mirrord impersonates the first pod in the deployment.\n \
Support for multi-pod impersonation requires the mirrord operator, which is part of mirrord for Teams.'
);
} else if (counter >= NOTIFICATION_STARTS_AT) {
if (counter === NOTIFICATION_STARTS_AT || (counter - NOTIFICATION_STARTS_AT) % NOTIFICATION_REPEATS_EVERY === 0) {
showMirrordForTeamsNotification(
'mirrord for Teams ' // TODO
);
}
}

globalContext.globalState.update(RUN_COUNTER, `${counter + 1}`);
}
13 changes: 8 additions & 5 deletions src/status.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import * as vscode from 'vscode';
import { MirrordConfigManager } from './config';
import { globalContext } from './extension';
import { waitlistRegisterCommand } from './waitlist';
import { NotificationBuilder } from './notification';

export class MirrordStatus {
readonly statusBar: vscode.StatusBarItem;
static readonly toggleCommandId = 'mirrord.toggleMirroring';
static readonly settingsCommandId = 'mirrord.changeSettings';
static readonly submitFeedbackCommandId = 'mirrord.submitFeedback';
static readonly waitlistCommandId = 'mirrord.waitlistSignup';
static readonly mirrordForTeamsCommandId = 'mirrord.mirrordForTeams';
static readonly selectActiveConfigId = 'mirrord.selectActiveConfig';
static readonly helpCommandId = 'mirrord.help';

Expand Down Expand Up @@ -40,7 +39,7 @@ export class MirrordStatus {
}
statusBar.tooltip.appendMarkdown(`\n\n[Select active config](command:${MirrordStatus.selectActiveConfigId})`);
statusBar.tooltip.appendMarkdown(`\n\n[Settings](command:${MirrordStatus.settingsCommandId})`);
statusBar.tooltip.appendMarkdown(`\n\n[mirrord for Teams Waitlist](command:${MirrordStatus.waitlistCommandId})`);
statusBar.tooltip.appendMarkdown(`\n\n[mirrord for Teams](command:${MirrordStatus.mirrordForTeamsCommandId})`);
statusBar.tooltip.appendMarkdown(`\n\n[Submit Feedback](command:${MirrordStatus.submitFeedbackCommandId})`);
statusBar.tooltip.appendMarkdown(`\n\n[Help](command:${MirrordStatus.helpCommandId})`);

Expand All @@ -59,7 +58,7 @@ export class MirrordStatus {
globalContext.subscriptions.push(vscode.commands.registerCommand(MirrordStatus.settingsCommandId, configManager.changeSettings.bind(configManager)));
globalContext.subscriptions.push(vscode.commands.registerCommand(MirrordStatus.toggleCommandId, this.toggle.bind(this)));
globalContext.subscriptions.push(vscode.commands.registerCommand(MirrordStatus.submitFeedbackCommandId, this.submitFeedback.bind(this)));
globalContext.subscriptions.push(vscode.commands.registerCommand(MirrordStatus.waitlistCommandId, waitlistRegisterCommand));
globalContext.subscriptions.push(vscode.commands.registerCommand(MirrordStatus.mirrordForTeamsCommandId, this.mirrordForTeams.bind(this)));
globalContext.subscriptions.push(vscode.commands.registerCommand(MirrordStatus.helpCommandId, async () => {
vscode.commands.executeCommand(`workbench.action.openWalkthrough`, `MetalBear.mirrord#mirrord.welcome`, false);
}));
Expand Down Expand Up @@ -93,4 +92,8 @@ export class MirrordStatus {
submitFeedback() {
vscode.env.openExternal(vscode.Uri.parse('https://mirrord.dev/feedback'));
}
}

mirrordForTeams() {
vscode.env.openExternal(vscode.Uri.parse('https://mirrord.dev/docs/teams/introduction/'));
}
}
101 changes: 0 additions & 101 deletions src/waitlist.ts

This file was deleted.

0 comments on commit 21e3dbe

Please sign in to comment.