Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added execution order display to code cells #13502

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ export class NotebookCellActionContribution implements MenuContribution, Command
});

// Notebook Cell extra execution options
menus.registerIndependentSubmenu(NotebookCellActionContribution.CONTRIBUTED_CELL_EXECUTION_MENU,
nls.localizeByDefault('More...'),
{ role: CompoundMenuNodeRole.Flat, icon: codicon('chevron-down') });
menus.getMenu(NotebookCellActionContribution.CODE_CELL_SIDEBAR_MENU).addNode(menus.getMenuNode(NotebookCellActionContribution.CONTRIBUTED_CELL_EXECUTION_MENU));
// menus.registerIndependentSubmenu(NotebookCellActionContribution.CONTRIBUTED_CELL_EXECUTION_MENU,
// nls.localizeByDefault('More...'),
// { role: CompoundMenuNodeRole.Flat, icon: codicon('chevron-down') });
// menus.getMenu(NotebookCellActionContribution.CODE_CELL_SIDEBAR_MENU).addNode(menus.getMenuNode(NotebookCellActionContribution.CONTRIBUTED_CELL_EXECUTION_MENU));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not needed anymore it could be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not like its not needed. We will have to add it again at a later point in time, but since its currently not working i removed it for now


// code cell output sidebar menu
menus.registerSubmenu(
Expand Down
24 changes: 18 additions & 6 deletions packages/notebook/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,28 @@
background-color: var(--theia-editor-background);
}

.theia-notebook-cell-sidebar {
.theia-notebook-cell-sidebar-toolbar {
display: flex;
flex-direction: column;
padding: 2px;
background-color: var(--theia-editor-background);
flex-grow: 1;
}

.theia-notebook-cell-sidebar {
display: flex;
flex-direction: column;
}

.theia-notebook-code-cell-execution-order {
height: 35px;
display: block;
font-family: var(--monaco-monospace-font);
font-size: 10px;
opacity: 0.7;
text-align: center;
white-space: pre;
padding: 5px 0;
}

.theia-notebook-cell-toolbar-item {
Expand All @@ -159,11 +176,6 @@
flex-direction: row;
}

.theia-notebook-cell-sidebar {
display: flex;
flex-direction: column;
}

.theia-notebook-main-container {
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class NotebookCellToolbar extends NotebookCellActionBar {
export class NotebookCellSidebar extends NotebookCellActionBar {

override render(): React.ReactNode {
return <div className='theia-notebook-cell-sidebar'>
return <div className='theia-notebook-cell-sidebar-toolbar'>
{this.state.inlineItems.filter(e => e.isVisible()).map(item => this.renderItem(item))}
</div>;
}
Expand Down
22 changes: 19 additions & 3 deletions packages/notebook/src/browser/view/notebook-code-cell-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ export class NotebookCodeCellRenderer implements CellRenderer {
render(notebookModel: NotebookModel, cell: NotebookCellModel, handle: number): React.ReactNode {
return <div>
<div className='theia-notebook-cell-with-sidebar'>
<div>
<div className='theia-notebook-cell-sidebar'>
{this.notebookCellToolbarFactory.renderSidebar(NotebookCellActionContribution.CODE_CELL_SIDEBAR_MENU, notebookModel, cell)}
{/* cell-execution-order needs an own component. Could be a little more complicated
<p className='theia-notebook-code-cell-execution-order'>{`[${cell.exec ?? ' '}]`}</p> */}
<CodeCellExecutionOrder cell={cell} />
</div>
<div className='theia-notebook-cell-editor-container'>
<CellEditor notebookModel={notebookModel} cell={cell}
Expand Down Expand Up @@ -269,3 +268,20 @@ export class NotebookCodeCellOutputs extends React.Component<NotebookCellOutputP
}

}

interface NotebookCellExecutionOrderProps {
cell: NotebookCellModel;
}

function CodeCellExecutionOrder({ cell }: NotebookCellExecutionOrderProps): React.JSX.Element {
const [executionOrder, setExecutionOrder] = React.useState(cell.internalMetadata.executionOrder ?? ' ');

React.useEffect(() => {
const listener = cell.onDidChangeInternalMetadata(e => {
setExecutionOrder(cell.internalMetadata.executionOrder ?? ' ');
});
return () => listener.dispose();
}, []);

return <span className='theia-notebook-code-cell-execution-order'>{`[${executionOrder}]`}</span>;
}
Loading