@principal-ade/code-quality-panels 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -27
- package/dist/panels.bundle.js +1661 -800
- package/dist/panels.bundle.js.map +1 -1
- package/dist/src/components/LensDataDebugPanel.d.ts +2 -2
- package/dist/src/components/LensDataDebugPanel.d.ts.map +1 -1
- package/dist/src/components/LensDataDebugPanel.stories.d.ts +2 -2
- package/dist/src/components/LensDataDebugPanel.stories.d.ts.map +1 -1
- package/dist/src/components/QualityEmptyState.d.ts +2 -2
- package/dist/src/components/QualityEmptyState.d.ts.map +1 -1
- package/dist/src/components/QualityHexagon.d.ts +16 -10
- package/dist/src/components/QualityHexagon.d.ts.map +1 -1
- package/dist/src/components/QualityHexagon.stories.d.ts +2 -2
- package/dist/src/components/QualityHexagon.stories.d.ts.map +1 -1
- package/dist/src/components/QualityMetricsList.d.ts +4 -4
- package/dist/src/components/QualityMetricsList.d.ts.map +1 -1
- package/dist/src/components/QualityMetricsList.stories.d.ts +2 -2
- package/dist/src/components/QualityMetricsList.stories.d.ts.map +1 -1
- package/dist/src/components/RepositoryQualityGrid.d.ts +3 -3
- package/dist/src/components/RepositoryQualityGrid.d.ts.map +1 -1
- package/dist/src/components/RepositoryQualityGrid.stories.d.ts +2 -2
- package/dist/src/components/RepositoryQualityGrid.stories.d.ts.map +1 -1
- package/dist/src/components/index.d.ts +5 -5
- package/dist/src/index.d.ts +7 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mocks/panelContext.d.ts +2 -2
- package/dist/src/mocks/panelContext.d.ts.map +1 -1
- package/dist/src/panels/LensDataDebugPanel.d.ts +2 -2
- package/dist/src/panels/LensDataDebugPanel.d.ts.map +1 -1
- package/dist/src/panels/LensDataDebugPanel.stories.d.ts +1 -1
- package/dist/src/panels/LensDataDebugPanel.stories.d.ts.map +1 -1
- package/dist/src/panels/QualityHexagonPanel.d.ts +2 -2
- package/dist/src/panels/QualityHexagonPanel.d.ts.map +1 -1
- package/dist/src/panels/QualityHexagonPanel.stories.d.ts +1 -1
- package/dist/src/panels/QualityHexagonPanel.stories.d.ts.map +1 -1
- package/dist/src/panels/RepositoryQualityGridPanel.d.ts +2 -2
- package/dist/src/panels/RepositoryQualityGridPanel.d.ts.map +1 -1
- package/dist/src/panels/RepositoryQualityGridPanel.stories.d.ts +1 -1
- package/dist/src/panels/RepositoryQualityGridPanel.stories.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,8 +50,8 @@ Update `package.json` with your information:
|
|
|
50
50
|
Edit `src/panels/ExamplePanel.tsx` or create new panel components:
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
|
-
import React from
|
|
54
|
-
import type { PanelComponentProps } from
|
|
53
|
+
import React from "react";
|
|
54
|
+
import type { PanelComponentProps } from "../types";
|
|
55
55
|
|
|
56
56
|
export const MyPanel: React.FC<PanelComponentProps> = ({
|
|
57
57
|
context,
|
|
@@ -72,14 +72,14 @@ export const MyPanel: React.FC<PanelComponentProps> = ({
|
|
|
72
72
|
Update `src/index.tsx` to export your panel definitions:
|
|
73
73
|
|
|
74
74
|
```tsx
|
|
75
|
-
import { MyPanel } from
|
|
75
|
+
import { MyPanel } from "./panels/MyPanel";
|
|
76
76
|
|
|
77
77
|
export const panels = [
|
|
78
78
|
{
|
|
79
|
-
id:
|
|
80
|
-
name:
|
|
81
|
-
icon:
|
|
82
|
-
description:
|
|
79
|
+
id: "your-org.my-panel",
|
|
80
|
+
name: "My Panel",
|
|
81
|
+
icon: "🚀",
|
|
82
|
+
description: "My custom panel",
|
|
83
83
|
component: MyPanel,
|
|
84
84
|
},
|
|
85
85
|
];
|
|
@@ -182,7 +182,7 @@ context.markdownFiles; // Markdown files list
|
|
|
182
182
|
// State management
|
|
183
183
|
context.loading; // Loading state
|
|
184
184
|
context.refresh(); // Refresh data
|
|
185
|
-
context.hasSlice(
|
|
185
|
+
context.hasSlice("git"); // Check slice availability
|
|
186
186
|
```
|
|
187
187
|
|
|
188
188
|
### Actions
|
|
@@ -193,11 +193,11 @@ Interact with the host application:
|
|
|
193
193
|
const { actions } = props;
|
|
194
194
|
|
|
195
195
|
// File operations
|
|
196
|
-
actions.openFile?.(
|
|
197
|
-
actions.openGitDiff?.(
|
|
196
|
+
actions.openFile?.("path/to/file.ts");
|
|
197
|
+
actions.openGitDiff?.("path/to/file.ts", "unstaged");
|
|
198
198
|
|
|
199
199
|
// Navigation
|
|
200
|
-
actions.navigateToPanel?.(
|
|
200
|
+
actions.navigateToPanel?.("panel-id");
|
|
201
201
|
|
|
202
202
|
// Notifications
|
|
203
203
|
actions.notifyPanels?.(event);
|
|
@@ -212,8 +212,8 @@ const { events } = props;
|
|
|
212
212
|
|
|
213
213
|
// Subscribe to events
|
|
214
214
|
useEffect(() => {
|
|
215
|
-
const unsubscribe = events.on(
|
|
216
|
-
console.log(
|
|
215
|
+
const unsubscribe = events.on("file:opened", (event) => {
|
|
216
|
+
console.log("File opened:", event.payload);
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
return unsubscribe; // Cleanup
|
|
@@ -221,10 +221,10 @@ useEffect(() => {
|
|
|
221
221
|
|
|
222
222
|
// Emit events
|
|
223
223
|
events.emit({
|
|
224
|
-
type:
|
|
225
|
-
source:
|
|
224
|
+
type: "custom:event",
|
|
225
|
+
source: "my-panel",
|
|
226
226
|
timestamp: Date.now(),
|
|
227
|
-
payload: { data:
|
|
227
|
+
payload: { data: "value" },
|
|
228
228
|
});
|
|
229
229
|
```
|
|
230
230
|
|
|
@@ -284,12 +284,12 @@ Called once for the entire package:
|
|
|
284
284
|
|
|
285
285
|
```typescript
|
|
286
286
|
export const onPackageLoad = async () => {
|
|
287
|
-
console.log(
|
|
287
|
+
console.log("Package loaded");
|
|
288
288
|
// Initialize shared resources
|
|
289
289
|
};
|
|
290
290
|
|
|
291
291
|
export const onPackageUnload = async () => {
|
|
292
|
-
console.log(
|
|
292
|
+
console.log("Package unloading");
|
|
293
293
|
// Cleanup shared resources
|
|
294
294
|
};
|
|
295
295
|
```
|
|
@@ -348,8 +348,8 @@ The host application will automatically discover your panel by the `panel-extens
|
|
|
348
348
|
Use reverse domain notation for panel IDs:
|
|
349
349
|
|
|
350
350
|
```typescript
|
|
351
|
-
id:
|
|
352
|
-
id:
|
|
351
|
+
id: "com.company.feature-panel"; // ✅ Good
|
|
352
|
+
id: "my-panel"; // ❌ Bad (collision risk)
|
|
353
353
|
```
|
|
354
354
|
|
|
355
355
|
### 2. Error Handling
|
|
@@ -362,8 +362,8 @@ const [error, setError] = useState(null);
|
|
|
362
362
|
useEffect(() => {
|
|
363
363
|
const loadData = async () => {
|
|
364
364
|
try {
|
|
365
|
-
if (!context.hasSlice(
|
|
366
|
-
throw new Error(
|
|
365
|
+
if (!context.hasSlice("git")) {
|
|
366
|
+
throw new Error("Git data not available");
|
|
367
367
|
}
|
|
368
368
|
// Use data...
|
|
369
369
|
} catch (err) {
|
|
@@ -383,7 +383,7 @@ if (error) {
|
|
|
383
383
|
Show loading indicators:
|
|
384
384
|
|
|
385
385
|
```tsx
|
|
386
|
-
if (context.loading || context.isSliceLoading(
|
|
386
|
+
if (context.loading || context.isSliceLoading("git")) {
|
|
387
387
|
return <div>Loading...</div>;
|
|
388
388
|
}
|
|
389
389
|
```
|
|
@@ -394,7 +394,7 @@ Always unsubscribe from events:
|
|
|
394
394
|
|
|
395
395
|
```tsx
|
|
396
396
|
useEffect(() => {
|
|
397
|
-
const unsubscribe = events.on(
|
|
397
|
+
const unsubscribe = events.on("event:type", handler);
|
|
398
398
|
return unsubscribe; // Cleanup on unmount
|
|
399
399
|
}, [events]);
|
|
400
400
|
```
|
|
@@ -404,7 +404,7 @@ useEffect(() => {
|
|
|
404
404
|
Use provided types for type safety:
|
|
405
405
|
|
|
406
406
|
```tsx
|
|
407
|
-
import type { PanelComponentProps, GitStatus } from
|
|
407
|
+
import type { PanelComponentProps, GitStatus } from "./types";
|
|
408
408
|
|
|
409
409
|
const MyPanel: React.FC<PanelComponentProps> = ({ context }) => {
|
|
410
410
|
const gitStatus: GitStatus = context.gitStatus;
|
|
@@ -427,7 +427,7 @@ Panels can access these data slices from the host:
|
|
|
427
427
|
Check availability before use:
|
|
428
428
|
|
|
429
429
|
```tsx
|
|
430
|
-
if (context.hasSlice(
|
|
430
|
+
if (context.hasSlice("git") && !context.isSliceLoading("git")) {
|
|
431
431
|
// Use git data
|
|
432
432
|
}
|
|
433
433
|
```
|
|
@@ -495,7 +495,7 @@ Ensure `package.json` has:
|
|
|
495
495
|
Check that peer dependencies are externalized in `vite.config.ts`:
|
|
496
496
|
|
|
497
497
|
```typescript
|
|
498
|
-
external: [
|
|
498
|
+
external: ["react", "react-dom"];
|
|
499
499
|
```
|
|
500
500
|
|
|
501
501
|
### Type Errors
|