Skip to content

Commit 80e38a7

Browse files
committed
feat: implement the base launch UI
1 parent 9dda754 commit 80e38a7

13 files changed

Lines changed: 338 additions & 22 deletions

File tree

packages/components/src/button/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import classNames from 'classnames';
22
import React from 'react';
33

44
import { Dropdown } from '../dropdown';
5+
import { Placement } from '../dropdown/dropdown';
56
import { Icon, DefaultIconKeys, getIcon } from '../icon';
67
import './style.less';
78

@@ -27,6 +28,8 @@ interface MoreActionProps {
2728
more?: boolean;
2829
moreIconClass?: string;
2930
menu?: React.ReactNode;
31+
moreVisible?: boolean;
32+
placement?: Placement;
3033
onVisibleChange?: (visible: boolean) => void;
3134
}
3235

@@ -95,6 +98,8 @@ export const Button = React.memo(
9598
more,
9699
moreIconClass,
97100
menu,
101+
moreVisible,
102+
placement,
98103
title,
99104
onVisibleChange,
100105
...otherProps
@@ -127,9 +132,16 @@ export const Button = React.memo(
127132

128133
const iconNode = iconClass ? <Icon iconClass={iconClass} disabled={disabled} /> : null;
129134

130-
if (more) {
135+
if (menu) {
131136
return (
132-
<Dropdown className={'kt-menu'} overlay={menu} trigger={['click']} onVisibleChange={onVisibleChange}>
137+
<Dropdown
138+
visible={moreVisible}
139+
className={'kt-menu'}
140+
overlay={menu}
141+
trigger={['click']}
142+
onVisibleChange={onVisibleChange}
143+
placement={placement}
144+
>
133145
<button
134146
{...otherProps}
135147
disabled={disabled}

packages/components/src/dropdown/dropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { tuple } from '../utils/type';
77
import { warning } from '../utils/warning';
88

99
const Placements = tuple('topLeft', 'topCenter', 'topRight', 'bottomLeft', 'bottomCenter', 'bottomRight');
10-
type Placement = (typeof Placements)[number];
10+
export type Placement = (typeof Placements)[number];
1111

1212
type OverlayFunc = () => React.ReactNode;
1313

packages/core-browser/src/menu/next/menu.interface.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ export class SeparatorMenuItemNode extends MenuNode {
201201
}
202202
}
203203

204+
// 只展示 label 的 menu node
205+
export class LabelMenuItemNode extends MenuNode {
206+
static readonly ID = 'menu.item.node.label';
207+
208+
constructor(label: string) {
209+
super({
210+
id: LabelMenuItemNode.ID,
211+
label,
212+
});
213+
}
214+
}
215+
204216
export interface IMenu extends IDisposable {
205217
/**
206218
* menu-id

packages/debug/src/browser/debug-configuration-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export class DebugConfigurationManager {
361361
if (!uri) {
362362
uri = await this.doCreate(model);
363363
}
364-
return this.workbenchEditorService.open(uri, {
364+
return this.workbenchEditorService.open(uri.withScheme('launch_view_scheme'), {
365365
disableNavigate: true,
366366
});
367367
}

packages/debug/src/browser/debug-contribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
4040

4141
import {
4242
IDebugSessionManager,
43-
launchSchemaUri,
4443
DEBUG_CONTAINER_ID,
4544
DEBUG_WATCH_ID,
4645
DEBUG_VARIABLES_ID,
@@ -53,6 +52,7 @@ import {
5352
TSourceBrekpointProperties,
5453
DEBUG_COMMANDS,
5554
IDebugModelManager,
55+
launchDefaultSchemaUri,
5656
} from '../common';
5757

5858
import {
@@ -67,7 +67,7 @@ import { DebugContextKey } from './contextkeys/debug-contextkey.service';
6767
import { DebugConfigurationManager } from './debug-configuration-manager';
6868
import { DebugPreferences, debugPreferencesSchema } from './debug-preferences';
6969
import { DebugProgressService } from './debug-progress.service';
70-
import { launchSchema } from './debug-schema-updater';
70+
import { launchSchema } from './debug-schema-manager';
7171
import { DebugSession } from './debug-session';
7272
import { DebugSessionManager } from './debug-session-manager';
7373
import { DebugEditorContribution } from './editor/debug-editor-contribution';
@@ -610,7 +610,7 @@ export class DebugContribution
610610
}
611611

612612
registerSchema(registry: IJSONSchemaRegistry) {
613-
registry.registerSchema(`${launchSchemaUri}/default`, launchSchema, ['launch.json']);
613+
registry.registerSchema(launchDefaultSchemaUri, launchSchema, ['launch.json']);
614614
}
615615

616616
registerKeybindings(keybindings: KeybindingRegistry) {

packages/debug/src/browser/debug-schema-updater.ts renamed to packages/debug/src/browser/debug-schema-manager.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Injectable, Autowired } from '@opensumi/di';
22
import { objects, IJSONSchema, IJSONSchemaRegistry } from '@opensumi/ide-core-browser';
33

4-
import { launchSchemaUri } from '../common';
4+
import { launchExtensionSchemaUri, launchSchemaUri } from '../common';
55
import { DebugServer, IDebugServer } from '../common/debug-service';
66

77
import { DebugConfigurationManager } from './debug-configuration-manager';
88

99
const { deepClone } = objects;
1010

1111
@Injectable()
12-
export class DebugSchemaUpdater {
12+
export class DebugSchemaManager {
1313
@Autowired(IDebugServer)
1414
protected readonly debug: DebugServer;
1515

@@ -19,7 +19,7 @@ export class DebugSchemaUpdater {
1919
@Autowired(DebugConfigurationManager)
2020
private config: DebugConfigurationManager;
2121

22-
async update(): Promise<void> {
22+
public async update(): Promise<void> {
2323
const debuggers = this.config.getDebuggers();
2424
const schema = { ...deepClone(launchSchema) };
2525
const items = schema!.properties!.configurations.items as IJSONSchema;
@@ -38,7 +38,8 @@ export class DebugSchemaUpdater {
3838
items.defaultSnippets.push(...configurationSnippets);
3939
}
4040
}
41-
this.schemaRegistry.registerSchema(`${launchSchemaUri}/extension`, schema, ['launch.json']);
41+
42+
this.schemaRegistry.registerSchema(launchExtensionSchemaUri, schema, ['launch.json']);
4243
}
4344
}
4445

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,80 @@
1-
import { PreferenceContribution, PreferenceSchema, Domain, PreferenceConfiguration } from '@opensumi/ide-core-browser';
1+
import { Autowired, Injectable } from '@opensumi/di';
2+
import {
3+
PreferenceContribution,
4+
PreferenceSchema,
5+
Domain,
6+
PreferenceConfiguration,
7+
URI,
8+
MaybePromise,
9+
localize,
10+
getIcon,
11+
} from '@opensumi/ide-core-browser';
12+
import {
13+
BrowserEditorContribution,
14+
EditorComponentRegistry,
15+
EditorOpenType,
16+
IResource,
17+
IResourceProvider,
18+
ResourceService,
19+
} from '@opensumi/ide-editor/lib/browser';
220

321
import { launchPreferencesSchema } from './launch-preferences';
22+
import { LaunchViewContainer } from './launch.view';
23+
24+
const LAUNCH_VIEW_SCHEME = 'launch_view_scheme';
25+
const LAUNCH_VIEW_COMPONENT_ID = 'launch-view';
26+
27+
@Injectable()
28+
export class LaunchResourceProvider implements IResourceProvider {
29+
readonly scheme: string = LAUNCH_VIEW_SCHEME;
30+
31+
provideResource(uri: URI): MaybePromise<IResource<any>> {
32+
// 获取文件类型 getFileType: (path: string) => string
33+
return {
34+
supportsRevive: true,
35+
name: localize('menu-bar.title.debug'),
36+
icon: getIcon('debug'),
37+
uri,
38+
};
39+
}
40+
41+
provideResourceSubname(resource: IResource, groupResources: IResource[]): string | null {
42+
return null;
43+
}
44+
45+
async shouldCloseResource(resource: IResource, openedResources: IResource[][]): Promise<boolean> {
46+
return true;
47+
}
48+
}
49+
50+
@Domain(PreferenceContribution, PreferenceConfiguration, BrowserEditorContribution)
51+
export class LaunchPreferencesContribution
52+
implements PreferenceContribution, PreferenceConfiguration, BrowserEditorContribution
53+
{
54+
@Autowired(LaunchResourceProvider)
55+
private readonly prefResourceProvider: LaunchResourceProvider;
456

5-
@Domain(PreferenceContribution, PreferenceConfiguration)
6-
export class LaunchPreferencesContribution implements PreferenceContribution, PreferenceConfiguration {
757
schema: PreferenceSchema = launchPreferencesSchema;
858
name = 'launch';
59+
60+
registerResource(resourceService: ResourceService): void {
61+
resourceService.registerResourceProvider(this.prefResourceProvider);
62+
}
63+
64+
registerEditorComponent(editorComponentRegistry: EditorComponentRegistry): void {
65+
editorComponentRegistry.registerEditorComponent({
66+
component: LaunchViewContainer,
67+
uid: LAUNCH_VIEW_COMPONENT_ID,
68+
scheme: LAUNCH_VIEW_SCHEME,
69+
});
70+
71+
editorComponentRegistry.registerEditorComponentResolver(LAUNCH_VIEW_SCHEME, (_, __, resolve) => {
72+
resolve([
73+
{
74+
type: EditorOpenType.component,
75+
componentId: LAUNCH_VIEW_COMPONENT_ID,
76+
},
77+
]);
78+
});
79+
}
980
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
@base-font-size: 14px;
2+
@small-base-font-size: 12px;
3+
4+
.launch_container {
5+
height: 100%;
6+
font-size: @base-font-size;
7+
overflow: hidden;
8+
padding: 16px 16px 0 16px;
9+
box-sizing: border-box;
10+
min-width: 500px;
11+
12+
.launch_panel {
13+
height: 100%;
14+
margin-top: 8px;
15+
16+
.launch_indexes_container {
17+
height: 100%;
18+
margin-right: 16px;
19+
.not_configuration_content {
20+
text-align: center;
21+
font-size: @small-base-font-size;
22+
}
23+
.configuration_items_box {
24+
height: calc(100% - 40px) !important;
25+
.configuration_item {
26+
height: 22px;
27+
display: flex;
28+
align-items: center;
29+
cursor: pointer;
30+
flex-direction: row;
31+
padding: 4px;
32+
&:hover {
33+
background: var(--list-hoverBackground);
34+
color: var(--list-hoverForeground);
35+
}
36+
&.selected {
37+
background: var(--list-activeSelectionBackground);
38+
color: var(--list-activeSelectionForeground);
39+
}
40+
41+
.configuration_wrapper {
42+
overflow: hidden;
43+
text-overflow: ellipsis;
44+
white-space: nowrap;
45+
flex: 1;
46+
}
47+
48+
.configuration_description {
49+
display: inline;
50+
font-size: 12px;
51+
}
52+
}
53+
}
54+
.foot_box {
55+
position: relative;
56+
z-index: 1;
57+
.button {
58+
width: 100%;
59+
}
60+
}
61+
}
62+
}
63+
}
64+
65+
.devider {
66+
box-sizing: border-box;
67+
font-size: 14px;
68+
font-variant: tabular-nums;
69+
list-style: none;
70+
font-feature-settings: 'tnum';
71+
position: relative;
72+
margin: 0 3px;
73+
display: inline-block;
74+
vertical-align: middle;
75+
&:after {
76+
content: '';
77+
display: block;
78+
position: absolute;
79+
top: 0px;
80+
left: 0px;
81+
width: 100%;
82+
height: 100%;
83+
border-top: 0;
84+
border-left: 1px solid var(--editorGroup-border);
85+
pointer-events: none;
86+
transform: translateX(1.5px);
87+
}
88+
&:hover:after {
89+
border-color: transparent;
90+
}
91+
}

0 commit comments

Comments
 (0)