瀏覽代碼

functional

markellekelly 5 年之前
父節點
當前提交
697fc77d9f
共有 2 個文件被更改,包括 35 次插入1 次删除
  1. 31 1
      packages/filebrowser-extension/src/index.ts
  2. 4 0
      packages/filebrowser/style/base.css

+ 31 - 1
packages/filebrowser-extension/src/index.ts

@@ -16,7 +16,8 @@ import {
   WidgetTracker,
   ICommandPalette,
   InputDialog,
-  showErrorMessage
+  showErrorMessage,
+  DOMUtils
 } from '@jupyterlab/apputils';
 
 import { PageConfig, PathExt, URLExt } from '@jupyterlab/coreutils';
@@ -122,6 +123,8 @@ namespace CommandIDs {
 
   export const toggleNavigateToCurrentDirectory =
     'filebrowser:toggle-navigate-to-current-directory';
+
+  export const toggleShowLastModified = 'filebrowser:toggle-show-last-modified';
 }
 
 /**
@@ -817,6 +820,28 @@ function addCommands(
     }
   });
 
+  commands.addCommand(CommandIDs.toggleShowLastModified, {
+    label: 'Show Last Modified',
+    execute: () => {
+      const header = DOMUtils.findElement(document.body, 'jp-id-modified');
+      const column = DOMUtils.findElements(
+        document.body,
+        'jp-DirListing-itemModified'
+      );
+      if (header.classList.contains('jp-LastModified-hidden')) {
+        header.classList.remove('jp-LastModified-hidden');
+        for (let i = 0; i < column.length; i++) {
+          column[i].classList.remove('jp-LastModified-hidden');
+        }
+      } else {
+        header.classList.add('jp-LastModified-hidden');
+        for (let i = 0; i < column.length; i++) {
+          column[i].classList.add('jp-LastModified-hidden');
+        }
+      }
+    }
+  });
+
   if (mainMenu) {
     mainMenu.settingsMenu.addGroup(
       [{ command: CommandIDs.toggleNavigateToCurrentDirectory }],
@@ -1009,6 +1034,11 @@ function addCommands(
     selector: selectorNotDir,
     rank: 13
   });
+  app.contextMenu.addItem({
+    command: CommandIDs.toggleShowLastModified,
+    selector: '.jp-DirListing-header',
+    rank: 14
+  });
 }
 
 /**

+ 4 - 0
packages/filebrowser/style/base.css

@@ -236,3 +236,7 @@
 .jp-FileDialog .jp-new-name-title {
   margin-top: 12px;
 }
+
+.jp-LastModified-hidden {
+  display: none;
+}