فهرست منبع

Use blocked/allowed extension naming in typescript

Eric Charles 4 سال پیش
والد
کامیت
1bd76d2dc5

+ 1 - 1
packages/apputils/test/sanitizer.spec.ts

@@ -74,7 +74,7 @@ describe('defaultSanitizer', () => {
       expect(defaultSanitizer.sanitize(link)).toBe('');
     });
 
-    it('should pass through simple well-formed whitelisted markup', () => {
+    it('should pass through simple well-formed allowedExtensionsed markup', () => {
       const div = '<div><p>Hello <b>there</b></p></div>';
       expect(defaultSanitizer.sanitize(div)).toBe(div);
     });

+ 8 - 8
packages/extensionmanager-extension/examples/listings/Makefile

@@ -1,13 +1,13 @@
-export BLACK_LIST_URIS="https://raw.githubusercontent.com/datalayer-jupyterlab/jupyterlab-listings-example/master/blacklist_simple.json"
+export BLACK_LIST_URIS="https://raw.githubusercontent.com/datalayer-jupyterlab/jupyterlab-listings-example/master/blockedExtensions_simple.json"
 # export BLACK_LIST_URIS=""
-# export WHITE_LIST_URIS="https://raw.githubusercontent.com/datalayer-jupyterlab/jupyterlab-listings-example/master/whitelist_only_jlab.json"
+# export WHITE_LIST_URIS="https://raw.githubusercontent.com/datalayer-jupyterlab/jupyterlab-listings-example/master/allowedExtensions_only_jlab.json"
 export WHITE_LIST_URIS=""
 export LISTINGS_REFRESH_SECONDS=120
 export LISTINGS_REQUEST_OPTS="{'timeout': 10}"
 
 listings-uris:
-	@exec echo Using blacklist URIs: ${BLACK_LIST_URIS}
-	@exec echo Using whitelist URIs: ${WHITE_LIST_URIS}
+	@exec echo Using blockedExtensions URIs: ${BLACK_LIST_URIS}
+	@exec echo Using allowedExtensions URIs: ${WHITE_LIST_URIS}
 	@exec echo Refreshing lists every ${LISTINGS_REFRESH_SECONDS} seconds
 	@exec echo Using ${LISTINGS_REQUEST_OPTS} for the HTTP requests
 
@@ -15,8 +15,8 @@ dev: listings-uris
 	@exec python main.py \
 	  --dev \
 	  --no-browser \
-	  --LabServerApp.blacklist_uris=${BLACK_LIST_URIS} \
-	  --LabServerApp.whitelist_uris=${WHITE_LIST_URIS} \
+	  --LabServerApp.black_extensions_uris=${BLACK_LIST_URIS} \
+	  --LabServerApp.white_extensions_uris=${WHITE_LIST_URIS} \
 	  --LabServerApp.listings_refresh_seconds=${LISTINGS_REFRESH_SECONDS} \
 	  --LabServerApp.listings_request_options=${LISTINGS_REQUEST_OPTS}
 
@@ -25,7 +25,7 @@ watch: listings-uris
 	  --dev \
 	  --no-browser \
 	  --watch \
-	  --LabServerApp.blacklist_uris=${BLACK_LIST_URIS} \
-	  --LabServerApp.whitelist_uris=${WHITE_LIST_URIS} \
+	  --LabServerApp.black_extensions_uris=${BLACK_LIST_URIS} \
+	  --LabServerApp.white_extensions_uris=${WHITE_LIST_URIS} \
 	  --LabServerApp.listings_refresh_seconds=${LISTINGS_REFRESH_SECONDS} \
 	  --LabServerApp.listings_request_options=${LISTINGS_REQUEST_OPTS}

+ 1 - 1
packages/extensionmanager-extension/examples/listings/list/whitelist.json → packages/extensionmanager-extension/examples/listings/list/allowed_extensions.json

@@ -1,5 +1,5 @@
 {
-  "whitelist": [
+  "allowed_extensions": [
     {
       "name": "@jupyterlab/*",
       "type": "jupyterlab",

+ 1 - 1
packages/extensionmanager-extension/examples/listings/list/blacklist.json → packages/extensionmanager-extension/examples/listings/list/blocked_extensions.json

@@ -1,5 +1,5 @@
 {
-  "blacklist": [
+  "blocked_extensions": [
     {
       "name": "@jupyterlab-examples/launcher",
       "type": "jupyterlab",

+ 18 - 13
packages/extensionmanager/src/listings.ts

@@ -33,16 +33,16 @@ export interface IListEntry {
  *
  */
 export type ListResult = null | {
-  mode: 'white' | 'black' | 'default' | 'invalid';
+  mode: 'block' | 'allow' | 'default' | 'invalid';
   uris: string[];
   entries: IListEntry[];
 };
 
 export interface IListingApi {
-  blacklist_uris: string[];
-  whitelist_uris: string[];
-  blacklist: IListEntry[];
-  whitelist: IListEntry[];
+  black_extensions_uris: string[];
+  white_extensions_uris: string[];
+  blocked_extensions: IListEntry[];
+  allowed_extensions: IListEntry[];
 }
 
 /**
@@ -62,7 +62,10 @@ export class Lister {
           uris: [],
           entries: []
         };
-        if (data.blacklist_uris.length > 0 && data.whitelist_uris.length > 0) {
+        if (
+          data.black_extensions_uris.length > 0 &&
+          data.white_extensions_uris.length > 0
+        ) {
           console.warn('Simultaneous black and white list are not allowed.');
           this._listings = {
             mode: 'invalid',
@@ -70,17 +73,19 @@ export class Lister {
             entries: []
           };
         } else if (
-          data.blacklist_uris.length > 0 ||
-          data.whitelist_uris.length > 0
+          data.black_extensions_uris.length > 0 ||
+          data.white_extensions_uris.length > 0
         ) {
           this._listings = {
-            mode: data.blacklist_uris.length > 0 ? 'black' : 'white',
+            mode: data.black_extensions_uris.length > 0 ? 'block' : 'allow',
             uris:
-              data.blacklist_uris.length > 0
-                ? data.blacklist_uris
-                : data.whitelist_uris,
+              data.black_extensions_uris.length > 0
+                ? data.black_extensions_uris
+                : data.white_extensions_uris,
             entries:
-              data.blacklist_uris.length > 0 ? data.blacklist : data.whitelist
+              data.black_extensions_uris.length > 0
+                ? data.blocked_extensions
+                : data.allowed_extensions
           };
         }
         this._listingsLoaded.emit(this._listings);

+ 48 - 34
packages/extensionmanager/src/model.ts

@@ -74,9 +74,9 @@ export interface IEntry {
    */
   installed_version: string;
 
-  blacklistEntry: IListEntry | undefined;
+  blockedExtensionsEntry: IListEntry | undefined;
 
-  whitelistEntry: IListEntry | undefined;
+  allowedExtensionsEntry: IListEntry | undefined;
 }
 
 /**
@@ -175,10 +175,10 @@ export class ListModel extends VDomModel {
 
   private _listingIsLoaded(_: Lister, listings: ListResult) {
     this._listMode = listings!.mode;
-    this._blacklistArray = new Array<IListEntry>();
-    if (this._listMode === 'black') {
+    this._blockedExtensionsArray = new Array<IListEntry>();
+    if (this._listMode === 'block') {
       listings!.entries.map(e => {
-        this._blacklistArray.push({
+        this._blockedExtensionsArray.push({
           name: e.name,
           regexp: new RegExp(e.name),
           type: e.type,
@@ -188,10 +188,10 @@ export class ListModel extends VDomModel {
         });
       });
     }
-    this._whitelistArray = new Array<IListEntry>();
-    if (this._listMode === 'white') {
+    this._allowedExtensionsArray = new Array<IListEntry>();
+    if (this._listMode === 'allow') {
       listings!.entries.map(e => {
-        this._whitelistArray.push({
+        this._allowedExtensionsArray.push({
           name: e.name,
           regexp: new RegExp(e.name),
           type: e.type,
@@ -273,22 +273,22 @@ export class ListModel extends VDomModel {
   /**
    * The list mode.
    */
-  get listMode(): 'black' | 'white' | 'default' | 'invalid' {
+  get listMode(): 'block' | 'allow' | 'default' | 'invalid' {
     return this._listMode;
   }
 
   /**
-   * The total number of blacklisted results in the current search.
+   * The total number of blockedExtensionsed results in the current search.
    */
-  get totalBlacklistedFound(): number {
-    return this._totalBlacklistedFound;
+  get totalblockedExtensionsFound(): number {
+    return this._totalblockedExtensionsFound;
   }
 
   /**
-   * The total number of whitelisted results in the current search.
+   * The total number of allowedExtensionsed results in the current search.
    */
-  get totalWhitelistedFound(): number {
-    return this._totalWhitelistedFound;
+  get totalallowedExtensionsFound(): number {
+    return this._totalallowedExtensionsFound;
   }
 
   /**
@@ -474,8 +474,8 @@ export class ListModel extends VDomModel {
     res: Promise<ISearchResult>
   ): Promise<{ [key: string]: IEntry }> {
     const entries: { [key: string]: IEntry } = {};
-    this._totalBlacklistedFound = 0;
-    this._totalWhitelistedFound = 0;
+    this._totalblockedExtensionsFound = 0;
+    this._totalallowedExtensionsFound = 0;
     this._totalEntries = 0;
     for (const obj of (await res).objects) {
       const pkg = obj.package;
@@ -483,13 +483,21 @@ export class ListModel extends VDomModel {
         continue;
       }
       this._totalEntries = this._totalEntries + 1;
-      const isBlacklisted = this.isListed(pkg.name, this._blacklistArray);
-      if (isBlacklisted) {
-        this._totalBlacklistedFound = this._totalBlacklistedFound + 1;
+      const isblockedExtensionsed = this.isListed(
+        pkg.name,
+        this._blockedExtensionsArray
+      );
+      if (isblockedExtensionsed) {
+        this._totalblockedExtensionsFound =
+          this._totalblockedExtensionsFound + 1;
       }
-      const isWhitelisted = this.isListed(pkg.name, this._whitelistArray);
-      if (isWhitelisted) {
-        this._totalWhitelistedFound = this._totalWhitelistedFound + 1;
+      const isallowedExtensionsed = this.isListed(
+        pkg.name,
+        this._allowedExtensionsArray
+      );
+      if (isallowedExtensionsed) {
+        this._totalallowedExtensionsFound =
+          this._totalallowedExtensionsFound + 1;
       }
       entries[pkg.name] = {
         name: pkg.name,
@@ -505,8 +513,8 @@ export class ListModel extends VDomModel {
         status: null,
         latest_version: pkg.version,
         installed_version: '',
-        blacklistEntry: isBlacklisted,
-        whitelistEntry: isWhitelisted
+        blockedExtensionsEntry: isblockedExtensionsed,
+        allowedExtensionsEntry: isallowedExtensionsed
       };
     }
     return entries;
@@ -534,8 +542,14 @@ export class ListModel extends VDomModel {
             status: pkg.status,
             latest_version: pkg.latest_version,
             installed_version: pkg.installed_version,
-            blacklistEntry: this.isListed(pkg.name, this._blacklistArray),
-            whitelistEntry: this.isListed(pkg.name, this._whitelistArray)
+            blockedExtensionsEntry: this.isListed(
+              pkg.name,
+              this._blockedExtensionsArray
+            ),
+            allowedExtensionsEntry: this.isListed(
+              pkg.name,
+              this._allowedExtensionsArray
+            )
           };
         })
       );
@@ -760,7 +774,7 @@ export class ListModel extends VDomModel {
   /**
    * Contains an error message if an error occurred when searching for lists.
    */
-  blacklistError: string | null = null;
+  blockedExtensionsError: string | null = null;
 
   /**
    * Contains an error message if an error occurred when querying the server extension.
@@ -810,11 +824,11 @@ export class ListModel extends VDomModel {
   private _pendingActions: Promise<any>[] = [];
   private _debouncedUpdate: Debouncer<void, void>;
 
-  private _listMode: 'black' | 'white' | 'default' | 'invalid';
-  private _blacklistArray: Array<IListEntry>;
-  private _whitelistArray: Array<IListEntry>;
-  private _totalBlacklistedFound: number = 0;
-  private _totalWhitelistedFound: number = 0;
+  private _listMode: 'block' | 'allow' | 'default' | 'invalid';
+  private _blockedExtensionsArray: Array<IListEntry>;
+  private _allowedExtensionsArray: Array<IListEntry>;
+  private _totalblockedExtensionsFound: number = 0;
+  private _totalallowedExtensionsFound: number = 0;
 }
 
 let _isDisclaimed = false;
@@ -849,7 +863,7 @@ export namespace ListModel {
  */
 namespace Private {
   /**
-   * A comparator function that sorts whitelisted orgs to the top.
+   * A comparator function that sorts allowedExtensionsed orgs to the top.
    */
   export function comparator(a: IEntry, b: IEntry): number {
     if (a.name === b.name) {

+ 1 - 1
packages/extensionmanager/src/npm.ts

@@ -297,6 +297,6 @@ export function isJupyterOrg(name: string): boolean {
     parts.length > 1 && // Has a first part
     !!first && // with a finite length
     first[0] === '@' && // corresponding to an org name
-    jupyterOrg.indexOf(first.slice(1)) !== -1 // in the org whitelist.
+    jupyterOrg.indexOf(first.slice(1)) !== -1 // in the org allowedExtensions.
   );
 }

+ 17 - 17
packages/extensionmanager/src/widget.tsx

@@ -177,23 +177,23 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> {
   }
   const githubUser = getExtensionGitHubUser(entry);
   if (
-    listMode === 'black' &&
-    entry.blacklistEntry &&
+    listMode === 'block' &&
+    entry.blockedExtensionsEntry &&
     viewType === 'searchResult'
   ) {
     return <li></li>;
   }
   if (
-    listMode === 'white' &&
-    !entry.whitelistEntry &&
+    listMode === 'allow' &&
+    !entry.allowedExtensionsEntry &&
     viewType === 'searchResult'
   ) {
     return <li></li>;
   }
-  if (listMode === 'black' && entry.blacklistEntry?.name) {
+  if (listMode === 'block' && entry.blockedExtensionsEntry?.name) {
     flagClasses.push(`jp-extensionmanager-entry-should-be-uninstalled`);
   }
-  if (listMode === 'white' && !entry.whitelistEntry) {
+  if (listMode === 'allow' && !entry.allowedExtensionsEntry) {
     flagClasses.push(`jp-extensionmanager-entry-should-be-uninstalled`);
   }
   return (
@@ -220,10 +220,10 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> {
               {entry.name}
             </a>
           </div>
-          {entry.blacklistEntry && (
+          {entry.blockedExtensionsEntry && (
             <ToolbarButtonComponent
               icon={listingsInfoIcon}
-              iconLabel={`${entry.name} extension has been blacklisted since install. Please uninstall immediately and contact your blacklist administrator.`}
+              iconLabel={`${entry.name} extension has been blockedExtensionsed since install. Please uninstall immediately and contact your blockedExtensions administrator.`}
               onClick={() =>
                 window.open(
                   'https://jupyterlab.readthedocs.io/en/stable/user/extensions.html'
@@ -231,12 +231,12 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> {
               }
             />
           )}
-          {!entry.whitelistEntry &&
+          {!entry.allowedExtensionsEntry &&
             viewType === 'installed' &&
-            listMode === 'white' && (
+            listMode === 'allow' && (
               <ToolbarButtonComponent
                 icon={listingsInfoIcon}
-                iconLabel={`${entry.name} extension has been removed from the whitelist since installation. Please uninstall immediately and contact your whitelist administrator.`}
+                iconLabel={`${entry.name} extension has been removed from the allowedExtensions since installation. Please uninstall immediately and contact your allowedExtensions administrator.`}
                 onClick={() =>
                   window.open(
                     'https://jupyterlab.readthedocs.io/en/stable/user/extensions.html'
@@ -259,8 +259,8 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> {
           </div>
           <div className="jp-extensionmanager-entry-buttons">
             {!entry.installed &&
-              !entry.blacklistEntry &&
-              !(!entry.whitelistEntry && listMode === 'white') &&
+              !entry.blockedExtensionsEntry &&
+              !(!entry.allowedExtensionsEntry && listMode === 'allow') &&
               ListModel.isDisclaimed() && (
                 <Button
                   onClick={() => props.performAction('install', entry)}
@@ -271,8 +271,8 @@ function ListEntry(props: ListEntry.IProperties): React.ReactElement<any> {
                 </Button>
               )}
             {ListModel.entryHasUpdate(entry) &&
-              !entry.blacklistEntry &&
-              !(!entry.whitelistEntry && listMode === 'white') &&
+              !entry.blockedExtensionsEntry &&
+              !(!entry.allowedExtensionsEntry && listMode === 'allow') &&
               ListModel.isDisclaimed() && (
                 <Button
                   onClick={() => props.performAction('install', entry)}
@@ -329,7 +329,7 @@ export namespace ListEntry {
     /**
      * The list mode to apply.
      */
-    listMode: 'black' | 'white' | 'default' | 'invalid';
+    listMode: 'block' | 'allow' | 'default' | 'invalid';
 
     /**
      * The requested view type.
@@ -415,7 +415,7 @@ export namespace ListView {
     /**
      * The list mode to apply.
      */
-    listMode: 'black' | 'white' | 'default' | 'invalid';
+    listMode: 'block' | 'allow' | 'default' | 'invalid';
 
     /**
      * The requested view type.