Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add file browser actions to the file browser toolbar#6888

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jtpio merged 15 commits intojupyter:mainfromjtpio:file-browser-actions
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
CSS fixes
  • Loading branch information
@jtpio
jtpio committedMay 26, 2023
commita625777e19c42fc55764a4c873b261f51f447288
17 changes: 13 additions & 4 deletionspackages/tree-extension/src/fileactions.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,17 +24,19 @@ import React from 'react';
const Commands = ({
commands,
browser,
translator,
}: {
commands: CommandRegistry;
browser: FileBrowser;
translator: ITranslator;
}): JSX.Element => {
const trans = translator.load('notebook');
const selection = Array.from(browser.selectedItems());
const oneFolder = selection.some((item) => item.type === 'directory');
const multipleFiles =
selection.filter((item) => item.type === 'file').length > 1;
if (selection.length === 0) {
// TODO: trans
return <div>Select items to perform actions on them.</div>;
return <div>{trans.__('Select items to perform actions on them.')}</div>;
} else {
const buttons = ['delete'];
if (!oneFolder) {
Expand All@@ -56,6 +58,7 @@ const Commands = ({
commands={commands}
id={`filebrowser:${action}`}
args={{ toolbar: true }}
icon={undefined}
/>
))}
</>
Expand All@@ -80,8 +83,14 @@ const FileActions = ({
translator: ITranslator;
}): JSX.Element => {
return (
<UseSignal signal={selectionChanged}>
{(): JSX.Element => <Commands commands={commands} browser={browser} />}
<UseSignal signal={selectionChanged} shouldUpdate={() => true}>
{(): JSX.Element => (
<Commands
commands={commands}
browser={browser}
translator={translator}
/>
)}
</UseSignal>
);
};
Expand Down
8 changes: 5 additions & 3 deletionspackages/tree-extension/src/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -243,18 +243,20 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
nbTreeWidget.tabsMovable = false;

// The file browser currently does not provide a way to detect when
// the selection changes. So we define a custom mutation observer
// the selection changes. So we define a custom mutation observer as a workaround.
// TODO: add link to the upstream JupyterLab issue
const selectionChanged = new Signal<FileBrowser, void>(browser);
const observer = new MutationObserver((mutationList, observer) => {
for (const mutation of mutationList) {
console.log('mutation');
if (mutation.type === 'childList') {
console.log('change selection');
selectionChanged.emit(void 0);
}
}
});
const config = {attributes: true,childList: true, subtree: true };
observer.observe(browser.node, config);
const config = { childList: true, subtree: true };
observer.observe(browser.content.node, config);

// Create a toolbar item that adds buttons to the file browser toolbar
// to perform actions on the files
Expand Down
21 changes: 21 additions & 0 deletionspackages/tree-extension/style/base.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,3 +28,24 @@
.jp-DirListing-content .jp-DirListing-checkboxWrapper {
visibility: visible;
}

/* Action buttons */

.jp-FileBrowser-toolbar > .jp-FileActions.jp-Toolbar-item {
display: flex;
flex-direction: row;
}

.jp-FileActions .jp-ToolbarButtonComponent-icon {
display: none;
}

.jp-FileActions .jp-ToolbarButtonComponent[data-command='filebrowser:delete'] {
background-color: var(--jp-error-color1);
}

.jp-FileBrowser-toolbar .jp-FileActions .jp-ToolbarButtonComponent {
border: solid 1px var(--jp-border-color2);
margin: 1px;
height: 100%;
}
5 changes: 0 additions & 5 deletionspackages/tree/style/base.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,8 +49,3 @@ button[data-command='filebrowser:refresh'] .jp-ToolbarButtonComponent-label {
.jp-TreePanel .lm-TabBar-tabIcon svg {
vertical-align: sub;
}

.jp-FileActions {
display: flex;
flex-direction: row;
}

[8]ページ先頭

©2009-2025 Movatter.jp