Skip to content

Commit

Permalink
Merge pull request #2 from pullflow/release/1.0.1
Browse files Browse the repository at this point in the history
🚇 Release 1.0.1
  • Loading branch information
hassan-pullflow authored Nov 7, 2023
2 parents a5ede64 + 9f6ff8f commit b3da203
Show file tree
Hide file tree
Showing 18 changed files with 360 additions and 44 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish to VS Code Marketplace
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Setup Node version
uses: actions/setup-node@v1
with:
node-version: 16

- uses: actions/checkout@v2

- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_SESSIONS_SECRET_KEY: ${{ secrets.SESSION_SECRET_KEY }}
envkey_CLIENT_IDENTIFIER: com.pullflow.vscode
envkey_PULLFLOW_APP_URL: https://app.pullflow.com

- name: Build, compile and test
run: |
yarn
yarn compile
yarn lint
yarn test
- name: publish
run: |
yarn global add vsce
vsce publish -p ${{ secrets.VSCE_ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "1.0.0",
"version": "1.0.1",
"configurations": [
{
"name": "Run Extension",
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"dbaeumer",
"nosources",
"Pullflow",
"quickpicks",
"Relogin",
"thumbsup",
"uuidv",
"vscodeignore",
"Webviews",
"Xids"
],
"editor.tabSize": 2,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The **Pullflow VS Code extension** brings all your code review workflows and col
---

1. **Installation**: Install the “Pullflow” extension from the Visual Studio Marketplace or Open VSX Registry.
2. **Login**: Click on “Sign in to Pullflow” from the VS Code status bar.
2. **Sign in**: Click on “Sign in to Pullflow” from the VS Code status bar.
3. **Ready to use**: The extension is now ready to use ✨

## Key Features
Expand Down
Binary file added assets/pullflow-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "pullflow",
"publisher": "Pullflow",
"displayName": "Pullflow",
"description": "Enhance your code review process by consolidating interactions within VS Code and directly integrating with platforms like Slack and GitHub.",
"version": "1.0.0",
"description": "Code review collaboration across GitHub, Slack, and VS Code.",
"version": "1.0.1",
"preview": true,
"license": "MIT",
"engines": {
Expand All @@ -14,11 +14,14 @@
},
"icon": "assets/pullflow.png",
"categories": [
"SCM Providers",
"Programming Languages",
"Machine Learning",
"Education",
"Snippets",
"Other"
],
"galleryBanner": {
"color": "#795DBD",
"color": "#F6F4F9",
"theme": "light"
},
"private": true,
Expand All @@ -41,12 +44,12 @@
"title": "Pullflow: Active Pull Requests"
},
{
"command": "pullflow.login",
"title": "Pullflow: login"
"command": "pullflow.signIn",
"title": "Pullflow: Sign in"
},
{
"command": "pullflow.logout",
"title": "Pullflow: logout"
"command": "pullflow.signOut",
"title": "Pullflow: Sign out"
},
{
"command": "pullflow.reconnect",
Expand All @@ -59,6 +62,10 @@
{
"command": "pullflow.toggle-flow-state",
"title": "Pullflow: Toggle Flow state"
},
{
"command": "pullflow.welcome-view",
"title": "Pullflow: Welcome"
}
],
"keybindings": [
Expand Down
5 changes: 4 additions & 1 deletion src/commands/reconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Reconnect = async (
if (codeReviews.requireRelogin) {
log.error(codeReviews.error, module)
window.showInformationMessage(`Pullflow: Please login again`)
commands.executeCommand(Command.logout)
commands.executeCommand(Command.signOut)
return
}

Expand All @@ -47,5 +47,8 @@ export const Reconnect = async (
userAuthoredCodeReviews: codeReviews.data.authored,
})
StatusBar.update({ context, statusBar, state: StatusBarState.SignedIn })

commands.executeCommand(Command.activePullRequests)

return
}
6 changes: 3 additions & 3 deletions src/commands/login.ts → src/commands/signIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { initialize } from '../utils/initialize'

const SIGN_IN_TIME_OUT = 120000 // sign in time out in ms

export const Login = async ({
export const SignIn = async ({
context,
statusBar,
}: {
context: ExtensionContext
statusBar: StatusBarItem
}) => {
const redirectUri = `${env.uriScheme}://${context.extension.packageJSON.publisher}.${context.extension.packageJSON.name}`
const loginUrl = AppConfig.pullflow.baseUrl
const signInUrl = AppConfig.pullflow.baseUrl

env.openExternal(
Uri.parse(
`${loginUrl}/?clientIdentifier=${AppConfig.app.clientIdentifier}&clientUri=${redirectUri}`
`${signInUrl}/?clientIdentifier=${AppConfig.app.clientIdentifier}&clientUri=${redirectUri}`
)
)
const user = await Authorization.waitForUser(context, SIGN_IN_TIME_OUT)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/logout.ts → src/commands/signOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StatusBar } from '../views/statusBar/statusBar'
import { StatusBarState } from '../utils'
import { Store } from '../utils/store'

export const Logout = async ({
export const SignOut = async ({
context,
statusBar,
pollIntervalId,
Expand Down
6 changes: 6 additions & 0 deletions src/commands/welcomeView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ExtensionContext } from 'vscode'
import { Welcome } from '../views/webviews/welcome/welcome'

export const WelcomeView = (context: ExtensionContext) => {
Welcome.show(context)
}
35 changes: 22 additions & 13 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { ExtensionContext, commands, StatusBarItem, window, Uri } from 'vscode'
import { log } from './utils/logger'
import { Login } from './commands/login'
import { SignIn } from './commands/signIn'
import { StatusBar } from './views/statusBar/statusBar'
import { Command } from './utils'
import { initialize } from './utils/initialize'
import { Store } from './utils/store'
import { Reconnect } from './commands/reconnect'
import { Logout } from './commands/logout'
import { SignOut } from './commands/signOut'
import { ActivePullRequests } from './commands/activePullRequests'
import { Authorization } from './utils/authorization'
import { ToggleFlowState } from './commands/toggleFlowState'
import { Welcome } from './views/webviews/welcome/welcome'

const module = 'extension.ts'

export async function activate(context: ExtensionContext) {
log.info('activating extension', module)

await checkSessionAndLogin(context)
checkFirstActivation(context)

const statusBar: StatusBarItem = await StatusBar.activate(context)
const { pollIntervalId, focusStateEvent, presenceInterval } =
await initialize({
Expand All @@ -42,11 +44,13 @@ export async function activate(context: ExtensionContext) {
})

context.subscriptions.push(
commands.registerCommand(Command.login, () => Login({ context, statusBar }))
commands.registerCommand(Command.signIn, () =>
SignIn({ context, statusBar })
)
)
context.subscriptions.push(
commands.registerCommand(Command.logout, () =>
Logout({
commands.registerCommand(Command.signOut, () =>
SignOut({
context,
statusBar,
pollIntervalId,
Expand All @@ -70,17 +74,22 @@ export async function activate(context: ExtensionContext) {
ToggleFlowState(context, statusBar)
)
)
context.subscriptions.push(
commands.registerCommand(Command.welcomeView, () => {
Welcome.show(context)
})
)
}

// this method is called when your extension is deactivated
export function deactivate() {}

const checkSessionAndLogin = async (context: ExtensionContext) => {
const session = await Authorization.currentSession(context)
if (!session) {
window.showInformationMessage(
`Pullflow: Please login to continue using extension`
)
commands.executeCommand(Command.login)
const checkFirstActivation = (context: ExtensionContext) => {
const isFirstActivation = !Store.get(context)?.extensionId

if (isFirstActivation) {
commands.executeCommand(Command.welcomeView)
const extensionId = `${context.extension.packageJSON.publisher}.${context.extension.packageJSON.name}`
Store.set(context, { extensionId })
}
}
5 changes: 3 additions & 2 deletions src/utils/commands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export const Command = {
login: 'pullflow.login',
signIn: 'pullflow.signIn',
activePullRequests: 'pullflow.active-pull-requests',
logout: 'pullflow.logout',
signOut: 'pullflow.signOut',
reconnect: 'pullflow.reconnect',
toggleFlowState: 'pullflow.toggle-flow-state',
welcomeView: 'pullflow.welcome-view',
}
2 changes: 1 addition & 1 deletion src/utils/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const setSpaceUsers = async ({
window.showInformationMessage(
`Error in fetching space users ${spaceUsers.error || spaceUsers.message}`
)
commands.executeCommand(Command.logout)
commands.executeCommand(Command.signOut)
return
}

Expand Down
5 changes: 1 addition & 4 deletions src/utils/pullRequestsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const PullRequestState = {
if (codeReviews.requireRelogin) {
log.error(codeReviews.error, module)
window.showInformationMessage(`Pullflow: Please login again`)
commands.executeCommand(Command.logout)
commands.executeCommand(Command.signOut)
return
}

Expand All @@ -52,9 +52,6 @@ export const PullRequestState = {
if (errorCount.count >= MAX_ERROR_COUNT) {
StatusBar.update({ context, statusBar, state: StatusBarState.Error })
}
window.showErrorMessage(
`Pullflow: Couldn't fetch pull requests. ${codeReviews.error.message}`
)
return
}
await Store.set(context, {
Expand Down
1 change: 1 addition & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type RepoChannelConnection = {
}

export type CacheObject = {
extensionId?: string
pendingUserCodeReviews?: [UserCodeReview]
userAuthoredCodeReviews?: [UserCodeReview]
user?: User
Expand Down
31 changes: 22 additions & 9 deletions src/views/statusBar/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const statusBarProperties = {
tooltip: 'Pullflow - Active Pull Requests',
},
signedOut: {
command: Command.login,
command: Command.signIn,
backgroundColor: new ThemeColor(Theme.statusBar.error),
text: '⚠ Sign in to Pullflow',
tooltip: 'Sign in to Pullflow account',
Expand Down Expand Up @@ -68,11 +68,15 @@ export const StatusBar = {
log.info('updating status bar', module)

if (state === StatusBarState.SignedIn) {
statusBarProperties.signedIn.text = getStatusBarText(context)
statusBarProperties.signedIn.text = getStatusBarText({ context })
statusBar = Object.assign(statusBar, statusBarProperties.signedIn)
} else if (state === StatusBarState.Loading) {
statusBar = Object.assign(statusBar, statusBarProperties.loading)
} else if (state === StatusBarState.Error) {
statusBarProperties.error.text = getStatusBarText({
context,
showErrorIcon: true,
})
statusBar = Object.assign(statusBar, statusBarProperties.error)
} else {
statusBar = Object.assign(statusBar, statusBarProperties.signedOut)
Expand All @@ -82,7 +86,13 @@ export const StatusBar = {
}

/** computes status bar text */
function getStatusBarText(context: ExtensionContext): string {
function getStatusBarText({
context,
showErrorIcon = false,
}: {
context: ExtensionContext
showErrorIcon?: boolean
}): string {
if (STATUS_BAR_ICON_PREVIEW) {
const allIcons = IconReference.map((k) => `$(${k})`).join('')
return '$(pullflow-icon)' + allIcons
Expand All @@ -93,12 +103,15 @@ function getStatusBarText(context: ExtensionContext): string {
previousPresenceStatus,
} = Store.get(context)

if (!pendingUserCodeReviews && !userAuthoredCodeReviews) return ''
const presenceIcon =
previousPresenceStatus === PresenceStatus.Flow ? '$(symbol-event)' : ''
const errorIcon = showErrorIcon ? ' $(warning) ' : ''

if (!pendingUserCodeReviews && !userAuthoredCodeReviews)
return `${errorIcon} ${presenceIcon} $(pullflow-icon)`

const pendingCodeReviewsCount = pendingUserCodeReviews?.length || 0
const authoredCodeReviewsCount = userAuthoredCodeReviews?.length || 0
const presenceIcon =
previousPresenceStatus === PresenceStatus.Flow ? '$(symbol-event)' : ''
if (
pendingCodeReviewsCount < MAX_PR_COUNT &&
authoredCodeReviewsCount < MAX_PR_COUNT
Expand All @@ -111,10 +124,10 @@ function getStatusBarText(context: ExtensionContext): string {
userAuthoredCodeReviews?.map(
(codeReview) => `$(${PullRequestIcons.getIcon(codeReview.botReaction)})`
) || []
return `${presenceIcon} ${pendingCodeReviewIcons.join(
return `${errorIcon} ${presenceIcon} ${pendingCodeReviewIcons.join(
''
)} $(pullflow-icon)\t${authoredCodeReviewIcons.join('')}`
)} $(pullflow-icon) ${authoredCodeReviewIcons.join('')}`
} else {
return `${presenceIcon} ${pendingCodeReviewsCount} $(pullflow-icon) ${authoredCodeReviewsCount}`
return `${errorIcon} ${presenceIcon} ${pendingCodeReviewsCount} $(pullflow-icon) ${authoredCodeReviewsCount}`
}
}
Loading

0 comments on commit b3da203

Please sign in to comment.