MCPcopy Create free account
hub / github.com/bytebase/bytebase / RawStringEditor

Function RawStringEditor

frontend/src/react/components/ExprEditor.tsx:1276–1319  ·  view source on GitHub ↗
({
  expr,
  groupPath,
  operandIndex,
}: {
  expr: RawStringExpr;
  groupPath: Path;
  operandIndex: number;
})

Source from the content-addressed store, hash-verified

1274// ============================================================
1275
1276function RawStringEditor({
1277 expr,
1278 groupPath,
1279 operandIndex,
1280}: {
1281 expr: RawStringExpr;
1282 groupPath: Path;
1283 operandIndex: number;
1284}) {
1285 const { readonly } = useExprEditorCtx();
1286 const doUpdate = useImmutableUpdate(groupPath);
1287
1288 return (
1289 <div className="w-full flex items-start gap-x-1">
1290 <textarea
1291 className="flex-1 min-h-16 max-h-24 px-2 py-1 text-sm rounded-xs border border-control-border bg-background resize-y disabled:opacity-50"
1292 placeholder="Enter raw CEL expression"
1293 value={expr.content}
1294 disabled={readonly}
1295 rows={2}
1296 onChange={(e) => {
1297 const newContent = e.target.value;
1298 doUpdate((group) => {
1299 const raw = group.args[operandIndex] as RawStringExpr;
1300 raw.content = newContent;
1301 });
1302 }}
1303 />
1304 {!readonly && (
1305 <button
1306 type="button"
1307 className="shrink-0 size-7 flex items-center justify-center rounded-xs text-control-placeholder hover:text-control hover:bg-control-bg"
1308 onClick={() =>
1309 doUpdate((group) => {
1310 group.args.splice(operandIndex, 1);
1311 })
1312 }
1313 >
1314 <Trash2 className="size-3.5" />
1315 </button>
1316 )}
1317 </div>
1318 );
1319}
1320
1321// ============================================================
1322// ConditionGroup (recursive)

Callers

nothing calls this directly

Calls 3

useExprEditorCtxFunction · 0.85
useImmutableUpdateFunction · 0.85
doUpdateFunction · 0.85

Tested by

no test coverage detected