Initial import of streamline
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
import { useState } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import "../styles.css";
|
||||
import { api, type RetargetPreview } from "../lib/api";
|
||||
import type { BoardItem, Task } from "../types";
|
||||
import type { TaskRetarget } from "@bbbug/shared/alpha_branch";
|
||||
import { retargetBlock, retargetBranchName } from "@bbbug/shared/alpha_branch";
|
||||
import TaskCard from "../components/TaskCard";
|
||||
import TaskDetailDrawer from "../components/TaskDetailDrawer";
|
||||
import Toaster from "../components/Toaster";
|
||||
import DialogHost from "../components/DialogHost";
|
||||
|
||||
/**
|
||||
* 本地演示:抽屉 MR 行只留「打开 / 提交」,其它收进「MR 操作」弹窗;弹窗里的「重做到 alpha」。
|
||||
* 抽屉是真组件,喂假数据;MR 相关接口在这里打桩。「重做」跑完用 4 秒假装一轮。其它接口连不上,只看 MR 那一块。
|
||||
*
|
||||
* 打开方式:control-web 下 `API_TARGET=http://127.0.0.1:9 bun x vite --port 8092`,访问
|
||||
* /demo-mr-actions.html(API_TARGET 指向死端口,保证不会代理到任何真实服务)。
|
||||
* 批次设置里的「P1 及以上的新单走最新 alpha」在 /demo-batch-watch.html 的「设置」那一幕。
|
||||
*/
|
||||
|
||||
const now = Date.now();
|
||||
const mrUrl = (id: number) => `https://bits.bytedance.net/devops/1499114242/code/detail/${id}`;
|
||||
const LATEST: Record<string, string> = { android: "alpha/v4770", ios: "alpha/47.7.0" };
|
||||
const base = {
|
||||
kind: "bug" as const, platform: "android", priorityKey: 1, pinned: 0, createdAt: now - 26 * 3_600_000,
|
||||
statusChangedAt: now - 40 * 60_000, clusters: [], tags: [], watchers: ["rd.li@bytedance.com"],
|
||||
watcherLabels: { "rd.li@bytedance.com": "李研发" }, status: "manual_review",
|
||||
mrState: "opened", mergedIntoBaseAt: null, baseRef: null, repoKey: "tiktok-android", retarget: null,
|
||||
createdViaKeyId: null, createdViaSource: null, createdViaLabel: null, createdViaOwner: null, externalId: null,
|
||||
description: "增量托管自动导入。", executionPlan: null, reproSteps: null, remark: null, reviewHistory: [],
|
||||
attempts: 1, executorNodeId: "fei-android-01", branchName: "bugfix/comment-mention-highlight",
|
||||
workspacePath: "/tmp/demo", beforeEvidencePath: "/tmp/demo/before.png", afterEvidencePath: "/tmp/demo/after.png", failureReason: null,
|
||||
meegoId: "7388192503", meegoUrl: "https://meego.larkoffice.com/tiktok/issue/detail/7388192503", mrUrl: mrUrl(8500001),
|
||||
};
|
||||
const mk = (over: Record<string, unknown>): BoardItem => ({ ...base, ...over } as unknown as BoardItem);
|
||||
|
||||
interface Scenario { note: string; item: BoardItem; outcome?: "moved" | "failed" }
|
||||
const SCENARIOS: Scenario[] = [
|
||||
{ note: "① 最典型:在 develop 上修好了,群里说要进 alpha。点「MR 操作」→「重做」,4 秒后成功(真实是排队跑一轮),基线和 MR 都换掉", outcome: "moved",
|
||||
item: mk({ id: "a1", title: "【Android】评论区 @昵称不高亮" }) },
|
||||
{ note: "② 同样发起,但这一轮没成:回到待复核,原 MR 和基线不变,弹窗里写原因", outcome: "failed",
|
||||
item: mk({ id: "a2", title: "【Android】故事发布失败没有提示", branchName: "bugfix/story-publish-toast", mrUrl: mrUrl(8500002) }) },
|
||||
{ note: "③ 增量托管按 P1 自动走 alpha 的单:已经在最新 alpha 上,按钮置灰并说明原因", item: mk({ id: "a3", title: "【Android】P1 · 发布页崩溃", baseRef: "alpha/v4770", mrUrl: mrUrl(8500003), branchName: "bugfix/publish-crash" }) },
|
||||
{ note: "④ 赶上了上一趟 alpha,复核拖到新 alpha 切出来:可以从 alpha/47.6.0 再挪到 alpha/47.7.0(iOS 的分支写法)", outcome: "moved",
|
||||
item: mk({ id: "a4", title: "【iOS】个人页头像预览无法关闭", platform: "ios", repoKey: "tiktok-ios", baseRef: "alpha/47.6.0", mrUrl: mrUrl(8500004), branchName: "bugfix/avatar-preview-close-alpha-47.6.0" }) },
|
||||
{ note: "⑤ MR 已合入(已修复):弹窗里没有「重做」,只剩能做的;这里按经办人重建也没了,所以入口不出现", item: mk({ id: "a5", title: "【Android】关注页「更多」无响应", status: "fix_succeeded", mrState: "merged", mrUrl: mrUrl(8500005), mrMergedAt: now - 3_600_000 }) },
|
||||
{ note: "⑥ 新 MR 建好了但旧 MR 没关掉(没人有权限):入口有警示,弹窗给旧 MR 链接", item: mk({ id: "a6", title: "【Android】草稿箱封面加载慢", baseRef: "alpha/v4770", mrUrl: mrUrl(8500006),
|
||||
retarget: { ref: "alpha/v4770", fromBranch: "bugfix/draft-cover", fromBase: "develop", oldMrUrl: mrUrl(8400006), by: "rd.li", at: now, phase: "closing_old" } satisfies TaskRetarget }) },
|
||||
{ note: "⑦ MR 提交失败:红色「MR 提交失败」,失败引导直接展开在下面,点这一行收起 / 展开", item: mk({ id: "a7", title: "【Android】直播间礼物面板偶现空白", mrUrl: null, mrState: null, failureReason: "create_mr: permission denied: no developer role" }) },
|
||||
{ note: "⑧ 还没提交 MR:琥珀色「MR 未创建」,右边小字「提交 MR」,整行一点就提交;提交中整行不可点", item: mk({ id: "a8", title: "【Android】私信输入框高度抖动", mrUrl: null, mrState: null }) },
|
||||
{ note: "⑨ 这一轮重做正在跑:复核区没了,抽屉基本信息里有一行「移动基线」", item: mk({ id: "a9", title: "【Android】分享面板图标错位", status: "fixing",
|
||||
retarget: { ref: "alpha/v4770", fromBranch: "bugfix/share-icon", fromBase: "develop", oldMrUrl: mrUrl(8500009), by: "rd.li", at: now, phase: "running" } satisfies TaskRetarget }) },
|
||||
{ note: "⑩ Feature 还没提交 MR:先选「产品需求 / 技术优化」(产品需求必填 Meego 单,这里从描述预填),再选以谁的名义提交。提交参数打在控制台",
|
||||
item: mk({ id: "f1", kind: "feature", title: "Lemon8 - 投稿后 landing 到 feed", mrUrl: null, mrState: null, meegoId: null, meegoUrl: null,
|
||||
branchName: "feature/l8-post-landing", description: "投稿后落到 feed。需求单 https://meego.larkoffice.com/tiktok/story/detail/7382040553" }) },
|
||||
{ note: "⑪ Feature 已提交 MR:「查看 MR ↗」", item: mk({ id: "f2", kind: "feature", title: "Lemon8 - 发布页草稿自动保存", meegoId: null, meegoUrl: null, mrUrl: mrUrl(8500011) }) },
|
||||
];
|
||||
|
||||
const outcomes = new Map(SCENARIOS.map((s) => [s.item.id, s.outcome]));
|
||||
let items = new Map(SCENARIOS.map((s) => [s.item.id, s.item]));
|
||||
let render: () => void = () => {};
|
||||
const patch = (id: string, over: Record<string, unknown>) => { items = new Map(items).set(id, { ...items.get(id)!, ...over } as BoardItem); render(); };
|
||||
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
Object.assign(api, {
|
||||
me: async () => ({ email: "rd.li@bytedance.com", hasBitsToken: true }),
|
||||
retargetPreview: async (id: string): Promise<RetargetPreview> => {
|
||||
await wait(500);
|
||||
const t = items.get(id) as Task;
|
||||
const latest = LATEST[t.platform] ?? null;
|
||||
return { baseRef: t.baseRef, latest, block: retargetBlock(t, latest) };
|
||||
},
|
||||
retarget: async (id: string) => {
|
||||
await wait(400);
|
||||
const t = items.get(id) as Task;
|
||||
const ref = LATEST[t.platform]!;
|
||||
const retarget: TaskRetarget = { ref, fromBranch: t.branchName, fromBase: t.baseRef || "develop", oldMrUrl: t.mrUrl, by: "rd.li", at: Date.now(), phase: "running" };
|
||||
patch(id, { status: "fixing", retarget });
|
||||
void wait(4000).then(() => {
|
||||
if (outcomes.get(id) === "failed") {
|
||||
patch(id, { status: "manual_review", retarget: { ...retarget, phase: "failed", error: `修复依赖的代码在 ${ref} 上不存在,确认这个问题不在这条分支上` } });
|
||||
} else {
|
||||
patch(id, { status: "manual_review", baseRef: ref, retarget: null, branchName: retargetBranchName(t.branchName!, ref), mrUrl: mrUrl(8600000 + Math.floor(Math.random() * 999)) });
|
||||
}
|
||||
});
|
||||
return { ok: true, ref };
|
||||
},
|
||||
regenerateMrPreview: async () => { await wait(400); return { assignees: ["rd.li"], oldMrUrl: null, plan: { ok: true, noop: true, owner: "rd.li", message: "MR 已经在经办人 rd.li 名下,无需重建" } }; },
|
||||
mrSubmitters: async () => ({ candidates: [{ user: "rd.li", roles: ["self", "assignee"], hasToken: true }], defaultUser: "rd.li" }),
|
||||
featureMrSubmitters: async () => {
|
||||
await wait(300);
|
||||
return {
|
||||
candidates: [{ user: "liuxiangyu.jason", roles: ["creator", "watcher"], hasToken: false }, { user: "rd.li", roles: ["self"], hasToken: true }],
|
||||
defaultUser: "rd.li",
|
||||
meegoUrls: ["https://meego.larkoffice.com/tiktok/story/detail/7382040553"],
|
||||
};
|
||||
},
|
||||
submitMrFeature: async (id: string, _repoKey?: string, asUser?: string, choice?: unknown) => {
|
||||
console.log("[demo] submitMrFeature", JSON.stringify({ id, asUser, choice }));
|
||||
await wait(1500);
|
||||
const url = mrUrl(8700000 + Math.floor(Math.random() * 999));
|
||||
patch(id, { mrUrl: url, failureReason: null });
|
||||
return { ok: true, mrUrl: url, bitsUser: asUser };
|
||||
},
|
||||
submitMr: async (id: string) => { await wait(800); const url = mrUrl(8700000 + Math.floor(Math.random() * 999)); patch(id, { mrUrl: url, mrState: "opened", failureReason: null }); return { ok: true, mrUrl: url }; },
|
||||
});
|
||||
|
||||
function Demo() {
|
||||
const [, force] = useState(0);
|
||||
render = () => force((n) => n + 1);
|
||||
const [openId, setOpenId] = useState<string | null>(null);
|
||||
const open = openId ? items.get(openId) ?? null : null;
|
||||
return (
|
||||
<div className="op-demo">
|
||||
<h1>MR 操作弹窗 · 重做到 alpha · 演示</h1>
|
||||
<p className="op-sub">点卡片打开抽屉,看「人工复核」那块:MR 行只剩打开 / 提交,下面一个「MR 操作」。抽屉是真组件、数据是假的,其它接口连不上(下半部分会空着)。刷新页面重置。</p>
|
||||
<div className="op-cards">
|
||||
{SCENARIOS.map((s) => {
|
||||
const it = items.get(s.item.id)! as Task;
|
||||
return (
|
||||
<div key={s.item.id} className="op-case">
|
||||
<div className="op-note">{s.note}</div>
|
||||
<TaskCard item={it as BoardItem} onOpen={() => setOpenId(it.id)} />
|
||||
<div className="op-mr">基线 {it.baseRef || "develop"} · MR {it.mrUrl?.replace(/.*\//, "") ?? "无"} · {it.status}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<TaskDetailDrawer item={open} onClose={() => setOpenId(null)} />
|
||||
<Toaster />
|
||||
<DialogHost />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const style = document.createElement("style");
|
||||
style.textContent = `
|
||||
html, body, #root { height: auto !important; overflow: auto !important; }
|
||||
body { margin: 0; background: var(--bg, #f6f7f9); }
|
||||
.op-demo { padding: 24px 32px 64px; max-width: 1120px; color: var(--text); }
|
||||
.op-demo h1 { font-size: 20px; margin: 0 0 6px; }
|
||||
.op-sub { font-size: 13px; color: var(--muted); margin: 0 0 24px; }
|
||||
.op-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
|
||||
.op-case { display: flex; flex-direction: column; gap: 8px; }
|
||||
.op-note { font-size: 12px; color: var(--muted); line-height: 1.5; min-height: 54px; }
|
||||
.op-mr { font-size: 12px; color: var(--muted); font-family: var(--mono, monospace); }
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
|
||||
createRoot(document.getElementById("root")!).render(<Demo />);
|
||||
Reference in New Issue
Block a user