Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/predefined configs #28

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import esbuild, { BuildOptions } from "esbuild";
import * as dotenv from "dotenv";
dotenv.config();
import MINIMAL_PREDEFINED_CONFIG from "../static/minimal-predefined.json";

const ENTRY_POINTS = {
typescript: ["static/main.ts"],
Expand All @@ -17,6 +18,7 @@ export const esbuildOptions: BuildOptions = {
loader: Object.fromEntries(DATA_URL_LOADERS.map((ext) => [ext, "dataurl"])),
outdir: "static/dist",
define: createEnvDefines([], {
MINIMAL_PREDEFINED_CONFIG: JSON.stringify(MINIMAL_PREDEFINED_CONFIG),
SUPABASE_STORAGE_KEY: generateSupabaseStorageKey(),
NODE_ENV: process.env.NODE_ENV || "development",
SUPABASE_URL: process.env.SUPABASE_URL || "https://wfzpewmlyiozupulbuur.supabase.co",
Expand Down
8 changes: 4 additions & 4 deletions static/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthService } from "./scripts/authentication";
import { ManifestFetcher } from "./scripts/fetch-manifest";
import { ManifestRenderer } from "./scripts/render-manifest";
import { renderOrgPicker } from "./scripts/rendering/org-select";
import { renderOrgSelector } from "./scripts/rendering/org-select";
import { toastNotification } from "./utils/toaster";

async function handleAuth() {
Expand All @@ -26,17 +26,17 @@ export async function mainModule() {
if (Object.keys(cache).length === 0) {
renderer.manifestGuiBody.dataset.loading = "true";
const killNotification = toastNotification("Fetching manifest data...", { type: "info", shouldAutoDismiss: true });
renderOrgPicker(renderer, []);
renderOrgSelector(renderer, []);

await fetcher.fetchMarketplaceManifests();
await fetcher.fetchOfficialPluginConfig();
killNotification();
renderer.manifestGuiBody.dataset.loading = "false";
}

renderOrgPicker(renderer, userOrgs);
renderOrgSelector(renderer, userOrgs);
} else {
renderOrgPicker(renderer, []);
renderOrgSelector(renderer, []);
}
} catch (error) {
if (error instanceof Error) {
Expand Down
9 changes: 8 additions & 1 deletion static/manifest-gui.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ header #uos-logo path {
transition: opacity 0.25s cubic-bezier(0, 1, 1, 1);
}

.template-buttons {
display: flex;
justify-content: center;
gap: 8px;
margin: 8px 0;
}

#manifest-gui.plugin-editor {
width: 100%;
}
Expand Down Expand Up @@ -255,7 +262,7 @@ button#reset-to-default::before {
content: "♻️";
}
button#reset-to-default:hover::before {
content: "Use Defaults";
content: "Reset";
}
button#reset-to-default:active::before {
content: "♻️♻️♻️♻️♻️";
Expand Down
11 changes: 11 additions & 0 deletions static/minimal-predefined.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"text-conversation-rewards": {
"yamlConfig": "- uses:\n - plugin: ubiquity-os-marketplace/text-conversation-rewards@development\n skipBotEvents: false\n with:\n logLevel: \"debug\"\n evmNetworkId: 100\n evmPrivateEncrypted: \"gdo_iiUND1poZaibNme5oUsG1g8RDEmtI41uLgZjxW8WwxnQZb0DHkOBcISuwobxyKEyzeGQC9KzjkWXv0_OCv-kuUHy4myWNIhs4j3odyvh1XUP7pZFeuVEiASmKQBGkzlKRii5dA0liXtHnhciZQi5N8E7-cdOMbA\" # https://github.com/ubiquibot/conversation-rewards/pull/111#issuecomment-2348639931\n erc20RewardToken: \"0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d\"\n incentives:\n requirePriceLabel: true\n contentEvaluator: {}\n userExtractor:\n enabled: true\n redeemTask: true\n dataPurge: {}\n formattingEvaluator:\n multipliers:\n - role:\n - ISSUE_SPECIFICATION\n multiplier: 3\n rewards:\n wordValue: 0.1\n html:\n br:\n score: 0\n countWords: true\n code:\n score: 5\n countWords: false\n p:\n score: 0\n countWords: true\n em:\n score: 0\n countWords: true\n img:\n score: 5\n countWords: true\n strong:\n score: 0\n countWords: false\n blockquote:\n score: 0\n countWords: false\n h1:\n score: 1\n countWords: true\n h2:\n score: 1\n countWords: true\n h3:\n score: 1\n countWords: true\n h4:\n score: 1\n countWords: true\n h5:\n score: 1\n countWords: true\n h6:\n score: 1\n countWords: true\n a:\n score: 5\n countWords: true\n li:\n score: 0.5\n countWords: true\n ul:\n score: 0\n countWords: true\n td:\n score: 0\n countWords: true\n hr:\n score: 0\n countWords: true\n pre:\n score: 0\n countWords: false\n ol:\n score: 0\n countWords: true\n - role:\n - ISSUE_AUTHOR\n - ISSUE_COLLABORATOR\n - PULL_COLLABORATOR\n multiplier: 1\n rewards:\n wordValue: 0.1\n html:\n br:\n score: 0\n countWords: true\n code:\n score: 5\n countWords: false\n p:\n score: 0\n countWords: true\n em:\n score: 0\n countWords: true\n img:\n score: 5\n countWords: true\n strong:\n score: 0\n countWords: false\n blockquote:\n score: 0\n countWords: false\n h1:\n score: 1\n countWords: true\n h2:\n score: 1\n countWords: true\n h3:\n score: 1\n countWords: true\n h4:\n score: 1\n countWords: true\n h5:\n score: 1\n countWords: true\n h6:\n score: 1\n countWords: true\n a:\n score: 5\n countWords: true\n li:\n score: 0.5\n countWords: true\n ul:\n score: 0\n countWords: true\n td:\n score: 0\n countWords: true\n hr:\n score: 0\n countWords: true\n pre:\n score: 0\n countWords: false\n ol:\n score: 0\n countWords: true\n - role:\n - ISSUE_CONTRIBUTOR\n - ISSUE_ASSIGNEE\n multiplier: 0.25\n rewards:\n wordValue: 0.1\n html:\n br:\n score: 0\n countWords: true\n code:\n score: 5\n countWords: false\n p:\n score: 0\n countWords: true\n em:\n score: 0\n countWords: true\n img:\n score: 5\n countWords: true\n strong:\n score: 0\n countWords: false\n blockquote:\n score: 0\n countWords: false\n h1:\n score: 1\n countWords: true\n h2:\n score: 1\n countWords: true\n h3:\n score: 1\n countWords: true\n h4:\n score: 1\n countWords: true\n h5:\n score: 1\n countWords: true\n h6:\n score: 1\n countWords: true\n a:\n score: 5\n countWords: true\n li:\n score: 0.5\n countWords: true\n ul:\n score: 0\n countWords: true\n td:\n score: 0\n countWords: true\n hr:\n score: 0\n countWords: true\n pre:\n score: 0\n countWords: false\n ol:\n score: 0\n countWords: true\n - role:\n - PULL_SPECIFICATION\n - PULL_AUTHOR\n - PULL_CONTRIBUTOR\n - PULL_ASSIGNEE\n multiplier: 0\n rewards:\n wordValue: 0\n html:\n br:\n score: 0\n countWords: true\n code:\n score: 5\n countWords: false\n p:\n score: 0\n countWords: true\n em:\n score: 0\n countWords: true\n img:\n score: 5\n countWords: true\n strong:\n score: 0\n countWords: false\n blockquote:\n score: 0\n countWords: false\n h1:\n score: 1\n countWords: true\n h2:\n score: 1\n countWords: true\n h3:\n score: 1\n countWords: true\n h4:\n score: 1\n countWords: true\n h5:\n score: 1\n countWords: true\n h6:\n score: 1\n countWords: true\n a:\n score: 5\n countWords: true\n li:\n score: 0.5\n countWords: true\n ul:\n score: 0\n countWords: true\n td:\n score: 0\n countWords: true\n hr:\n score: 0\n countWords: true\n pre:\n score: 0\n countWords: false\n ol:\n score: 0\n countWords: true\n wordCountExponent: 0.85\n permitGeneration:\n enabled: true\n githubComment:\n post: true\n debug: false\n dataCollection:\n maxAttempts: 10\n delayMs: 1000"
},
"command-start-stop": {
"yamlConfig": "- skipBotEvents: false\n uses:\n - plugin: https://ubiquity-os-command-start-stop-development.ubiquity.workers.dev\n with:\n reviewDelayTolerance: \"3 Days\"\n taskStaleTimeoutDuration: \"30 Days\"\n startRequiresWallet: true\n maxConcurrentTasks:\n member: 2\n contributor: 2\n emptyWalletText: \"Please set your wallet address with the /wallet command first and try again.\"\n rolesWithReviewAuthority:\n - COLLABORATOR\n - OWNER\n - MEMBER\n - ADMIN\n requiredLabelsToStart: [\"Priority: 3 (High)\", \"Priority: 4 (Urgent)\", \"Priority: 5 (Emergency)\"]"
},
"daemon-pricing": {
"yamlConfig": "- uses:\n - plugin: https://ubiquity-os-daemon-pricing-development.ubiquity.workers.dev\n with:\n labels:\n time:\n - \"Time: <15 Minutes\"\n - \"Time: <1 Hour\"\n - \"Time: <2 Hours\"\n - \"Time: <4 Hours\"\n - \"Time: <1 Day\"\n - \"Time: <1 Week\"\n - \"Time: <2 Weeks\"\n - \"Time: <1 Month\"\n priority:\n - \"Priority: 1 (Normal)\"\n - \"Priority: 2 (Medium)\"\n - \"Priority: 3 (High)\"\n - \"Priority: 4 (Urgent)\"\n - \"Priority: 5 (Emergency)\"\n basePriceMultiplier: 2\n publicAccessControl:\n setLabel: true\n fundExternalClosedIssue: false"
}
}
18 changes: 15 additions & 3 deletions static/scripts/config-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Plugin, PluginConfig } from "../types/plugins";
import { Octokit } from "@octokit/rest";
import { toastNotification } from "../utils/toaster";
import { CONFIG_FULL_PATH, CONFIG_ORG_REPO } from "@ubiquity-os/plugin-sdk/constants";
import { AuthService } from "./authentication";

/**
* Responsible for fetching, parsing, and updating the user's installed plugin configurations.
Expand Down Expand Up @@ -119,7 +120,11 @@ export class ConfigParser {
return this.createOrUpdateFileContents(org, repo, path, octokit);
}

async createOrUpdateFileContents(org: string, repo: string, path: string, octokit: Octokit) {
async createOrUpdateFileContents(org: string, repo: string, path: string, octokit: AuthService["octokit"]) {
if (!octokit) {
throw new Error("Octokit not found");
}

const recentSha = await octokit.repos.getContent({
owner: org,
repo: repo,
Expand Down Expand Up @@ -177,7 +182,11 @@ export class ConfigParser {
this.saveConfig();
}

loadConfig(): string {
loadConfig(config?: string) {
if (config) {
this.saveConfig(config);
}

if (!this.newConfigYml) {
this.newConfigYml = localStorage.getItem("config") as string;
}
Expand All @@ -193,7 +202,10 @@ export class ConfigParser {
return this.newConfigYml;
}

saveConfig() {
saveConfig(config?: string) {
if (config) {
this.newConfigYml = config;
}
if (this.newConfigYml) {
localStorage.setItem("config", this.newConfigYml);
}
Expand Down
Loading
Loading