generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
520 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from "react"; | ||
import { App, Modal } from "obsidian"; | ||
import { createRoot } from "react-dom/client"; | ||
import { Root } from "react-dom/client"; | ||
import { Button } from "@/components/ui/button"; | ||
import { navigateToPlusPage } from "@/plusUtils"; | ||
import { PLUS_UTM_MEDIUMS } from "@/constants"; | ||
import { ExternalLink } from "lucide-react"; | ||
|
||
function CopilotPlusExpiredModalContent({ onCancel }: { onCancel: () => void }) { | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<p> | ||
Your Copilot Plus license key is no longer valid. Please renew your subscription to continue | ||
using Copilot Plus. | ||
</p> | ||
<div className="flex gap-2 justify-end w-full"> | ||
<Button variant="ghost" onClick={onCancel}> | ||
Close | ||
</Button> | ||
<Button | ||
variant="default" | ||
onClick={() => { | ||
navigateToPlusPage(PLUS_UTM_MEDIUMS.EXPIRED_MODAL); | ||
}} | ||
> | ||
Renew Now <ExternalLink className="size-4" /> | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export class CopilotPlusExpiredModal extends Modal { | ||
private root: Root; | ||
|
||
constructor(app: App) { | ||
super(app); | ||
// https://docs.obsidian.md/Reference/TypeScript+API/Modal/setTitle | ||
// @ts-ignore | ||
this.setTitle("Thanks for being a Copilot Plus user 👋"); | ||
} | ||
|
||
onOpen() { | ||
const { contentEl } = this; | ||
this.root = createRoot(contentEl); | ||
|
||
const handleCancel = () => { | ||
this.close(); | ||
}; | ||
|
||
this.root.render(<CopilotPlusExpiredModalContent onCancel={handleCancel} />); | ||
} | ||
|
||
onClose() { | ||
this.root.unmount(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from "react"; | ||
import { App, Modal } from "obsidian"; | ||
import { createRoot } from "react-dom/client"; | ||
import { Root } from "react-dom/client"; | ||
import { Button } from "@/components/ui/button"; | ||
import { switchToPlusModels } from "@/plusUtils"; | ||
|
||
function CopilotPlusWelcomeModalContent({ | ||
onConfirm, | ||
onCancel, | ||
}: { | ||
onConfirm: () => void; | ||
onCancel: () => void; | ||
}) { | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<div> | ||
<p> | ||
Thanks for purchasing <b>Copilot Plus</b>! You have unlocked the full power of Copilot, | ||
featuring chat context, PDF and image support, exclusive chat and embedding models, and | ||
much more! | ||
</p> | ||
<p> | ||
Would you like to switch to the exclusive models now? You can always change this later in | ||
Settings. | ||
</p> | ||
</div> | ||
<div className="flex gap-2 justify-end w-full"> | ||
<Button variant="ghost" onClick={onCancel}> | ||
Switch Later | ||
</Button> | ||
<Button variant="default" onClick={onConfirm}> | ||
Switch Now | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export class CopilotPlusWelcomeModal extends Modal { | ||
private root: Root; | ||
|
||
constructor(app: App) { | ||
super(app); | ||
// https://docs.obsidian.md/Reference/TypeScript+API/Modal/setTitle | ||
// @ts-ignore | ||
this.setTitle("Welcome to Copilot Plus 🚀"); | ||
} | ||
|
||
onOpen() { | ||
const { contentEl } = this; | ||
this.root = createRoot(contentEl); | ||
|
||
const handleConfirm = () => { | ||
switchToPlusModels(); | ||
this.close(); | ||
}; | ||
|
||
const handleCancel = () => { | ||
this.close(); | ||
}; | ||
|
||
this.root.render( | ||
<CopilotPlusWelcomeModalContent onConfirm={handleConfirm} onCancel={handleCancel} /> | ||
); | ||
} | ||
|
||
onClose() { | ||
this.root.unmount(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { getSettings } from "@/settings/model"; | ||
|
||
export function logInfo(...args: any[]) { | ||
if (getSettings().debug) { | ||
console.log(...args); | ||
} | ||
} | ||
|
||
export function logError(...args: any[]) { | ||
if (getSettings().debug) { | ||
console.error(...args); | ||
} | ||
} |
Oops, something went wrong.