@weavix/tracker-components 0.1.0 → 0.1.1
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 +191 -19
- package/build/cjs/components/Icon/GoalIcon/README.md +123 -0
- package/build/cjs/components/Icon/IssueTypeIcon/README.md +105 -23
- package/build/cjs/components/Icon/KeyResultIcon/README.md +73 -0
- package/build/cjs/components/Icon/MetaEntityIcon/README.md +126 -0
- package/build/cjs/components/Icon/PortfolioIcon/README.md +87 -9
- package/build/cjs/components/Icon/ProjectIcon/README.md +133 -9
- package/build/cjs/components/TrackerDisclosure/README.md +205 -0
- package/build/esm/components/Icon/GoalIcon/README.md +123 -0
- package/build/esm/components/Icon/IssueTypeIcon/README.md +105 -23
- package/build/esm/components/Icon/KeyResultIcon/README.md +73 -0
- package/build/esm/components/Icon/MetaEntityIcon/README.md +126 -0
- package/build/esm/components/Icon/PortfolioIcon/README.md +87 -9
- package/build/esm/components/Icon/ProjectIcon/README.md +133 -9
- package/build/esm/components/TrackerDisclosure/README.md +205 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,45 +1,217 @@
|
|
|
1
1
|
# @weavix/tracker-components
|
|
2
2
|
|
|
3
|
+
Shared UI component library for **Yandex Tracker plugins**. Provides ready-made React components for selecting queues, fields, and meta entities (projects, portfolios, goals), displaying issue-type and entity icons, and building collapsible sections — all styled to match the Tracker design system.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
3
7
|
## Installation
|
|
4
8
|
|
|
5
9
|
```bash
|
|
6
10
|
pnpm add @weavix/tracker-components
|
|
7
11
|
```
|
|
8
12
|
|
|
9
|
-
Peer
|
|
13
|
+
### Peer dependencies
|
|
14
|
+
|
|
15
|
+
| Package | Version |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `react`, `react-dom` | `^18` |
|
|
18
|
+
| `@gravity-ui/uikit` | `^7` |
|
|
19
|
+
| `@gravity-ui/icons` | `^2` |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Component catalogue
|
|
24
|
+
|
|
25
|
+
### Select components
|
|
26
|
+
|
|
27
|
+
| Component | Description | README |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| [`QueueSelect`](#queueselect) | Dropdown for choosing a Tracker queue. Supports static lists, async suggest, icons, loading states, and confirmation dialogs. | [→ README](src/components/QueueSelect/README.md) |
|
|
30
|
+
| [`MetaEntitiesSelect`](#metaentitiesselect) | Suggest-based select for projects, portfolios, goals, or reports. Async item fetching, loading states, error display, clear button. | [→ README](src/components/MetaEntitiesSelect/README.md) |
|
|
31
|
+
| [`PluginFieldsSelect`](#pluginfieldsselect) | Dropdown for choosing Tracker fields inside a plugin. Auto-groups fields by category, supports search, multi-select, submit/reset, loading states. | [→ README](src/components/PluginFieldsSelect/README.md) |
|
|
32
|
+
|
|
33
|
+
### Icon components
|
|
34
|
+
|
|
35
|
+
| Component | Description | README |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| [`IssueTypeIcon`](#issuetypeicon) | Icon for a Tracker issue type (task, bug, epic, …). | [→ README](src/components/Icon/IssueTypeIcon/README.md) |
|
|
38
|
+
| [`MetaEntityIcon`](#metaentityicon) | Dispatcher icon that renders the correct icon for any meta entity type (project, portfolio, goal, key result). | [→ README](src/components/Icon/MetaEntityIcon/README.md) |
|
|
39
|
+
| [`ProjectIcon`](#projecticon) | Colored icon for a project entity. Color is deterministically derived from the project ID. | [→ README](src/components/Icon/ProjectIcon/README.md) |
|
|
40
|
+
| [`PortfolioIcon`](#portfolioicon) | Colored icon for a portfolio entity. Color is deterministically derived from the portfolio ID. | [→ README](src/components/Icon/PortfolioIcon/README.md) |
|
|
41
|
+
| [`GoalIcon`](#goalicon) | Colored icon for a goal entity. Color is deterministically derived from the goal ID. | [→ README](src/components/Icon/GoalIcon/README.md) |
|
|
42
|
+
| [`KeyResultIcon`](#keyresulticon) | Icon for a key result entity, with a built-in tooltip. | [→ README](src/components/Icon/KeyResultIcon/README.md) |
|
|
43
|
+
|
|
44
|
+
### Layout components
|
|
45
|
+
|
|
46
|
+
| Component | Description | README |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| [`TrackerDisclosure`](#trackerdisclosure) | Collapsible section with Tracker-specific styling. Extends Gravity UI `Disclosure` with configurable arrow position, size, and an optional toolbar slot. | [→ README](src/components/TrackerDisclosure/README.md) |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Quick start
|
|
53
|
+
|
|
54
|
+
### QueueSelect
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import {QueueSelect} from '@weavix/tracker-components';
|
|
58
|
+
import type {QueueInfo} from '@weavix/tracker-components';
|
|
59
|
+
|
|
60
|
+
const queues: QueueInfo[] = [
|
|
61
|
+
{key: 'DEV', display: 'Development'},
|
|
62
|
+
{key: 'DESIGN', display: 'Design'},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
<QueueSelect
|
|
66
|
+
queues={queues}
|
|
67
|
+
defaultQueue={queues[0]}
|
|
68
|
+
onChange={(queue) => console.log(queue)}
|
|
69
|
+
/>;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
→ Full documentation including async suggest and Tracker API integration: [src/components/QueueSelect/README.md](src/components/QueueSelect/README.md)
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### MetaEntitiesSelect
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import {MetaEntitiesSelect} from '@weavix/tracker-components';
|
|
80
|
+
|
|
81
|
+
<MetaEntitiesSelect
|
|
82
|
+
getItems={(text) => fetchProjects(text)}
|
|
83
|
+
onChange={(entity) => console.log('selected', entity)}
|
|
84
|
+
/>;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
→ Full documentation including Tracker API integration: [src/components/MetaEntitiesSelect/README.md](src/components/MetaEntitiesSelect/README.md)
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### PluginFieldsSelect
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import {PluginFieldsSelect} from '@weavix/tracker-components';
|
|
95
|
+
import type {PluginFieldsSelectField} from '@weavix/tracker-components';
|
|
96
|
+
|
|
97
|
+
const fields: PluginFieldsSelectField[] = [
|
|
98
|
+
{id: 'summary', name: 'Summary', category: {id: '1', display: 'System Fields'}},
|
|
99
|
+
{id: 'sprint', name: 'Sprint', category: {id: '2', display: 'Custom Fields'}},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
<PluginFieldsSelect
|
|
103
|
+
open={true}
|
|
104
|
+
fields={fields}
|
|
105
|
+
onOpenChange={setOpen}
|
|
106
|
+
onItemSelect={(item) => console.log('selected', item)}
|
|
107
|
+
onItemDeselect={(item) => console.log('deselected', item)}
|
|
108
|
+
/>;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
→ Full documentation including 3 Tracker API fetch flows: [src/components/PluginFieldsSelect/README.md](src/components/PluginFieldsSelect/README.md)
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### IssueTypeIcon
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
119
|
+
|
|
120
|
+
<IssueTypeIcon issueType="bug" />
|
|
121
|
+
<IssueTypeIcon issueType="epic" size={24} />
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
→ Full documentation: [src/components/Icon/IssueTypeIcon/README.md](src/components/Icon/IssueTypeIcon/README.md)
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### MetaEntityIcon
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import {MetaEntityIcon} from '@weavix/tracker-components';
|
|
132
|
+
|
|
133
|
+
// Automatically renders the correct icon based on entityType
|
|
134
|
+
<MetaEntityIcon entity={{entityType: 'project', id: 'proj-1', shortId: 42}} />
|
|
135
|
+
<MetaEntityIcon entity={{entityType: 'portfolio', id: 'port-1', shortId: 7}} size={24} />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
→ Full documentation: [src/components/Icon/MetaEntityIcon/README.md](src/components/Icon/MetaEntityIcon/README.md)
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### ProjectIcon / PortfolioIcon / GoalIcon
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import {ProjectIcon, PortfolioIcon, GoalIcon} from '@weavix/tracker-components';
|
|
146
|
+
|
|
147
|
+
<ProjectIcon projectId={123} />
|
|
148
|
+
<PortfolioIcon portfolioId="portfolio-abc" />
|
|
149
|
+
<GoalIcon goalId={456} />
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
→ [ProjectIcon README](src/components/Icon/ProjectIcon/README.md) · [PortfolioIcon README](src/components/Icon/PortfolioIcon/README.md) · [GoalIcon README](src/components/Icon/GoalIcon/README.md)
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### KeyResultIcon
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import {KeyResultIcon} from '@weavix/tracker-components';
|
|
160
|
+
|
|
161
|
+
<KeyResultIcon size={16} />
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
→ Full documentation: [src/components/Icon/KeyResultIcon/README.md](src/components/Icon/KeyResultIcon/README.md)
|
|
10
165
|
|
|
11
|
-
|
|
12
|
-
- `@gravity-ui/uikit` ^7
|
|
13
|
-
- `@gravity-ui/icons` ^2
|
|
166
|
+
---
|
|
14
167
|
|
|
15
|
-
|
|
168
|
+
### TrackerDisclosure
|
|
16
169
|
|
|
17
170
|
```tsx
|
|
18
|
-
import {
|
|
171
|
+
import {TrackerDisclosure} from '@weavix/tracker-components';
|
|
19
172
|
|
|
20
|
-
<
|
|
173
|
+
<TrackerDisclosure summary="Section title" defaultExpanded>
|
|
174
|
+
Content goes here
|
|
175
|
+
</TrackerDisclosure>
|
|
21
176
|
```
|
|
22
177
|
|
|
178
|
+
→ Full documentation: [src/components/TrackerDisclosure/README.md](src/components/TrackerDisclosure/README.md)
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Architecture notes
|
|
183
|
+
|
|
184
|
+
### Data-agnostic pattern
|
|
185
|
+
|
|
186
|
+
All select components (`QueueSelect`, `MetaEntitiesSelect`, `PluginFieldsSelect`) are **data-agnostic**: they accept data via props and callbacks. You are responsible for fetching data from the Tracker API and passing it to the component. This keeps the components reusable and testable without a live API.
|
|
187
|
+
|
|
188
|
+
### Tracker API integration
|
|
189
|
+
|
|
190
|
+
Each select component's README contains a dedicated **Tracker API** section with:
|
|
191
|
+
- The exact API endpoints to call
|
|
192
|
+
- Ready-to-copy fetch functions
|
|
193
|
+
- Complete working examples
|
|
194
|
+
|
|
195
|
+
### Styling
|
|
196
|
+
|
|
197
|
+
Components use [Gravity UI](https://gravity-ui.com/) design tokens and BEM class names. Import the component CSS by ensuring your bundler processes `.scss` files from this package (the package declares `sideEffects: ["*.scss"]`).
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
23
201
|
## Development
|
|
24
202
|
|
|
25
203
|
```bash
|
|
26
204
|
pnpm install
|
|
27
|
-
pnpm run build
|
|
28
|
-
pnpm run typecheck
|
|
29
|
-
pnpm run lint
|
|
30
|
-
pnpm run test
|
|
205
|
+
pnpm run build # compile to build/
|
|
206
|
+
pnpm run typecheck # TypeScript type check
|
|
207
|
+
pnpm run lint # ESLint + Stylelint + Prettier
|
|
208
|
+
pnpm run test # Jest unit tests
|
|
31
209
|
```
|
|
32
210
|
|
|
33
211
|
### Storybook
|
|
34
212
|
|
|
35
|
-
Для запуска Storybook-сервера:
|
|
36
|
-
|
|
37
213
|
```bash
|
|
38
|
-
pnpm run storybook
|
|
214
|
+
pnpm run storybook # starts at http://localhost:7008
|
|
39
215
|
```
|
|
40
216
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
To build a static version of Storybook:
|
|
44
|
-
|
|
45
|
-
Истории компонентов находятся в директориях `__stories__` в папках компонентов.
|
|
217
|
+
Component stories live in `__stories__/` directories inside each component folder.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# GoalIcon
|
|
2
|
+
|
|
3
|
+
<!-- description:start -->
|
|
4
|
+
Displays a colored icon for a Tracker goal entity. The icon color is deterministically derived from the `goalId`, so the same goal always renders the same color across sessions and environments.
|
|
5
|
+
<!-- description:end -->
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {GoalIcon} from '@weavix/tracker-components';
|
|
11
|
+
|
|
12
|
+
<GoalIcon goalId={456} />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Component props
|
|
16
|
+
|
|
17
|
+
<!-- props:start -->
|
|
18
|
+
```ts
|
|
19
|
+
{
|
|
20
|
+
/**
|
|
21
|
+
* Goal ID used to generate a deterministic color.
|
|
22
|
+
* Accepts either a numeric shortId or a string entity ID.
|
|
23
|
+
*/
|
|
24
|
+
goalId: number | string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Additional CSS class applied to the root element.
|
|
28
|
+
*/
|
|
29
|
+
className?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Entity type label. Defaults to "goal".
|
|
33
|
+
*/
|
|
34
|
+
type?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Size of the SVG icon inside the container in pixels.
|
|
38
|
+
* @default 16
|
|
39
|
+
*/
|
|
40
|
+
size?: number;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Size of the icon container (the colored square) in pixels.
|
|
44
|
+
* @default 24
|
|
45
|
+
*/
|
|
46
|
+
refugeSize?: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether to render a colored background behind the icon.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
withBackground?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Border radius variant of the icon container.
|
|
56
|
+
* @default 'm'
|
|
57
|
+
*/
|
|
58
|
+
radius?: 'm' | 'l';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Alpha (opacity) of the icon foreground color.
|
|
62
|
+
* @default 1
|
|
63
|
+
*/
|
|
64
|
+
colorAlpha?: number;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
<!-- props:end -->
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Default
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import {GoalIcon} from '@weavix/tracker-components';
|
|
77
|
+
|
|
78
|
+
<GoalIcon goalId={456} />
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Custom size
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Larger icon container with a larger SVG inside
|
|
85
|
+
<GoalIcon goalId={456} size={20} refugeSize={32} />
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Without background
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// Renders only the colored SVG, no background square
|
|
92
|
+
<GoalIcon goalId={456} withBackground={false} />
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Alongside goal name
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import {GoalIcon} from '@weavix/tracker-components';
|
|
99
|
+
|
|
100
|
+
export const GoalLabel = ({goal}: {goal: {shortId: number; summary: string}}) => (
|
|
101
|
+
<div style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
102
|
+
<GoalIcon goalId={goal.shortId} />
|
|
103
|
+
<span>{goal.summary}</span>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Multiple goals (each gets a unique color)
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
const goals = [
|
|
112
|
+
{shortId: 1, summary: 'Increase retention'},
|
|
113
|
+
{shortId: 2, summary: 'Launch mobile app'},
|
|
114
|
+
{shortId: 3, summary: 'Reduce churn'},
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
goals.map((g) => (
|
|
118
|
+
<div key={g.shortId} style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
119
|
+
<GoalIcon goalId={g.shortId} />
|
|
120
|
+
<span>{g.summary}</span>
|
|
121
|
+
</div>
|
|
122
|
+
));
|
|
123
|
+
```
|
|
@@ -1,40 +1,122 @@
|
|
|
1
1
|
# IssueTypeIcon
|
|
2
2
|
|
|
3
3
|
<!-- description:start -->
|
|
4
|
-
|
|
4
|
+
Displays the icon for a Tracker issue type (task, bug, epic, improvement, etc.). Each issue type maps to a distinct SVG asset. Unknown type keys fall back to a generic icon.
|
|
5
5
|
<!-- description:end -->
|
|
6
6
|
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
11
|
+
|
|
12
|
+
<IssueTypeIcon issueType="bug" />
|
|
13
|
+
```
|
|
14
|
+
|
|
7
15
|
## Component props
|
|
8
16
|
|
|
9
17
|
<!-- props:start -->
|
|
10
18
|
```ts
|
|
11
19
|
{
|
|
12
20
|
/**
|
|
13
|
-
*
|
|
21
|
+
* Issue type key. Known values are listed below; any other string is
|
|
22
|
+
* accepted and falls back to a generic icon.
|
|
14
23
|
*/
|
|
15
|
-
|
|
24
|
+
issueType:
|
|
25
|
+
| 'task'
|
|
26
|
+
| 'bug'
|
|
27
|
+
| 'design'
|
|
28
|
+
| 'epic'
|
|
29
|
+
| 'improvement'
|
|
30
|
+
| 'incident'
|
|
31
|
+
| 'info'
|
|
32
|
+
| 'milestone'
|
|
33
|
+
| 'newFeature'
|
|
34
|
+
| 'query'
|
|
35
|
+
| 'refactoring'
|
|
36
|
+
| 'release'
|
|
37
|
+
| 'research'
|
|
38
|
+
| 'serviceRequest'
|
|
39
|
+
| 'story'
|
|
40
|
+
| 'subBug'
|
|
41
|
+
| 'subTask'
|
|
42
|
+
| 'technicalDebt'
|
|
43
|
+
| string;
|
|
44
|
+
|
|
16
45
|
/**
|
|
17
|
-
*
|
|
46
|
+
* Size of the icon in pixels.
|
|
47
|
+
* @default 16
|
|
18
48
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'incident' |
|
|
26
|
-
'info' |
|
|
27
|
-
'newFeature' |
|
|
28
|
-
'query' |
|
|
29
|
-
'refactoring' |
|
|
30
|
-
'release' |
|
|
31
|
-
'serviceRequest' |
|
|
32
|
-
'story' |
|
|
33
|
-
'subBug' |
|
|
34
|
-
'subTask' |
|
|
35
|
-
'technicalDebt' |
|
|
36
|
-
'milestone' |
|
|
37
|
-
string;
|
|
49
|
+
size?: number;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Additional CSS class applied to the root element.
|
|
53
|
+
*/
|
|
54
|
+
className?: string;
|
|
38
55
|
}
|
|
39
56
|
```
|
|
40
57
|
<!-- props:end -->
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
### Single icon
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
67
|
+
|
|
68
|
+
<IssueTypeIcon issueType="task" />
|
|
69
|
+
<IssueTypeIcon issueType="bug" />
|
|
70
|
+
<IssueTypeIcon issueType="epic" />
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Custom size
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<IssueTypeIcon issueType="story" size={24} />
|
|
77
|
+
<IssueTypeIcon issueType="story" size={32} />
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Alongside issue summary
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
84
|
+
|
|
85
|
+
export const IssueRow = ({issue}: {issue: {type: string; summary: string}}) => (
|
|
86
|
+
<div style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
87
|
+
<IssueTypeIcon issueType={issue.type} size={16} />
|
|
88
|
+
<span>{issue.summary}</span>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### All known issue types
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import {IssueTypeIcon} from '@weavix/tracker-components';
|
|
97
|
+
|
|
98
|
+
const ISSUE_TYPES = [
|
|
99
|
+
'task', 'bug', 'design', 'epic', 'improvement',
|
|
100
|
+
'incident', 'info', 'milestone', 'newFeature', 'query',
|
|
101
|
+
'refactoring', 'release', 'research', 'serviceRequest',
|
|
102
|
+
'story', 'subBug', 'subTask', 'technicalDebt',
|
|
103
|
+
] as const;
|
|
104
|
+
|
|
105
|
+
export const IssueTypeGallery = () => (
|
|
106
|
+
<div style={{display: 'flex', flexWrap: 'wrap', gap: 16}}>
|
|
107
|
+
{ISSUE_TYPES.map((type) => (
|
|
108
|
+
<div key={type} style={{display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4}}>
|
|
109
|
+
<IssueTypeIcon issueType={type} size={24} />
|
|
110
|
+
<span style={{fontSize: 11}}>{type}</span>
|
|
111
|
+
</div>
|
|
112
|
+
))}
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Notes
|
|
120
|
+
|
|
121
|
+
- The `issueType` value is matched case-sensitively against the known keys. Values returned by the Tracker API (e.g. `"newFeature"`, `"subTask"`) match directly without transformation.
|
|
122
|
+
- Passing an unknown string does not throw — the component renders a generic fallback icon.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# KeyResultIcon
|
|
2
|
+
|
|
3
|
+
<!-- description:start -->
|
|
4
|
+
Displays the icon for a Tracker key result entity. Renders a fixed SVG asset wrapped in a sized container, with a built-in tooltip that shows the localized "Key result" label on hover.
|
|
5
|
+
<!-- description:end -->
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {KeyResultIcon} from '@weavix/tracker-components';
|
|
11
|
+
|
|
12
|
+
<KeyResultIcon />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Component props
|
|
16
|
+
|
|
17
|
+
<!-- props:start -->
|
|
18
|
+
```ts
|
|
19
|
+
{
|
|
20
|
+
/**
|
|
21
|
+
* Size of the SVG icon inside the container in pixels.
|
|
22
|
+
* @default 16
|
|
23
|
+
*/
|
|
24
|
+
size?: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Size of the icon container in pixels.
|
|
28
|
+
* @default 24
|
|
29
|
+
*/
|
|
30
|
+
refugeSize?: number;
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
<!-- props:end -->
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Default
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import {KeyResultIcon} from '@weavix/tracker-components';
|
|
43
|
+
|
|
44
|
+
<KeyResultIcon />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Custom size
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
// Larger icon for a header row
|
|
51
|
+
<KeyResultIcon size={20} refugeSize={32} />
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Alongside key result name
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import {KeyResultIcon} from '@weavix/tracker-components';
|
|
58
|
+
|
|
59
|
+
export const KeyResultLabel = ({name}: {name: string}) => (
|
|
60
|
+
<div style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
61
|
+
<KeyResultIcon />
|
|
62
|
+
<span>{name}</span>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Notes
|
|
70
|
+
|
|
71
|
+
- The tooltip text is **automatically localized** using the Gravity UI `getConfig().lang` setting. No additional i18n setup is required.
|
|
72
|
+
- Unlike [`GoalIcon`](../GoalIcon/README.md), [`ProjectIcon`](../ProjectIcon/README.md), and [`PortfolioIcon`](../PortfolioIcon/README.md), `KeyResultIcon` does **not** accept an entity ID — it always renders the same fixed asset.
|
|
73
|
+
- To render the correct icon for an arbitrary meta entity type, use [`MetaEntityIcon`](../MetaEntityIcon/README.md) instead.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# MetaEntityIcon
|
|
2
|
+
|
|
3
|
+
<!-- description:start -->
|
|
4
|
+
A dispatcher component that renders the correct icon for any Tracker meta entity type — project, portfolio, goal, or key result. Pass the entity object and the component automatically selects and renders the appropriate icon with a deterministic color derived from the entity ID.
|
|
5
|
+
<!-- description:end -->
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {MetaEntityIcon} from '@weavix/tracker-components';
|
|
11
|
+
|
|
12
|
+
<MetaEntityIcon entity={{entityType: 'project', id: 'proj-1', shortId: 42}} />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Component props
|
|
16
|
+
|
|
17
|
+
<!-- props:start -->
|
|
18
|
+
```ts
|
|
19
|
+
{
|
|
20
|
+
/**
|
|
21
|
+
* The meta entity to display an icon for.
|
|
22
|
+
* Only `entityType`, `id`, and `shortId` are required.
|
|
23
|
+
*/
|
|
24
|
+
entity: {
|
|
25
|
+
entityType: 'project' | 'portfolio' | 'goal' | 'keyResult';
|
|
26
|
+
/** String entity ID (used for portfolio color generation). */
|
|
27
|
+
id: string;
|
|
28
|
+
/** Numeric short ID (used for project and goal color generation). */
|
|
29
|
+
shortId: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Size of the SVG icon inside the container in pixels.
|
|
34
|
+
* @default 20
|
|
35
|
+
*/
|
|
36
|
+
size?: number;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
<!-- props:end -->
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Supported entity types
|
|
44
|
+
|
|
45
|
+
| `entityType` | Rendered component | Color source |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `'project'` | [`ProjectIcon`](../ProjectIcon/README.md) | `shortId` |
|
|
48
|
+
| `'portfolio'` | [`PortfolioIcon`](../PortfolioIcon/README.md) | `id` |
|
|
49
|
+
| `'goal'` | [`GoalIcon`](../GoalIcon/README.md) | `shortId` |
|
|
50
|
+
| `'keyResult'` | [`KeyResultIcon`](../KeyResultIcon/README.md) | fixed asset, no color |
|
|
51
|
+
| anything else | `null` (renders nothing) | — |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
### All entity types
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import {MetaEntityIcon} from '@weavix/tracker-components';
|
|
61
|
+
|
|
62
|
+
<MetaEntityIcon entity={{entityType: 'project', id: 'proj-1', shortId: 42}} />
|
|
63
|
+
<MetaEntityIcon entity={{entityType: 'portfolio', id: 'port-1', shortId: 7}} />
|
|
64
|
+
<MetaEntityIcon entity={{entityType: 'goal', id: 'goal-1', shortId: 99}} />
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Custom size
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
// 32 px icon for a page header
|
|
71
|
+
<MetaEntityIcon
|
|
72
|
+
entity={{entityType: 'project', id: 'proj-1', shortId: 42}}
|
|
73
|
+
size={32}
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Rendering from a Tracker API response
|
|
78
|
+
|
|
79
|
+
`MetaEntityIcon` accepts the shape returned directly by the Tracker entities search endpoint, so you can pass `result.data[i]` without any mapping:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import React, {useEffect, useState} from 'react';
|
|
83
|
+
import {MetaEntityIcon} from '@weavix/tracker-components';
|
|
84
|
+
import type {MetaEntityV2} from '@weavix/tracker-api-types';
|
|
85
|
+
|
|
86
|
+
interface Props {
|
|
87
|
+
trackerApi: TrackerApi;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const EntityList: React.FC<Props> = ({trackerApi}) => {
|
|
91
|
+
const [entities, setEntities] = useState<MetaEntityV2[]>([]);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
trackerApi.v3
|
|
95
|
+
.post['/entities/{entityType}/_search']({
|
|
96
|
+
pathParams: {entityType: 'project'},
|
|
97
|
+
queryParams: {fields: ['summary'], page: 1, perPage: 20},
|
|
98
|
+
bodyParams: {filter: {}, filterTypes: ['ALL'], input: ''},
|
|
99
|
+
})
|
|
100
|
+
.then((result) => setEntities(result.data));
|
|
101
|
+
}, [trackerApi]);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<ul>
|
|
105
|
+
{entities.map((entity) => (
|
|
106
|
+
<li key={entity.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
107
|
+
<MetaEntityIcon entity={entity} size={20} />
|
|
108
|
+
<span>{entity.fields?.summary?.value ?? entity.id}</span>
|
|
109
|
+
</li>
|
|
110
|
+
))}
|
|
111
|
+
</ul>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Used inside MetaEntitiesSelect
|
|
117
|
+
|
|
118
|
+
`MetaEntityIcon` is used internally by [`MetaEntitiesSelect`](../../MetaEntitiesSelect/README.md) to render each item in the suggest list. You do not need to use it directly when using that component.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Notes
|
|
123
|
+
|
|
124
|
+
- The `entity` prop only requires `entityType`, `id`, and `shortId` — it is compatible with the full `MetaEntityV2` type from `@weavix/tracker-api-types`.
|
|
125
|
+
- For unknown `entityType` values the component renders `null` silently.
|
|
126
|
+
- To render individual entity icons directly, use [`ProjectIcon`](../ProjectIcon/README.md), [`PortfolioIcon`](../PortfolioIcon/README.md), [`GoalIcon`](../GoalIcon/README.md), or [`KeyResultIcon`](../KeyResultIcon/README.md).
|