MCPcopy
hub / github.com/remotely-save/remotely-save / onOpen

Method onOpen

pro/src/settingsPro.ts:46–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44 }
45
46 async onOpen() {
47 const { contentEl } = this;
48
49 const { authUrl, codeVerifier, codeChallenge } =
50 await generateAuthUrlAndCodeVerifierChallenge(false);
51 this.plugin.oauth2Info.verifier = codeVerifier;
52
53 const t = this.t;
54
55 const div2 = contentEl.createDiv();
56 div2.createEl(
57 "button",
58 {
59 text: t("modal_proauth_copybutton"),
60 },
61 (el) => {
62 el.onclick = async () => {
63 await navigator.clipboard.writeText(authUrl);
64 new Notice(t("modal_proauth_copynotice"));
65 };
66 }
67 );
68
69 contentEl.createEl("p").createEl("a", {
70 href: authUrl,
71 text: authUrl,
72 });
73
74 // manual paste
75 let authCode = "";
76 new Setting(contentEl)
77 .setName(t("modal_proauth_maualinput"))
78 .setDesc(t("modal_proauth_maualinput_desc"))
79 .addText((text) =>
80 text
81 .setPlaceholder("")
82 .setValue("")
83 .onChange((val) => {
84 authCode = val.trim();
85 })
86 )
87 .addButton(async (button) => {
88 button.setButtonText(t("submit"));
89 button.onClick(async () => {
90 new Notice(t("modal_proauth_maualinput_notice"));
91 try {
92 const authRes = await sendAuthReq(
93 codeVerifier ?? "verifier",
94 authCode,
95 async (e: any) => {
96 new Notice(t("protocol_pro_connect_fail"));
97 new Notice(`${e}`);
98 throw e;
99 }
100 );
101 console.debug(authRes);
102 const self = this;
103 setConfigBySuccessfullAuthInplace(

Callers

nothing calls this directly

Calls 8

sendAuthReqFunction · 0.90
getAndSaveProFeaturesFunction · 0.90
stringToFragmentFunction · 0.90
getAndSaveProEmailFunction · 0.90
featureListToTextFunction · 0.85
saveSettingsMethod · 0.80

Tested by

no test coverage detected