Skip to content

Commit e0b0bd5

Browse files
committed
fix remote runtime add button
1 parent 6762515 commit e0b0bd5

File tree

2 files changed

+18
-33
lines changed

2 files changed

+18
-33
lines changed

ui/src/components/repo/sidebar.js

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -208,21 +208,21 @@ function RuntimeItem({ socketAddress, mqAddress }) {
208208
{!edit && socketAddress !== "localhost:14321" && (
209209
<Box>
210210
<IconButton
211-
// onClick={() => {
212-
// updateRepoConfig({
213-
// variables: {
214-
// reponame,
215-
// config: JSON.stringify({
216-
// runtimes: produce(repoConfig.runtimes, (draft) => {
217-
// let idx = draft.findIndex(
218-
// ([addr1, addr2]) => addr1 === socketAddress
219-
// );
220-
// draft.splice(idx, 1);
221-
// }),
222-
// }),
223-
// },
224-
// });
225-
// }}
211+
onClick={() => {
212+
updateRepoConfig({
213+
variables: {
214+
reponame,
215+
config: JSON.stringify({
216+
runtimes: produce(repoConfig.runtimes, (draft) => {
217+
let idx = draft.findIndex(
218+
([addr1, addr2]) => addr1 === socketAddress
219+
);
220+
draft.splice(idx, 1);
221+
}),
222+
}),
223+
},
224+
});
225+
}}
226226
>
227227
<DeleteForeverTwoToneIcon sx={{ fontSize: 15, color: "red" }} />
228228
</IconButton>
@@ -263,24 +263,6 @@ function SidebarRuntime() {
263263
</Box>
264264
<Box>
265265
Runtimes:
266-
<ClickInputButton
267-
callback={(value) => {
268-
// dispatch(repoSlice.actions.addRuntime(value));
269-
// also save this to config
270-
updateRepoConfig({
271-
variables: {
272-
reponame,
273-
config: JSON.stringify({
274-
runtimes: produce(repoConfig.runtimes, (draft) => {
275-
draft[value] = true;
276-
}),
277-
}),
278-
},
279-
});
280-
}}
281-
>
282-
Add
283-
</ClickInputButton>
284266
<Button
285267
onClick={() => {
286268
dispatch(repoSlice.actions.addRuntime());

ui/src/lib/reducers/runtime.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export default {
2121
},
2222
addRuntime: (state, action) => {
2323
// socket address, MQ address, editing
24+
if (!state.repoConfig.runtimes) {
25+
state.repoConfig.runtimes = []
26+
}
2427
state.repoConfig.runtimes.push(["", ""]);
2528
},
2629
};

0 commit comments

Comments
 (0)