Skip to content

Commit

Permalink
Fix alignment, code server icon, and conda-store logic
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed May 7, 2024
1 parent 72c2bd7 commit 5d591c4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jupyterlab-new-launcher",
"version": "0.2.1",
"version": "0.2.2",
"description": "A redesigned JupyterLab launcher",
"keywords": [
"jupyter",
Expand Down
6 changes: 6 additions & 0 deletions src/icons.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LabIcon } from '@jupyterlab/ui-components';
import starSvgstr from '../style/icons/md/star.svg';
import fileSvgstr from '../style/icons/md/file.svg';
import codeServerSvgstr from '../style/icons/code-server.svg';

export const starIcon = new LabIcon({
name: 'jupyterlab-new-launcher:star',
Expand All @@ -11,3 +12,8 @@ export const fileIcon = new LabIcon({
name: 'jupyterlab-new-launcher:file',
svgstr: fileSvgstr
});

export const codeServerIcon = new LabIcon({
name: 'jupyterlab-new-launcher:code-server',
svgstr: codeServerSvgstr
});
23 changes: 17 additions & 6 deletions src/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Distributed under the terms of the Modified BSD License.
import type { CommandRegistry } from '@lumino/commands';
import type { VirtualElement } from '@lumino/virtualdom';
import { ReadonlyJSONObject } from '@lumino/coreutils';
import { ReadonlyJSONObject, JSONObject } from '@lumino/coreutils';
import { ILauncher } from '@jupyterlab/launcher';
import { Signal, ISignal } from '@lumino/signaling';
import { IItem, IFavoritesDatabase, ILastUsedDatabase } from './types';
import { codeServerIcon } from './icons';

export class Item implements IItem {
// base ILauncher.IItemOptions
Expand Down Expand Up @@ -50,20 +51,30 @@ export class Item implements IItem {
this.starred = favoritesDatabase.get(item) ?? false;
// special handling for conda-store
// https://www.nebari.dev/docs/faq/#why-is-there-duplication-in-names-of-environments
const kernel = this.metadata['kernel'] as JSONObject;
const condaStoreMatch = (
(this.metadata['conda_env_name'] as string | undefined) ?? ''
(kernel['conda_env_name'] as string | undefined) ?? ''
).match(/(?<namespace>.+)-(?<duplicate>\1)-(?<environment>.+)/);
if (condaStoreMatch && this.metadata) {
const groups = condaStoreMatch.groups!;
this.label =
(this.metadata['conda_language'] as string | undefined) ??
groups.environment;
(kernel['conda_language'] as string | undefined) ?? groups.environment;
this.metadata = {
...this.metadata,
conda_env_name: groups.environment,
Namespace: groups.namespace
kernel: {
...kernel,
conda_env_name: groups.environment,
Namespace: groups.namespace
}
};
}
// set the code-server icon to support dark theme properly
if (
this.command === 'server-proxy:open' &&
this.kernelIconUrl?.endsWith('/vscode')
) {
this.icon = codeServerIcon;
}
}
get lastUsed(): Date | null {
return this._lastUsed;
Expand Down
5 changes: 5 additions & 0 deletions style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
margin: 0;
}

.jp-NewLauncher-OtherItems {
display: flex;
gap: 4px;
}

.jp-NewLauncher-OtherItems .jp-LauncherCard-label {
display: none;
}
Expand Down
9 changes: 9 additions & 0 deletions style/icons/code-server.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5d591c4

Please sign in to comment.