Skip to content

Commit

Permalink
settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
edde746 committed Aug 18, 2023
1 parent 2f2f475 commit f9a81c5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ jobs:

- name: Copy additional files
run: |
cp -r static/* dist || true
cp -r previews/* dist || true
cp README.md dist/README.md
printf -- "---\npermalink: /404.html\n---\n" > dist/404.md
printf -- "> **Note:** You accessed a link that returned a 404, probably by clicking one of the plugin links. You're supposed to copy the link address and add it into shelter.\n\n" >> dist/404.md
printf -- "remote_theme: jameshamann/jekyll-material-theme\n" > dist/_config.yml
cat README.md >> dist/404.md
# Documentation: https://github.com/peaceiris/actions-gh-pages
Expand Down
15 changes: 2 additions & 13 deletions plugins/gpt/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export function onLoad() {

let closeModal = null;
const openGenerationModal = async () => {
let hasValidKey = store.openaiKey?.startsWith("sk-");
let savedModel = store.model || "gpt-3.5-turbo";

let model = savedModel;
Expand Down Expand Up @@ -195,18 +194,6 @@ export function onLoad() {
>
Generate
</Button>
<Button
look={ButtonLooks.LINK}
grow={true}
onClick={() => {
// i am not designing this...
const key = window.prompt("Enter your OpenAI key");
store.openaiKey = key;
hasValidKey = true;
}}
>
{hasValidKey ? "Change" : "Set"} OpenAI key
</Button>
</div>
</ModalFooter>
</ModalRoot>
Expand Down Expand Up @@ -249,3 +236,5 @@ export function onUnload() {
unobserve();
popupButton?.remove();
}

export { default as settings } from "./settings";
17 changes: 17 additions & 0 deletions plugins/gpt/settings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const {
plugin: { store },
ui: { TextBox, Text },
} = shelter;

export default () => (
<>
<Text>OpenAI Key</Text>
<TextBox
placeholder="sk-..."
value={store.openaiKey}
onInput={(value) => {
store.openaiKey = value;
}}
/>
</>
);

0 comments on commit f9a81c5

Please sign in to comment.