Merge branch 'main' into alex/createTag
This commit is contained in:
commit
c1e7d88d35
6 changed files with 115 additions and 17 deletions
36
package-lock.json
generated
36
package-lock.json
generated
|
@ -726,16 +726,30 @@
|
|||
"dev": true
|
||||
},
|
||||
"browserslist": {
|
||||
"version": "4.16.4",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.4.tgz",
|
||||
"integrity": "sha512-d7rCxYV8I9kj41RH8UKYnvDYCRENUlHRgyXy/Rhr/1BaeLGfiCptEdFE8MIrvGfWbBFNjVYx76SQWvNX1j+/cQ==",
|
||||
"version": "4.16.6",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.6.tgz",
|
||||
"integrity": "sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"caniuse-lite": "^1.0.30001208",
|
||||
"caniuse-lite": "^1.0.30001219",
|
||||
"colorette": "^1.2.2",
|
||||
"electron-to-chromium": "^1.3.712",
|
||||
"electron-to-chromium": "^1.3.723",
|
||||
"escalade": "^3.1.1",
|
||||
"node-releases": "^1.1.71"
|
||||
},
|
||||
"dependencies": {
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001230",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001230.tgz",
|
||||
"integrity": "sha512-5yBd5nWCBS+jWKTcHOzXwo5xzcj4ePE/yjtkZyUV1BTUmrBaA9MRGC+e7mxnqXSA90CmCA8L3eKLaSUkt099IQ==",
|
||||
"dev": true
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.742",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.742.tgz",
|
||||
"integrity": "sha512-ihL14knI9FikJmH2XUIDdZFWJxvr14rPSdOhJ7PpS27xbz8qmaRwCwyg/bmFwjWKmWK9QyamiCZVCvXm5CH//Q==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"buffer-crc32": {
|
||||
|
@ -784,12 +798,6 @@
|
|||
"integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==",
|
||||
"dev": true
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30001209",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001209.tgz",
|
||||
"integrity": "sha512-2Ktt4OeRM7EM/JaOZjuLzPYAIqmbwQMNnYbgooT+icoRGrKOyAxA1xhlnotBD1KArRSPsuJp3TdYcZYrL7qNxA==",
|
||||
"dev": true
|
||||
},
|
||||
"chainsaw": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz",
|
||||
|
@ -1091,12 +1099,6 @@
|
|||
"readable-stream": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.717",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.717.tgz",
|
||||
"integrity": "sha512-OfzVPIqD1MkJ7fX+yTl2nKyOE4FReeVfMCzzxQS+Kp43hZYwHwThlGP+EGIZRXJsxCM7dqo8Y65NOX/HP12iXQ==",
|
||||
"dev": true
|
||||
},
|
||||
"emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
|
|
|
@ -222,6 +222,11 @@
|
|||
"icon": "$(refresh)",
|
||||
"category": "Appwrite"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.refreshFunctions",
|
||||
"title": "Refresh functions",
|
||||
"icon": "$(refresh)"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.removeProject",
|
||||
"title": "Remove project",
|
||||
|
|
13
src/tree/common/EditableTreeItemBase.ts
Normal file
13
src/tree/common/EditableTreeItemBase.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { TreeItem } from "vscode";
|
||||
|
||||
export abstract class EditableTreeItemBase<T> extends TreeItem {
|
||||
public abstract setValue(value: T): Promise<void>;
|
||||
|
||||
constructor(contextValuePrefix: string, public readonly value: T, description?: string) {
|
||||
super(typeof value === "string" ? value : "No label");
|
||||
this.contextValue = `editable_${contextValuePrefix}`;
|
||||
this.description = description ?? contextValuePrefix;
|
||||
}
|
||||
|
||||
public abstract prompt(): Promise<void>;
|
||||
}
|
38
src/tree/common/EnumEditableTreeItem.ts
Normal file
38
src/tree/common/EnumEditableTreeItem.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { QuickPickItem, QuickPickOptions, window } from "vscode";
|
||||
import { EditableTreeItemBase } from "./EditableTreeItemBase";
|
||||
|
||||
export abstract class EnumEditableTreeItemBase extends EditableTreeItemBase<string[]> {
|
||||
public abstract options: string[] | QuickPickItem[];
|
||||
|
||||
public quickPickOptions: QuickPickOptions;
|
||||
|
||||
constructor(contextValuePrefix: string, public readonly value: string[], description?: string) {
|
||||
super(contextValuePrefix, value, description);
|
||||
this.quickPickOptions = {};
|
||||
}
|
||||
|
||||
public async prompt(): Promise<void> {
|
||||
|
||||
const value = await window.showQuickPick(
|
||||
this.options.map<QuickPickItem>((option: QuickPickItem | string): QuickPickItem => {
|
||||
if (typeof option === "string") {
|
||||
return { label: option, picked: this.value.includes(option) };
|
||||
}
|
||||
const picked = this.value.includes(option.label);
|
||||
return { ...option, picked, alwaysShow: picked };
|
||||
}).sort((a, b) => {
|
||||
if (a.picked) {
|
||||
return -1;
|
||||
}
|
||||
if (b.picked) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}),
|
||||
{ ...this.quickPickOptions, canPickMany: true }
|
||||
);
|
||||
if (value !== undefined) {
|
||||
this.setValue(value.map((item) => item.label));
|
||||
}
|
||||
}
|
||||
}
|
18
src/tree/common/SimpleEditableTreeItem.ts
Normal file
18
src/tree/common/SimpleEditableTreeItem.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { TreeItem, window } from "vscode";
|
||||
|
||||
export class EditableTreeItem extends TreeItem {
|
||||
public readonly setValue: (value: string) => Promise<void>;
|
||||
|
||||
constructor(label: string, contextValuePrefix: string, public readonly value: string, setValue: (value: string) => Promise<void>) {
|
||||
super(label);
|
||||
this.setValue = setValue;
|
||||
this.contextValue = `editable_${contextValuePrefix}`;
|
||||
}
|
||||
|
||||
public async prompt(): Promise<void> {
|
||||
const value = await window.showInputBox({ value: this.value });
|
||||
if (value !== undefined) {
|
||||
this.setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
22
src/tree/common/StringEditableTreeItem.ts
Normal file
22
src/tree/common/StringEditableTreeItem.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { InputBoxOptions, window } from "vscode";
|
||||
import { EditableTreeItemBase } from "./EditableTreeItemBase";
|
||||
|
||||
export abstract class StringEditableTreeItemBase extends EditableTreeItemBase<string> {
|
||||
public abstract setValue(value: string): Promise<void>;
|
||||
public inputBoxOptions: InputBoxOptions;
|
||||
|
||||
constructor(contextValuePrefix: string, public readonly value: string, description?: string) {
|
||||
super(contextValuePrefix, value, description);
|
||||
|
||||
this.inputBoxOptions = {
|
||||
prompt: description,
|
||||
};
|
||||
}
|
||||
|
||||
public async prompt(): Promise<void> {
|
||||
const value = await window.showInputBox({ value: this.value, ...this.inputBoxOptions });
|
||||
if (value !== undefined) {
|
||||
this.setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue