Skip to content

Commit 9075f9f

Browse files
liujupingJackLian
authored andcommitted
feat(plugin-view-manager-pane): add disabled、tips configs
1 parent 50f3fe0 commit 9075f9f

2 files changed

Lines changed: 33 additions & 12 deletions

File tree

packages/plugin-view-manager-pane/src/components/resourceTree/index.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@
7272
font-size: 12px;
7373
color: var(--color-title, #5f697a);
7474

75-
76-
&.resource-tree-group-item-pro-code {
77-
color: var(--color-text-disabled, #bcc5d1);
78-
pointer-events: none;
79-
}
80-
8175
&.active .resource-tree-title {
8276
background-color: var(--color-block-background-light, #f7f8fa);
8377
}
@@ -144,6 +138,13 @@
144138
}
145139
}
146140

141+
&-group-disabled {
142+
.resource-tree-title {
143+
opacity: 0.4;
144+
cursor: not-allowed;
145+
}
146+
}
147+
147148
&-title {
148149
height: 24px;
149150
display: flex;

packages/plugin-view-manager-pane/src/components/resourceTree/index.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,17 @@ function ResourceItem(props: {
263263
}
264264

265265
const children = props.children?.filter(d => d.config?.display !== false);
266+
const {
267+
disabled,
268+
tips,
269+
} = props.resource?.config || {};
266270

267-
return (
271+
const context = (
268272
<div
269273
ref={ref}
270274
className={`resource-tree-group-node ${
271-
props.resource?.options.isProCodePage
272-
? 'resource-tree-group-item-pro-code'
275+
disabled
276+
? 'resource-tree-group-disabled'
273277
: ''
274278
} ${props.activeId === props.resource?.options.id || props.activeId === props.resource?.id ? 'active' : ''}`}
275279
onContextMenu={(e) => {
@@ -281,6 +285,9 @@ function ResourceItem(props: {
281285
>
282286
<div
283287
onClick={() => {
288+
if (disabled) {
289+
return;
290+
}
284291
props.resource && props.pluginContext?.workspace.openEditorWindow(props.resource);
285292
}}
286293
className="resource-tree-title"
@@ -316,9 +323,6 @@ function ResourceItem(props: {
316323
</div>
317324
<div className="resource-tree-group-title-label">
318325
{props.resource?.options?.label || props.resource?.title}
319-
{props.resource?.options.isProCodePage
320-
? intl('view_manager.components.resourceTree.SourceCode')
321-
: ''}
322326

323327
{
324328
props.resource?.options?.slug ||
@@ -369,6 +373,22 @@ function ResourceItem(props: {
369373
}
370374
</div>
371375
);
376+
377+
if (tips) {
378+
return (
379+
<Balloon
380+
v2
381+
trigger={context}
382+
triggerType="hover"
383+
align='r'
384+
title=""
385+
>
386+
{tips}
387+
</Balloon>
388+
);
389+
}
390+
391+
return context;
372392
}
373393

374394
interface IPluginOptions {

0 commit comments

Comments
 (0)