Skip to content

Commit

Permalink
feat: 展示插件配置项并支持修改 (#28)
Browse files Browse the repository at this point in the history
* feat: show plugin config and support edit

* feat: add issue template

* fix: use URLSearchParams

* refactor: only computed once

Co-authored-by: StarHeart <[email protected]>

* ci: add noneflow

---------

Co-authored-by: StarHeart <[email protected]>
  • Loading branch information
he0119 and StarHeartHunt authored Nov 28, 2024
1 parent ac63c4e commit 7fd0903
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 5 deletions.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Bug 反馈
title: "bug: 出现异常"
description: 提交 Bug 反馈以帮助我们改进代码
labels: ["bug"]
body:
- type: textarea
id: describe
attributes:
label: 描述问题
description: 清晰简洁地说明问题是什么
validations:
required: true

- type: textarea
id: reproduction
attributes:
label: 复现步骤
description: 提供能复现此问题的详细操作步骤
placeholder: |
1. 首先……
2. 然后……
3. 发生……
validations:
required: true

- type: textarea
id: expected
attributes:
label: 期望的结果
description: 清晰简洁地描述你期望发生的事情

- type: textarea
id: logs
attributes:
label: 截图或日志
description: 提供有助于诊断问题的任何日志和截图
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 功能建议
title: "feat: 功能描述"
description: 提出关于项目新功能的想法
labels: ["enhancement"]
body:
- type: textarea
id: problem
attributes:
label: 希望能解决的问题
description: 在使用中遇到什么问题而需要新的功能?
validations:
required: true

- type: textarea
id: feature
attributes:
label: 描述所需要的功能
description: 请说明需要的功能或解决方法
validations:
required: true
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/plugin_config_edit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 修改插件配置项
title: "plugin: {name}"
description: 修改插件测试时的配置项
labels: ["Plugin", "Config"]
body:
- type: input
id: pypi
attributes:
label: PyPI 项目名
description: PyPI 项目名
placeholder: e.g. nonebot-plugin-xxx
validations:
required: true

- type: input
id: module
attributes:
label: 插件 import 包名
description: 插件 import 包名
placeholder: e.g. nonebot_plugin_xxx
validations:
required: true

- type: textarea
id: config
attributes:
label: 插件配置项
description: 插件配置项
render: dotenv
placeholder: |
# e.g.
# KEY=VALUE
# KEY2=VALUE2
75 changes: 75 additions & 0 deletions .github/workflows/noneflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: NoneFlow

on:
issues:
types: [opened, reopened, edited]
pull_request_target:
types: [closed]
issue_comment:
types: [created]
pull_request_review:
types: [submitted]

concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number || github.run_id }}
cancel-in-progress: false

jobs:
noneflow:
runs-on: ubuntu-latest
name: noneflow
# do not run on forked PRs, do not run on not related issues, do not run on pr comments
if: |
!(
(
github.event.pull_request &&
(
github.event.pull_request.head.repo.fork ||
!(
contains(github.event.pull_request.labels.*.name, 'Plugin') ||
contains(github.event.pull_request.labels.*.name, 'Adapter') ||
contains(github.event.pull_request.labels.*.name, 'Bot')
)
)
) ||
(
github.event_name == 'issue_comment' && github.event.issue.pull_request
)
)
steps:
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_KEY }}

- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}

- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: .cache/.pre-commit
key: noneflow-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: NoneFlow
uses: docker://ghcr.io/nonebot/noneflow:latest
with:
config: >
{
"base": "master",
"plugin_path": "assets/plugins.json5",
"bot_path": "assets/bots.json5",
"adapter_path": "assets/adapters.json5",
"registry_repository": "nonebot/registry"
}
env:
APP_ID: ${{ secrets.APP_ID }}
PRIVATE_KEY: ${{ secrets.APP_KEY }}
PRE_COMMIT_HOME: /github/workspace/.cache/.pre-commit

- name: Fix permission
run: sudo chown -R $(whoami):$(id -ng) .cache/.pre-commit
4 changes: 1 addition & 3 deletions src/types/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export interface Metadata {

export interface Results {
[K: string]: {
inputs: {
[K in "configs"]: string;
};
config: string;
outputs: {
load: string;
metadata: Metadata | null;
Expand Down
37 changes: 35 additions & 2 deletions src/views/PluginPage.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed } from "vue";
import { mdiCheckCircle, mdiRocketLaunch } from "@mdi/js";
import { mdiCheckCircle, mdiRocketLaunch, mdiSquareEditOutline } from "@mdi/js";
import {
NA,
NAlert,
Expand All @@ -14,6 +14,7 @@ import {
NResult,
NSkeleton,
NTag,
NTooltip,
NText,
} from "naive-ui";
import { storeToRefs } from "pinia";
Expand Down Expand Up @@ -41,6 +42,19 @@ if (props.path) {
const plugin = computed(() => !loading.value && store.getPlugin(pypi, module));
const result = computed(() => !loading.value && store.getResult(pypi, module));
const editConfigUrl = computed(() => {
if (!plugin.value || !result.value) return "";
const params = new URLSearchParams({
template: "plugin_config_edit.yml",
title: `Plugin: 修改插件 ${plugin.value.name || ""} 的配置项`,
pypi,
module,
config: (result.value.config || "").trim(),
});
return `https://github.com/nonebot/registry/issues/new?${params.toString()}`;
});
</script>

<template>
Expand All @@ -61,6 +75,22 @@ const result = computed(() => !loading.value && store.getResult(pypi, module));
</n-page-header>
<div class="flex justify-between flex-col-reverse xl:flex-row">
<div class="flex-initial min-w-0 xl:max-w-3/4 xl:pr-32">
<n-p>
<n-h3
>配置项
<n-tooltip placement="right-end" trigger="hover">
<template #trigger>
<n-button text tag="a" :href="editConfigUrl" target="_blank">
<Icon :path="mdiSquareEditOutline" />
</n-button>
</template>
<span> 修改配置项 </span>
</n-tooltip>
</n-h3>
<pre class="overflow-auto font-mono">{{
result.config.trim() || "无"
}}</pre>
</n-p>
<n-p>
<n-h3>验证结果</n-h3>
<Validation
Expand Down Expand Up @@ -96,7 +126,10 @@ const result = computed(() => !loading.value && store.getResult(pypi, module));
</div>
<div class="min-w-1/4 pb-4">
<n-h3>插件信息</n-h3>
<n-p> 作者:<Author :author="plugin.author" /> </n-p>
<n-p>
作者:
<Author :author="plugin.author" />
</n-p>
<n-p> 版本:{{ plugin.version }} </n-p>
<n-p> 描述:{{ plugin.desc }} </n-p>
<n-p>
Expand Down

0 comments on commit 7fd0903

Please sign in to comment.