From d39d7939c2186add93a2fc4e96913c8d1a1b735d Mon Sep 17 00:00:00 2001
From: Yannick Guern
Date: Fri, 9 Sep 2022 11:05:03 +0200
Subject: [PATCH] feat: Allow to hide some component inside the b64-playground
---
demo/playground-b64.html | 11 ++++++++++-
src/bc-datalog-playground-base64.ts | 29 ++++++++++++++++++++++-------
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/demo/playground-b64.html b/demo/playground-b64.html
index a9f5c79..b8fbfc7 100644
--- a/demo/playground-b64.html
+++ b/demo/playground-b64.html
@@ -17,7 +17,16 @@ demo biscuit
}
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/bc-datalog-playground-base64.ts b/src/bc-datalog-playground-base64.ts
index 12e8f75..be56a8b 100644
--- a/src/bc-datalog-playground-base64.ts
+++ b/src/bc-datalog-playground-base64.ts
@@ -19,6 +19,8 @@ import {
export class BCDatalogPlayground extends LitElement {
@property() fromHash = null;
@property() showBlocks = false;
+ @property() displayFacts = false;
+ @property() displayExternalKeys = false;
@state() code = "";
@state() blocks: Array<{ code: string; externalKey: string | null }> = [];
@state() private started = false;
@@ -67,6 +69,14 @@ export class BCDatalogPlayground extends LitElement {
console.log(newval)
this.showBlocks = newval === "true";
}
+
+ if (name === "displayfacts") {
+ this.displayFacts = newval === "true";
+ }
+
+ if (name === "displayexternalkeys") {
+ this.displayExternalKeys = newval === "true";
+ }
}
addBlock() {
@@ -141,28 +151,33 @@ export class BCDatalogPlayground extends LitElement {
) ?? [];
}
+
+ const factContent = html`Facts
+ `;
+
+ const facts = this.displayFacts ? factContent : html``;
+
return html`
${this.renderBlocks(markers.blocks, parseErrors.blocks)}
${this.renderAuthorizer(markers.authorizer, parseErrors.authorizer)}
Result
- Facts
-
+ ${facts}
`;
}
renderExternalKeyInput(blockId: number) {
if (blockId <= 0) return;
- return html`
+ return this.displayExternalKeys ? html`:
this.onUpdatedExternalKey(blockId, e)}
value=${this.blocks[blockId].externalKey}
/>
- `;
+ ` : html``;
}
renderBlock(
@@ -174,7 +189,7 @@ export class BCDatalogPlayground extends LitElement {
return html`
${
blockId == 0 ? "Authority block" : "Block " + blockId
- }: ${this.renderExternalKeyInput(blockId)}
+ } ${this.renderExternalKeyInput(blockId)}