feat(files): New → Clone repository clones into the open folder
The File Explorer's New menu (and its right-click menu) gains Clone repository: it clones a URL into the folder it has open — of the user's own home or of a workspace's own folder — through POST /api/lanes/clone with that folder as `parent`, so the URL allowlist, the own-folder check and the folder account's own git identity all apply, and opens a workspace on the clone. ECREDENTIALS asks for a login, ESSHAUTH points to Settings → Git. GET /api/homes now gives `me` its absolute `dir`. Keys typed in the dialog never reach the explorer's shortcuts (Backspace / Delete).
This commit is contained in:
@@ -79,6 +79,8 @@ describe("File Explorer on the home", () => {
|
||||
r.body.homes.map((h) => [h.id, h.readOnly]),
|
||||
[["me", false]]
|
||||
);
|
||||
// Its absolute folder: where the Files page's Clone repository clones to.
|
||||
assert.equal(r.body.homes[0].dir, path.resolve(HOME));
|
||||
});
|
||||
|
||||
it("lists the home with every top-level dot entry hidden", async () => {
|
||||
|
||||
+12
-3
@@ -49,14 +49,23 @@ function homeOf(user) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The homes `req` may open: `{ id: "me" | <username>, label, readOnly }`.
|
||||
* The homes `req` may open: `{ id: "me" | <username>, label, readOnly }`,
|
||||
* `me` with its absolute `dir`.
|
||||
* Others' only for an admin, and only those that resolve to a folder.
|
||||
*/
|
||||
function listHomes(req) {
|
||||
const out = [];
|
||||
const me = req.user || null;
|
||||
if (homeOf(me))
|
||||
out.push({ id: "me", label: me?.displayName || me?.username || "", readOnly: false });
|
||||
const mine = homeOf(me);
|
||||
// `dir` for the caller's own home only: the Files page clones into it.
|
||||
if (mine) {
|
||||
out.push({
|
||||
id: "me",
|
||||
label: me?.displayName || me?.username || "",
|
||||
readOnly: false,
|
||||
dir: path.resolve(mine),
|
||||
});
|
||||
}
|
||||
if (me?.role === "admin" && auth.isServerMode()) {
|
||||
for (const u of auth.listUsers()) {
|
||||
if (u.id === me.id || u.disabled) continue;
|
||||
|
||||
Reference in New Issue
Block a user