Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/minor'
Browse files Browse the repository at this point in the history
  • Loading branch information
monstajoe2002 committed Dec 12, 2023
2 parents 094ec88 + 4da5f26 commit 24e4de6
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 48 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,38 +0,0 @@
on:
push:
branches:
- release/patch
release:
types:
- created
jobs:
merge:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm install
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish
if: success() && startsWith(github.ref, 'refs/tags/')
run: npm run deploy\:patch
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

All notable changes to **Project Explorer** will be documented in this file.

## [0.1.5] - 2023-12-12

### Added

- View open (active) tabs in the tree view

## [0.1.4] - 2023-12-02

### Fixed

- Replace minus sign with ttrash in the tree view
- Replace minus sign with trash in the tree view

## [0.1.3] - 2023-11-29

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Project Explorer README
<a href="https://www.producthunt.com/posts/project-explorer?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-project&#0045;explorer" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=427756&theme=neutral" alt="Project&#0032;Explorer - Organize&#0032;and&#0032;view&#0032;your&#0032;Next&#0046;js&#0032;project&#0032;in&#0032;an&#0032;intuitive&#0032;way&#0032; | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>

<a href="https://www.producthunt.com/posts/project-explorer?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-project&#0045;explorer" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=427756&theme=neutral" alt="Project&#0032;Explorer - Organize&#0032;and&#0032;view&#0032;your&#0032;Next&#0046;js&#0032;project&#0032;in&#0032;an&#0032;intuitive&#0032;way&#0032; | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>

A convenient extension for searching and creating page and layout files in a Next.js application project.

## Motivation
Expand All @@ -22,5 +24,7 @@ This extension works in Next.js 13+ projects with `app` directory enabled **only

## Known Issues

When you delete a file through the command palette, VS Code will through an error saying that the file is not found. *See screenshot below*. This is a known issue with VS Code and is not related to this extension.
- When you delete a file through the command palette, VS Code will through an error saying that the file is not found. *See screenshot below*. This is a known issue with VS Code and is not related to this extension.
![Alt text](delete-error.png)

- In the Active Editors section, all tabs may not show there. This only occurs after launching Visual Studio Code to open tabs.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
{
"id": "projectExplorer.layouts",
"name": "Layouts"
},
{
"id": "projectExplorer.activeEditors",
"name": "Active Editors"
}
]
},
Expand Down Expand Up @@ -72,7 +76,7 @@
"view/title": [
{
"command": "project-explorer.tree.refresh",
"when": "view == projectExplorer.pages || view == projectExplorer.layouts",
"when": "view == projectExplorer.pages || view == projectExplorer.layouts || view == projectExplorer.activeEditors",
"group": "navigation"
}
],
Expand Down
7 changes: 6 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PagesProvider from "./providers/pages-provider";
import FileTreeItem from "./utils/file-tree-item";
import LayoutsProvider from "./providers/layouts-provider";
import path from "path";
import ActiveEditorsProvider from "./providers/active-editors-provider";

