feat: new tbl_col and tbl_cell in theme system for spotter table styling (#2391)

This commit is contained in:
三咲雅 · Misaki Masa 2025-02-23 23:37:35 +08:00 committed by GitHub
parent 7b4c4eae40
commit 36ed32d2c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 34 additions and 20 deletions

View file

@ -1,4 +1,6 @@
const LABEL_NAME = "needs info"
const RE_VERSION = /Yazi\s+Version\s*:\s\d+\.\d+\.\d+\s\(/gm
const RE_DEPENDENCIES = /Dependencies\s+[/a-z]+\s*:\s/gm
const RE_CHECKLIST = /#{3}\s+Checklist\s+(?:^-\s+\[x]\s+.+?\n){2}/gm
function bugReportBody(creator, content, hash) {
@ -10,14 +12,14 @@ function bugReportBody(creator, content, hash) {
- The bug can still be reproduced on the [newest nightly build](https://yazi-rs.github.io/docs/installation/#binaries).
- The debug information (\`yazi --debug\`) is updated for the newest nightly.
- All required fields in the checklist have been checked.
- All *required* fields in the checklist have been checked.
Issues with \`${LABEL_NAME}\` will be marked ready once edited with the proper content, or closed after 2 days of inactivity.
`
}
function featureRequestBody(creator, content, hash) {
if (content.includes(` (${hash} `) && RE_CHECKLIST.test(content)) {
function featureRequestBody(creator, content) {
if (RE_VERSION.test(content) && RE_DEPENDENCIES.test(content) && RE_CHECKLIST.test(content)) {
return null
}
@ -25,7 +27,7 @@ function featureRequestBody(creator, content, hash) {
- The requested feature does not exist in the [newest nightly build](https://yazi-rs.github.io/docs/installation/#binaries).
- The debug information (\`yazi --debug\`) is updated for the newest nightly.
- All required fields in the checklist have been checked.
- All *required* fields in the checklist have been checked.
Issues with \`${LABEL_NAME}\` will be marked ready once edited with the proper content, or closed after 2 days of inactivity.
`
@ -66,7 +68,7 @@ module.exports = async ({ github, context, core }) => {
await github.rest.issues.addLabels({
...context.repo,
issue_number: id,
labels: [LABEL_NAME],
labels : [LABEL_NAME],
})
await github.rest.issues.createComment({
...context.repo,
@ -77,7 +79,7 @@ module.exports = async ({ github, context, core }) => {
await github.rest.issues.removeLabel({
...context.repo,
issue_number: id,
name: LABEL_NAME,
name : LABEL_NAME,
})
}
} catch (e) {
@ -89,7 +91,7 @@ module.exports = async ({ github, context, core }) => {
try {
const { data: issues } = await github.rest.issues.listForRepo({
...context.repo,
state: "open",
state : "open",
labels: LABEL_NAME,
})
@ -102,13 +104,13 @@ module.exports = async ({ github, context, core }) => {
await github.rest.issues.update({
...context.repo,
issue_number: issue.number,
state: "closed",
state : "closed",
state_reason: "not_planned",
})
await github.rest.issues.createComment({
...context.repo,
issue_number: issue.number,
body: `This issue has been automatically closed because it was marked as \`${LABEL_NAME}\` for more than 2 days without updates.
body : `This issue has been automatically closed because it was marked as \`${LABEL_NAME}\` for more than 2 days without updates.
If the problem persists, please file a new issue and complete the issue template so we can capture all the details necessary to investigate further.`,
})
}
@ -136,7 +138,7 @@ If the problem persists, please file a new issue and complete the issue template
const body = bugReportBody(creator, content, hash)
await updateLabels(id, !!body, body)
} else if (await hasLabel(id, "feature")) {
const body = featureRequestBody(creator, content, hash)
const body = featureRequestBody(creator, content)
await updateLabels(id, !!body, body)
}
}

View file

@ -128,6 +128,10 @@ btn_labels = [ " [Y]es ", " (N)o " ]
border = { fg = "blue" }
title = { fg = "blue" }
# Table
tbl_col = { fg = "blue" }
tbl_cell = { fg = "yellow", reversed = true }
# : }}}

View file

@ -128,6 +128,10 @@ btn_labels = [ " [Y]es ", " (N)o " ]
border = { fg = "blue" }
title = { fg = "blue" }
# Table
tbl_col = { fg = "blue" }
tbl_cell = { fg = "yellow", reversed = true }
# : }}}

View file

@ -131,10 +131,11 @@ pub struct Which {
#[derive(Deserialize, Serialize)]
pub struct Confirm {
pub border: Style,
pub title: Style,
pub content: Style,
pub list: Style,
pub border: Style,
pub title: Style,
pub content: Style,
pub list: Style,
pub btn_yes: Style,
pub btn_no: Style,
pub btn_labels: [String; 2],
@ -144,6 +145,9 @@ pub struct Confirm {
pub struct Spot {
pub border: Style,
pub title: Style,
pub tbl_col: Style,
pub tbl_cell: Style,
}
#[derive(Deserialize, Serialize)]

View file

@ -23,8 +23,8 @@ function M:spot(job)
:area(ui.Pos { "center", w = 60, h = 20 })
:row(1)
:col(1)
:col_style(ui.Style():fg("blue"))
:cell_style(ui.Style():fg("yellow"):reverse())
:col_style(th.spot.tbl_col)
:cell_style(th.spot.tbl_cell)
:widths { ui.Constraint.Length(14), ui.Constraint.Fill(1) }
)
end

View file

@ -33,8 +33,8 @@ function M:spot(job)
:row(job.skip)
:row(1)
:col(1)
:col_style(ui.Style():fg("blue"))
:cell_style(ui.Style():fg("yellow"):reverse())
:col_style(th.spot.tbl_col)
:cell_style(th.spot.tbl_cell)
:widths { ui.Constraint.Length(14), ui.Constraint.Fill(1) }
)
end

View file

@ -82,8 +82,8 @@ function M:spot(job)
:area(ui.Pos { "center", w = 60, h = 20 })
:row(1)
:col(1)
:col_style(ui.Style():fg("blue"))
:cell_style(ui.Style():fg("yellow"):reverse())
:col_style(th.spot.tbl_col)
:cell_style(th.spot.tbl_cell)
:widths { ui.Constraint.Length(14), ui.Constraint.Fill(1) }
)
end