mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-20 21:31:32 +03:00
d98611a04b
Fully implements webterm support for multiple dill terminal sessions. Remaining work includes styling, session creation safety (name-wise), and general cleanup. Co-authored-by: tomholford <tomholford@users.noreply.github.com> Co-authored-by: liam-fitzgerald <liam@tlon.io>
37 lines
907 B
TypeScript
37 lines
907 B
TypeScript
import { pokeTask } from '@urbit/api/term';
|
|
import api from './api';
|
|
import React from 'react';
|
|
import useTermState from './state';
|
|
import { Tab } from './Tab';
|
|
|
|
export const Tabs = () => {
|
|
const { sessions, names } = useTermState();
|
|
|
|
const onAddClick = () => {
|
|
const name = prompt('please entew a session name uwu');
|
|
if (!name) {
|
|
return;
|
|
}
|
|
//TODO name must be @ta
|
|
api.poke(pokeTask(name, { open: { term: 'hood', apps: [{ who: '~'+(window as any).ship, app: 'dojo' }] } }));
|
|
useTermState.getState().set(state => {
|
|
state.names = [name, ...state.names].sort();
|
|
state.selected = name;
|
|
state.sessions[name] = null;
|
|
});
|
|
|
|
|
|
}
|
|
|
|
return (
|
|
<div className="tabs">
|
|
{ names.map((n, i) => {
|
|
return (
|
|
<Tab session={sessions[n]} name={n} key={i} />
|
|
);
|
|
})}
|
|
<button onClick={onAddClick}>+</button>
|
|
</div>
|
|
);
|
|
};
|