const workspaceUri = vscode.workspace.workspaceFolders![0].uri;
let appDirUri: vscode.Uri;
Expand All @@ -31,7 +32,7 @@ export async function activate(_: vscode.ExtensionContext) {

const pagesTree = new PagesProvider(appDirUri);
const layoutsTree = new LayoutsProvider(appDirUri);

const activeEditorsTree = new ActiveEditorsProvider(appDirUri);
nextSearch.register(_, async () => {
await nextSearch.showDirectoryContents(appDirUri);
});
Expand All @@ -47,9 +48,13 @@ export async function activate(_: vscode.ExtensionContext) {
vscode.window.createTreeView("projectExplorer.layouts", {
treeDataProvider: layoutsTree,
});
vscode.window.createTreeView("projectExplorer.activeEditors", {
treeDataProvider: activeEditorsTree,
});
vscode.commands.registerCommand("project-explorer.tree.refresh", () => {
pagesTree.refresh();
layoutsTree.refresh();
activeEditorsTree.refresh();
});
vscode.commands.registerCommand(
"project-explorer.tree.delete",
Expand Down
68 changes: 68 additions & 0 deletions src/providers/active-editors-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import * as vscode from "vscode";
import { Provider } from "../utils/base-provider";
import ActiveEditorsTreeItem from "../utils/active-editors-tree-item";
export default class ActiveEditorsProvider
extends Provider<ActiveEditorsTreeItem>
implements vscode.TreeDataProvider<ActiveEditorsTreeItem>
{
constructor(protected _projectDirUri: vscode.Uri) {
super(_projectDirUri);
}
protected readonly _onDidChangeTreeData: vscode.EventEmitter<
void | ActiveEditorsTreeItem | ActiveEditorsTreeItem[] | null | undefined
> = new vscode.EventEmitter<
void | ActiveEditorsTreeItem | ActiveEditorsTreeItem[] | null | undefined
>();
onDidChangeTreeData?:
| vscode.Event<
| void
| ActiveEditorsTreeItem
| ActiveEditorsTreeItem[]
| null
| undefined
>
| undefined = this._onDidChangeTreeData.event;
refresh(): void {
this._onDidChangeTreeData?.fire();
}
getTreeItem(
element: ActiveEditorsTreeItem
): vscode.TreeItem | Thenable<vscode.TreeItem> {
return element;
}
getChildren(
element?: ActiveEditorsTreeItem | undefined
): vscode.ProviderResult<ActiveEditorsTreeItem[]> {
const openDocuments = vscode.workspace.textDocuments;
const activeEditors: ActiveEditorsTreeItem[] = [];
this.refresh();
openDocuments.forEach((editor) => {
if (editor.fileName.endsWith(".git")) {
return null;
}
const activeEditor = new ActiveEditorsTreeItem(
"\\" +
editor.fileName.substring(
editor.fileName.indexOf("app\\") + "app\\".length
),
vscode.TreeItemCollapsibleState.None,
{
command: "vscode.open",
title: "",
arguments: [editor.uri],
}
);
activeEditors.push(activeEditor);
});
return activeEditors;
}
closeEditor(element: ActiveEditorsTreeItem) {
vscode.window.visibleTextEditors.map((editor) => {
if (editor.document.fileName === element.label) {
vscode.commands.executeCommand("workbench.action.closeActiveEditor");
}
});
this.refresh();
return;
}
}
12 changes: 8 additions & 4 deletions src/providers/layouts-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import * as vscode from "vscode";
import * as fs from "fs";
import * as path from "path";
import FileTreeItem from "../utils/file-tree-item";
import { Provider } from "../utils/base-provider";
export default class LayoutsProvider
extends Provider<FileTreeItem>
implements vscode.TreeDataProvider<FileTreeItem>
{
constructor(private projectDirUri: vscode.Uri) {}
private _onDidChangeTreeData: vscode.EventEmitter<
constructor(protected _projectDirUri: vscode.Uri) {
super(_projectDirUri);
}
protected readonly _onDidChangeTreeData: vscode.EventEmitter<
void | FileTreeItem | FileTreeItem[] | null | undefined
> = new vscode.EventEmitter<
void | FileTreeItem | FileTreeItem[] | null | undefined
Expand All @@ -26,11 +30,11 @@ export default class LayoutsProvider
getChildren(
element?: FileTreeItem | undefined
): vscode.ProviderResult<FileTreeItem[]> {
if (!this.projectDirUri) {
if (!this._projectDirUri) {
vscode.window.showInformationMessage("No file in empty workspace");
return [];
}
let rootDir: vscode.Uri = this.projectDirUri;
let rootDir: vscode.Uri = this._projectDirUri;
if (element) {
rootDir = element.resourceUri!;
}
Expand Down
8 changes: 6 additions & 2 deletions src/providers/pages-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import * as vscode from "vscode";
import * as fs from "fs";
import * as path from "path";
import FileTreeItem from "../utils/file-tree-item";
import { Provider } from "../utils/base-provider";
export default class PagesProvider
extends Provider<FileTreeItem>
implements vscode.TreeDataProvider<FileTreeItem>
{
constructor(private projectDirUri: vscode.Uri) {}
private _onDidChangeTreeData: vscode.EventEmitter<
constructor(protected projectDirUri: vscode.Uri) {
super(projectDirUri);
}
protected readonly _onDidChangeTreeData: vscode.EventEmitter<
void | FileTreeItem | FileTreeItem[] | null | undefined
> = new vscode.EventEmitter<
void | FileTreeItem | FileTreeItem[] | null | undefined
Expand Down
10 changes: 10 additions & 0 deletions src/utils/active-editors-tree-item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as vscode from "vscode";
export default class ActiveEditorsTreeItem extends vscode.TreeItem {
constructor(
public readonly label: string,
public readonly collapsibleState: vscode.TreeItemCollapsibleState,
public readonly command?: vscode.Command
) {
super(label, collapsibleState);
}
}
19 changes: 19 additions & 0 deletions src/utils/base-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as vscode from "vscode";
import FileTreeItem from "./file-tree-item";
export abstract class Provider<T extends vscode.TreeItem> {
constructor(protected _projectDirUri: vscode.Uri) {}
protected readonly _onDidChangeTreeData: vscode.EventEmitter<
void | T | T[] | null | undefined
> = new vscode.EventEmitter<void | T | T[] | null | undefined>();
onDidChangeTreeData?:
| vscode.Event<void | T | T[] | null | undefined>
| undefined = this._onDidChangeTreeData.event;
refresh(): void {
this._onDidChangeTreeData?.fire();
}
getTreeItem(element: T): vscode.TreeItem | Thenable<vscode.TreeItem> {
return element;
}

abstract getChildren(element?: T | undefined): vscode.ProviderResult<T[]>;
}

0 comments on commit 24e4de6

Please sign in to comment.