-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeeplink.ts
More file actions
70 lines (58 loc) · 2.29 KB
/
deeplink.ts
File metadata and controls
70 lines (58 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Button, Dialog } from "@fullstacked/ui";
import { createElement } from "./components/element";
import { Store } from "./store";
import { CONFIG_TYPE, Project as ProjectType } from "./types";
import { CloneGit } from "./views/add-project/clone-git";
import { Project } from "./views/project";
import config from "./editor_modules/config";
import { windAdminDialogClass } from "./deeplink.s";
// fullstacked://http//github.....git
export async function deeplink(fullstackedUrl: string) {
console.log(fullstackedUrl);
let url = fullstackedUrl.slice("fullstacked://".length);
const [protocol, ...rest] = url.split("//");
const [hostAndPath] = rest.join("//").split("?");
url = protocol + (protocol.endsWith(":") ? "" : ":") + "//" + hostAndPath;
if (!url.endsWith(".git")) {
url += ".git";
}
const runProjectIfFound = (projects: ProjectType[]) => {
const existingProject = projects?.find(
(p) => p.gitRepository?.url === url
);
if (existingProject) {
Store.projects.list.unsubscribe(runProjectIfFound);
let isUserMode = Store.preferences.isUserMode.check();
if (!isUserMode) {
Store.projects.setCurrent(existingProject);
}
Store.projects.build(existingProject);
return true;
}
return false;
};
const { projects } = await config.get(CONFIG_TYPE.PROJECTS);
if (runProjectIfFound(projects)) return;
Store.projects.list.subscribe(runProjectIfFound);
CloneGit(url);
}
export function WindowsAskForAdmin() {
const container = createElement("div");
container.classList.add(windAdminDialogClass);
container.innerHTML = `
<h1>Welcome,</h1>
<p>Please close FullStacked and reopen it with <b>Run as administrator</b>.<p>
<p>It will register the FullStacked deeplink and enable the <b>Open in FullStacked</b> feature in your system.</p>
<p>You can open FullStacked normally afterwards.</p>
<p>You only have to do this operation <b>once</b>.</p>
`;
const closeButton = Button({
text: "Close"
});
container.append(closeButton);
const { remove } = Dialog(container);
closeButton.onclick = () => {
remove();
fetch("/restart-admin");
};
}