-
Notifications
You must be signed in to change notification settings - Fork 433
feat: statusBarService support extends addElement #4503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/next |
Walkthrough此次 PR 的修改集中在 Changes
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
yarn install v1.22.22 ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/status-bar/src/browser/status-bar.service.ts (4)
30-30
: 将 entriesObservable 更改为公共属性是支持扩展的好方法将 entriesObservable 的可见性从私有改为公共可以让外部组件直接访问和修改状态栏条目集合,这对于扩展 addElement 功能是必要的。不过,直接暴露这个内部状态可能会在未来的重构中导致兼容性问题。
建议添加适当的 JSDoc 文档注释,明确说明这个属性的用途和预期使用场景。
104-106
: 将 getEntriesById 改为公共方法有助于重写 addElement将这个方法的访问权限修改为公共是合理的,因为它在扩展 addElement 功能时可能需要被外部调用。这个方法用于根据 ID 查找状态栏条目,对于自定义实现非常有用。
建议添加更详细的文档注释,特别是说明返回值的类型和用途。
111-113
: 将 getStorageState 改为公共方法支持状态持久化扩展这个更改使外部实现可以访问状态栏条目的存储状态,对于扩展 addElement 功能时保持状态一致性非常重要。此方法从 storage 中读取状态栏元素的状态信息。
建议添加更完整的文档注释,包括返回值类型和可能的使用场景。
30-113
: 整体扩展性改进评估这些更改(将 entriesObservable、getEntriesById 和 getStorageState 改为公共)共同为 StatusBarService 类提供了很好的扩展性,特别是对 addElement 方法的重写支持。这种方法允许外部组件访问必要的内部状态和功能,而不必完全重新实现 addElement 的逻辑。
不过,需要注意的是,暴露这些内部实现细节会降低封装性,可能会在未来的重构中引入兼容性问题。建议考虑以下改进:
- 为新公开的成员添加全面的文档注释
- 考虑添加一个简单的示例,说明如何利用这些变更来扩展 addElement 功能
- 在 README 或相关文档中说明这些 API 的预期使用方式
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/status-bar/src/browser/status-bar.service.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: 🚀🚀🚀 Next Version for pull request
- GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
- GitHub Check: ubuntu-latest, Node.js 20.x
- GitHub Check: unittest (ubuntu-latest, 18.x, node)
- GitHub Check: unittest (macos-latest, 18.x, node)
- GitHub Check: build-windows
- GitHub Check: build (ubuntu-latest, 20.x)
- GitHub Check: unittest (macos-latest, 18.x, jsdom)
- GitHub Check: build (macos-latest, 20.x)
🎉 PR Next publish successful! 3.8.3-next-1743422663.0 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4503 +/- ##
=======================================
Coverage 53.12% 53.13%
=======================================
Files 1665 1665
Lines 102648 102648
Branches 22216 22224 +8
=======================================
+ Hits 54535 54542 +7
+ Misses 40026 40020 -6
+ Partials 8087 8086 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
/next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/core-browser/src/services/status-bar-service.ts (1)
50-54
: 建议更新文档注释以反映新的类型当前的注释只描述了如何通过特定语法
$(iconClassName) :text
在字符串中设置图标,但没有提及当text
是 React 组件时应如何处理图标。建议更新注释以反映新的类型:
/** * 状态栏显示文案 * 可以通过 text 设置图标 * $(iconClassName) :text + * 也可以直接使用 React 组件 */ text?: string | React.ReactNode;
packages/status-bar/src/browser/status-bar-item.view.tsx (1)
140-156
: 建议保持样式和可访问性属性的一致性当
text
是字符串时,它被包装在一个设置了特定样式、aria-label 和 role 属性的 span 中。但当text
是 React 组件时,这些样式和属性没有被应用,可能导致展示和可访问性的不一致。建议将 React 组件也包装在具有相同样式和属性的 span 中:
{typeof text === 'string' ? transformLabelWithCodicon( text, {}, iconService.fromString.bind(iconService), (text: string, index: number) => ( <span key={`${text}-${index}`} style={{ height: '22px', lineHeight: '22px' }} aria-label={ariaLabel} role={role} > {replaceLocalizePlaceholder(text)} </span> ), ) - : text} + : <span + style={{ height: '22px', lineHeight: '22px' }} + aria-label={ariaLabel} + role={role} + > + {text} + </span>}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/core-browser/src/services/status-bar-service.ts
(1 hunks)packages/status-bar/src/browser/status-bar-item.view.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: 🚀🚀🚀 Next Version for pull request
- GitHub Check: build (macos-latest, 20.x)
- GitHub Check: build (ubuntu-latest, 20.x)
- GitHub Check: build-windows
- GitHub Check: ubuntu-latest, Node.js 20.x
- GitHub Check: unittest (macos-latest, 18.x, node)
- GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
- GitHub Check: unittest (ubuntu-latest, 18.x, node)
- GitHub Check: unittest (macos-latest, 18.x, jsdom)
🔇 Additional comments (3)
packages/core-browser/src/services/status-bar-service.ts (1)
54-54
: 更新了 text 类型以支持 React 组件将
text
类型从string
扩展为string | React.ReactNode
提高了状态栏内容的灵活性,允许直接使用 React 组件而不仅限于字符串。这是一个良好的改进,可以支持更丰富的状态栏展示内容。packages/status-bar/src/browser/status-bar-item.view.tsx (2)
140-156
: 正确处理了 text 类型的变更代码对
text
进行了类型检查,针对不同类型采取了不同的处理方式:
- 当
text
是字符串时,使用transformLabelWithCodicon
进行处理- 当
text
是 React 组件时,直接渲染这个实现正确地适配了
StatusBarEntry
接口中text
类型的变更。
140-156
: 考虑 React 组件的国际化处理当
text
是字符串时,通过replaceLocalizePlaceholder
进行了国际化处理,但当text
是 React 组件时,没有进行此处理。如果 React 组件中也需要国际化,应确保在组件内部处理。请确认 React 组件的国际化是否已在组件内部处理,或是否需要额外的国际化支持。
🎉 PR Next publish successful! 3.8.3-next-1743485759.0 |
Types
Background or solution
Changelog
feat: statusBarService支持复写addElement
Summary by CodeRabbit
新特性
text
属性类型,允许其接受更灵活的内容类型(string | React.ReactNode
),增强了状态栏元素的视觉表现。StatusBarItem
组件中text
属性的处理逻辑,允许直接渲染非字符串值,提升了灵活性。重构