mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Add branches and issues state and effects
cgen-a6dde697689b484b87087ada8a5cd7f7
This commit is contained in:
parent
b87eedb237
commit
8a8d5b7254
1 changed files with 18 additions and 0 deletions
|
|
@ -15,11 +15,29 @@ export function SwitchPage() {
|
|||
const [tree, setTree] = React.useState<{ path: string; isDir: boolean; children?: any[] }[]>([]);
|
||||
const [openFile, setOpenFile] = React.useState<OpenFile | undefined>();
|
||||
const [editorValue, setEditorValue] = React.useState<string>("// SWITCH: Open a folder to get started\n");
|
||||
const [branches, setBranches] = React.useState<BranchRecord[]>([]);
|
||||
const [currentBranchId, setCurrentBranchIdState] = React.useState<string | undefined>(undefined);
|
||||
const [commitMsg, setCommitMsg] = React.useState("");
|
||||
const [history, setHistory] = React.useState<CommitRecord[]>([]);
|
||||
const [issues, setIssues] = React.useState<IssueRecord[]>([]);
|
||||
const [newIssueTitle, setNewIssueTitle] = React.useState("");
|
||||
|
||||
React.useEffect(() => {
|
||||
refreshRepos();
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => { (async () => {
|
||||
if (!activeRepo) return;
|
||||
const b = await listBranches(activeRepo.id);
|
||||
setBranches(b);
|
||||
const cur = await getCurrentBranchId(activeRepo.id) || b.find(x=>x.name===activeRepo.defaultBranch)?.id;
|
||||
if (cur) {
|
||||
setCurrentBranchIdState(cur);
|
||||
await refreshHistory(activeRepo.id, cur);
|
||||
}
|
||||
setIssues(await listIssues(activeRepo.id));
|
||||
})(); }, [activeRepo?.id]);
|
||||
|
||||
async function refreshRepos() {
|
||||
const list = await listRepositories();
|
||||
setRepos(list);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue