Skip to content

Commit 1052a1c

Browse files
committed
add double click to render
1 parent 8bc9822 commit 1052a1c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

ui/src/components/repo/pod.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export function DeckTitle({ id }) {
285285

286286
function PodSummary({ id }) {
287287
let pod = useSelector((state) => state.repo.pods[id]);
288+
// console.log("PodSummary", id, pod.running);
288289
return (
289290
<Box as="span">
290291
{pod.running && <Spinner />}
@@ -598,6 +599,7 @@ function WysiwygPod({ pod }) {
598599
);
599600
}
600601
function Pod({ id, draghandle }) {
602+
console.log("Rendering pod", id);
601603
return (
602604
<PodWrapper id={id} draghandle={draghandle}>
603605
<ThePod id={id} />
@@ -697,6 +699,7 @@ function PodDiff({ id, setShowDiff }) {
697699
}
698700

699701
function PodWrapper({ id, draghandle, children }) {
702+
// console.log("PodWrapper", id);
700703
const pod = useSelector((state) => state.repo.pods[id]);
701704
const devmode = useSelector((state) => state.repo.dev);
702705
const dispatch = useDispatch();
@@ -955,7 +958,24 @@ function ThePod({ id }) {
955958
></Textarea>
956959
);
957960
} else if (pod.type === "CODE") {
958-
return <CodePod id={id} />;
961+
// return <Text>CODE</Text>;
962+
if (pod.render) {
963+
return <CodePod id={id} />;
964+
} else {
965+
return (
966+
<Code
967+
onDoubleClick={() => {
968+
// console.log("Double clicked!");
969+
dispatch(repoSlice.actions.setPodRender({ id, value: true }));
970+
}}
971+
whiteSpace="pre-wrap"
972+
fontSize="sm"
973+
>
974+
{pod.content}
975+
<Text>(Read-only)</Text>
976+
</Code>
977+
);
978+
}
959979
} else if (pod.type === "REPL") {
960980
return <ReplPod pod={pod} />;
961981
} else if (pod.type === "DECK") {

ui/src/lib/reducers/pod.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,8 @@ export default {
181181
// pod.dirty = pod.remoteHash !== hashPod(pod);
182182
pod.dirty = true;
183183
},
184+
setPodRender: (state, action) => {
185+
const { id, value } = action.payload;
186+
state.pods[id].render = value;
187+
},
184188
};

0 commit comments

Comments
 (0)