Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@
"title": "Disable Help Explorer",
"category": "Atlassian"
},
{
"command": "atlascode.startWork",
"title": "Start Work on Issue"
},
{
"command": "atlascode.finishWork",
"title": "Finish Work on Issue"
},
{
"command": "atlascode.showOnboardingFlow",
"title": "Show Onboarding Flow",
Expand Down Expand Up @@ -705,6 +713,14 @@
"command": "atlascode.bb.refreshPipelines",
"when": "false"
},
{
"command": "atlascode.startWork",
"when": "true"
},
{
"command": "atlascode.finishWork",
"when": "true"
},
{
"command": "atlascode.bb.openInBitbucket",
"when": "false"
Expand Down
48 changes: 41 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ import { GitExtension } from './typings/git';
import { Experiments, FeatureFlagClient, Features } from './util/featureFlags';
import { NotificationManagerImpl } from './views/notifications/notificationManager';

import { window as vscodeWindow, StatusBarAlignment } from 'vscode';
import { MinimalIssue } from '@atlassianlabs/jira-pi-common-models';

const AnalyticDelay = 5000;
let activeIssue: MinimalIssue<any> | undefined;
let statusBarItem = vscodeWindow.createStatusBarItem(StatusBarAlignment.Left);

export async function activate(context: ExtensionContext) {
const start = process.hrtime();
Expand All @@ -38,11 +43,9 @@ export async function activate(context: ExtensionContext) {
const previousVersion = context.globalState.get<string>(GlobalStateVersionKey);

registerResources(context);

Configuration.configure(context);
Logger.configure(context);

// Mark ourselves as the PID in charge of refreshing credentials and start listening for pings.
context.globalState.update('rulingPid', pid);

try {
Expand Down Expand Up @@ -70,7 +73,6 @@ export async function activate(context: ExtensionContext) {
Container.clientManager.requestSite(site);
});

// new user for auth exp
if (previousVersion === undefined) {
const expVal = FeatureFlagClient.checkExperimentValue(Experiments.AtlascodeOnboardingExperiment);
if (expVal) {
Expand All @@ -90,9 +92,6 @@ export async function activate(context: ExtensionContext) {
const duration = process.hrtime(start);
context.subscriptions.push(languages.registerCodeLensProvider({ scheme: 'file' }, { provideCodeLenses }));

// Following are async functions called without await so that they are run
// in the background and do not slow down the time taken for the extension
// icon to appear in the activity bar
activateBitbucketFeatures();
activateYamlFeatures(context);

Expand All @@ -101,6 +100,41 @@ export async function activate(context: ExtensionContext) {
duration[0] * 1000 + Math.floor(duration[1] / 1000000)
} ms`,
);

// Register custom start/finish work commands
context.subscriptions.push(
commands.registerCommand('atlascode.startWork', (issue: MinimalIssue<any>) => {
activeIssue = issue;
updateStatusBar();
})
);

context.subscriptions.push(
commands.registerCommand('atlascode.finishWork', () => {
activeIssue = undefined;
updateStatusBar();
})
);

// Restore last issue on startup (if persisted, optional)
if (activeIssue) {
updateStatusBar();
}

statusBarItem.show();
context.subscriptions.push(statusBarItem);
}

function updateStatusBar() {
if (activeIssue) {
statusBarItem.text = `Working on: ${activeIssue.key}`;
statusBarItem.command = 'atlascode.finishWork';
statusBarItem.tooltip = 'Click to finish work on this issue';
} else {
statusBarItem.text = 'Start Work';
statusBarItem.command = undefined;
statusBarItem.tooltip = 'No active issue';
}
}

function activateErrorReporting(): void {
Expand Down Expand Up @@ -194,9 +228,9 @@ async function sendAnalytics(version: string, globalState: Memento) {
});
}

// this method is called when your extension is deactivated
export function deactivate() {
unregisterErrorReporting();
FeatureFlagClient.dispose();
NotificationManagerImpl.getInstance().stopListening();
statusBarItem.dispose();
}
12 changes: 10 additions & 2 deletions src/lib/ipc/toUI/startWork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import { Branch } from '../../../typings/git';
export enum StartWorkMessageType {
Init = 'init',
StartWorkResponse = 'startWorkResponse',
FinishWork = 'finishWork',
}

export type StartWorkMessage = ReducerAction<StartWorkMessageType.Init, StartWorkInitMessage>;
export type StartWorkResponse = ReducerAction<StartWorkMessageType.StartWorkResponse, StartWorkResponseMessage>;
export type FinishWorkMessage = ReducerAction<StartWorkMessageType.FinishWork, FinishWorkRequestMessage>;

export interface StartWorkIssueMessage {
issue: MinimalIssue<DetailedSiteInfo>;
Expand All @@ -30,6 +32,10 @@ export interface StartWorkResponseMessage {
upstream?: string;
}

export interface FinishWorkRequestMessage {
clearIssue: boolean;
}

export interface BranchType {
kind: string;
prefix: string;
Expand All @@ -50,13 +56,15 @@ export interface RepoData {
isCloud: boolean;
}

export const emptyStartWorkIssueMessage = {
export const emptyStartWorkIssueMessage: StartWorkIssueMessage = {
issue: createEmptyMinimalIssue(emptySiteInfo),
};

export const emptyStartWorkInitMessage = {
export const emptyStartWorkInitMessage: StartWorkInitMessage = {
issue: createEmptyMinimalIssue(emptySiteInfo),
repoData: [],
customTemplate: '',
customPrefixes: [],
};

export const emptyRepoData: RepoData = {
Expand Down