MCPcopy Create free account
hub / github.com/chhoumann/quickadd / display

Method display

src/gui/ProviderPickerModal.ts:34–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32 }
33
34 private display() {
35 this.contentEl.empty();
36 this.modalEl.addClass("qa-ai-wide-modal");
37 this.contentEl.addClass("qa-ai-scroll-content");
38 this.addHeader(this.contentEl);
39
40 const grid = this.contentEl.createDiv({ cls: "qa-provider-grid" });
41
42 for (const preset of PROVIDER_PRESETS) {
43 const card = grid.createDiv({ cls: "qa-provider-card" });
44
45 card.createEl("div", { text: preset.name, cls: "qa-provider-card-title" });
46
47 card.createEl("div", {
48 text: preset.endpoint,
49 cls: "qa-provider-card-endpoint",
50 });
51
52 if (preset.doc) {
53 const doc = card.createEl("a", { text: "Docs", href: preset.doc });
54 doc.target = "_blank";
55 doc.rel = "noopener noreferrer";
56 }
57
58 let apiKeyRef = "";
59 const apiSetting = new Setting(card)
60 .setName("API Key")
61 .setDesc("Select a secret from SecretStorage")
62 .addComponent((el) => new SecretComponent(this.app, el)
63 .setValue(apiKeyRef)
64 .onChange((value) => {
65 apiKeyRef = value;
66 }));
67
68 apiSetting.settingEl.addClass("qa-provider-api-setting");
69
70 apiSetting.addButton((b) => {
71 b.setButtonText("Connect").setCta().onClick(() => {
72 try {
73 const selectedSecret = apiKeyRef.trim();
74
75 // Basic validation
76 try {
77 // Validate endpoint URL format
78
79 new URL(preset.endpoint);
80 } catch {
81 new Notice(`Invalid endpoint URL for ${preset.name}.`);
82 return;
83 }
84
85 const lower = preset.endpoint.toLowerCase();
86 const likelyRequiresKey = [
87 "openai.com",
88 "generativelanguage.googleapis.com",
89 "anthropic",
90 "api.groq.com",
91 "together.xyz",

Callers 1

constructorMethod · 0.95

Calls 13

addHeaderMethod · 0.95
addComponentMethod · 0.80
pushMethod · 0.80
closeMethod · 0.65
addClassMethod · 0.45
setDescMethod · 0.45
setNameMethod · 0.45
onChangeMethod · 0.45
setValueMethod · 0.45
addButtonMethod · 0.45
onClickMethod · 0.45
setCtaMethod · 0.45

Tested by

no test coverage detected