mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Templates API
cgen-e9d51cb3c2694f9e8c7ab24e370654a2
This commit is contained in:
parent
ecf9f1b837
commit
2dc0a76cd7
1 changed files with 26 additions and 0 deletions
26
website/src/website/switch/templates.ts
Normal file
26
website/src/website/switch/templates.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { get, put, del, getAll, type RepoTemplateRecord, type IssueTemplateRecord } from "./db";
|
||||
import { nanoid } from "./uid";
|
||||
|
||||
export async function createRepoTemplate(name: string, fsHandleId: string): Promise<RepoTemplateRecord> {
|
||||
const rec: RepoTemplateRecord = { id: nanoid(), name, fsHandleId };
|
||||
await put("repoTemplates" as any, rec as any);
|
||||
return rec;
|
||||
}
|
||||
export async function listRepoTemplates(): Promise<RepoTemplateRecord[]> {
|
||||
return getAll<any>("repoTemplates" as any) as any;
|
||||
}
|
||||
export async function deleteRepoTemplate(id: string): Promise<void> {
|
||||
await del("repoTemplates" as any, id);
|
||||
}
|
||||
|
||||
export async function createIssueTemplate(data: { name: string; title: string; body: string; labels: string[] }): Promise<IssueTemplateRecord> {
|
||||
const rec: IssueTemplateRecord = { id: nanoid(), ...data };
|
||||
await put("issueTemplates" as any, rec as any);
|
||||
return rec;
|
||||
}
|
||||
export async function listIssueTemplates(): Promise<IssueTemplateRecord[]> {
|
||||
return getAll<any>("issueTemplates" as any) as any;
|
||||
}
|
||||
export async function deleteIssueTemplate(id: string): Promise<void> {
|
||||
await del("issueTemplates" as any, id);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue