@teambit/lanes.ui.lane-overview 0.0.209 → 0.0.211
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/dist/empty-lane-overview.d.ts +2 -2
- package/dist/lane-overview.d.ts +14 -3
- package/dist/lane-overview.js +70 -6
- package/dist/lane-overview.js.map +1 -1
- package/dist/lane-overview.module.scss +11 -0
- package/lane-overview.module.scss +11 -0
- package/lane-overview.tsx +102 -15
- package/package.json +17 -9
- /package/dist/{preview-1695807370382.js → preview-1704347596257.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { EmptyComponentGalleryProps } from '@teambit/ui-foundation.ui.empty-component-gallery';
|
|
3
3
|
export declare type EmptyLaneOverviewProps = {} & EmptyComponentGalleryProps;
|
|
4
4
|
/**
|
|
5
5
|
* A component to show when the scope is empty
|
|
6
6
|
*/
|
|
7
|
-
export declare function EmptyLaneOverview(props: EmptyLaneOverviewProps): JSX.Element;
|
|
7
|
+
export declare function EmptyLaneOverview(props: EmptyLaneOverviewProps): React.JSX.Element;
|
package/dist/lane-overview.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import { LanesModel, LanesHost } from '@teambit/lanes.ui.models.lanes-model';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
import { LaneModel, LanesModel, LanesHost } from '@teambit/lanes.ui.models.lanes-model';
|
|
3
3
|
import { RouteSlot } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
4
4
|
import { SlotRegistry } from '@teambit/harmony';
|
|
5
|
+
import { ComponentModel } from '@teambit/component';
|
|
6
|
+
import { ComponentCardPluginType, PluginProps } from '@teambit/explorer.ui.component-card';
|
|
5
7
|
export declare type LaneOverviewLine = ComponentType;
|
|
6
8
|
export declare type LaneOverviewLineSlot = SlotRegistry<LaneOverviewLine[]>;
|
|
7
9
|
export declare type LaneOverviewProps = {
|
|
@@ -13,4 +15,13 @@ export declare type LaneOverviewProps = {
|
|
|
13
15
|
loading?: boolean;
|
|
14
16
|
};
|
|
15
17
|
};
|
|
16
|
-
export declare
|
|
18
|
+
export declare class LinkPlugin {
|
|
19
|
+
private currentLane?;
|
|
20
|
+
constructor(currentLane?: LaneModel);
|
|
21
|
+
link: (id: any) => any;
|
|
22
|
+
}
|
|
23
|
+
export declare function LaneOverview({ routeSlot, overviewSlot, host, useLanes: useLanesFromProps, }: LaneOverviewProps): React.JSX.Element;
|
|
24
|
+
export declare function useCardPlugins({ compModelsById, currentLane, }: {
|
|
25
|
+
compModelsById: Map<string, ComponentModel>;
|
|
26
|
+
currentLane?: LaneModel;
|
|
27
|
+
}): ComponentCardPluginType<PluginProps>[];
|
package/dist/lane-overview.js
CHANGED
|
@@ -26,19 +26,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.LaneOverview = void 0;
|
|
29
|
+
exports.useCardPlugins = exports.LaneOverview = exports.LinkPlugin = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const lanes_ui_models_lanes_model_1 = require("@teambit/lanes.ui.models.lanes-model");
|
|
32
32
|
const explorer_ui_gallery_component_grid_1 = require("@teambit/explorer.ui.gallery.component-grid");
|
|
33
33
|
const ui_foundation_ui_react_router_slot_router_1 = require("@teambit/ui-foundation.ui.react-router.slot-router");
|
|
34
|
-
const workspace_ui_workspace_component_card_1 = require("@teambit/workspace.ui.workspace-component-card");
|
|
35
34
|
const lanes_hooks_use_lanes_1 = require("@teambit/lanes.hooks.use-lanes");
|
|
35
|
+
const cloud_hooks_use_cloud_scopes_1 = require("@teambit/cloud.hooks.use-cloud-scopes");
|
|
36
36
|
const lanes_hooks_use_lane_components_1 = require("@teambit/lanes.hooks.use-lane-components");
|
|
37
37
|
const lodash_flatten_1 = __importDefault(require("lodash.flatten"));
|
|
38
38
|
const scope_1 = require("@teambit/scope");
|
|
39
|
+
const preview_ui_preview_placeholder_1 = require("@teambit/preview.ui.preview-placeholder");
|
|
40
|
+
const design_ui_tooltip_1 = require("@teambit/design.ui.tooltip");
|
|
41
|
+
const component_id_1 = require("@teambit/component-id");
|
|
42
|
+
const scopes_scope_id_1 = require("@teambit/scopes.scope-id");
|
|
43
|
+
const workspace_ui_workspace_component_card_1 = require("@teambit/workspace.ui.workspace-component-card");
|
|
39
44
|
const lanes_ui_lane_details_1 = require("@teambit/lanes.ui.lane-details");
|
|
40
45
|
const empty_lane_overview_1 = require("./empty-lane-overview");
|
|
41
46
|
const lane_overview_module_scss_1 = __importDefault(require("./lane-overview.module.scss"));
|
|
47
|
+
class LinkPlugin {
|
|
48
|
+
constructor(currentLane) {
|
|
49
|
+
this.currentLane = currentLane;
|
|
50
|
+
this.link = (id) => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (!((_a = this.currentLane) === null || _a === void 0 ? void 0 : _a.id))
|
|
53
|
+
return id.fullName;
|
|
54
|
+
return lanes_ui_models_lanes_model_1.LanesModel.getLaneComponentUrl(id, (_b = this.currentLane) === null || _b === void 0 ? void 0 : _b.id);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.LinkPlugin = LinkPlugin;
|
|
42
59
|
function LaneOverview({ routeSlot, overviewSlot, host, useLanes: useLanesFromProps = lanes_hooks_use_lanes_1.useLanes, }) {
|
|
43
60
|
const { lanesModel } = useLanesFromProps();
|
|
44
61
|
const overviewItems = (0, react_1.useMemo)(() => (0, lodash_flatten_1.default)(overviewSlot === null || overviewSlot === void 0 ? void 0 : overviewSlot.values()), [overviewSlot]);
|
|
@@ -51,16 +68,63 @@ function LaneOverview({ routeSlot, overviewSlot, host, useLanes: useLanesFromPro
|
|
|
51
68
|
}
|
|
52
69
|
exports.LaneOverview = LaneOverview;
|
|
53
70
|
function LaneOverviewWithPreview({ currentLane, overviewItems, routeSlot, host }) {
|
|
54
|
-
const { loading, components } = (0, lanes_hooks_use_lane_components_1.useLaneComponents)(currentLane.id);
|
|
71
|
+
const { loading, components, componentDescriptors } = (0, lanes_hooks_use_lane_components_1.useLaneComponents)(currentLane.id);
|
|
72
|
+
const uniqueScopes = new Set(components === null || components === void 0 ? void 0 : components.map((c) => c.id.scope));
|
|
73
|
+
const uniqueScopesArr = Array.from(uniqueScopes);
|
|
74
|
+
const { cloudScopes = [] } = (0, cloud_hooks_use_cloud_scopes_1.useCloudScopes)(uniqueScopesArr);
|
|
75
|
+
const cloudScopesById = new Map(cloudScopes.map((scope) => [scope.id.toString(), scope]));
|
|
76
|
+
const compDescriptorById = new Map(componentDescriptors === null || componentDescriptors === void 0 ? void 0 : componentDescriptors.map((comp) => [comp.id.toString(), comp]));
|
|
77
|
+
const compModelsById = new Map(components === null || components === void 0 ? void 0 : components.map((comp) => [comp.id.toString(), comp]));
|
|
78
|
+
const plugins = useCardPlugins({ compModelsById, currentLane });
|
|
55
79
|
if (loading)
|
|
56
80
|
return null;
|
|
57
81
|
const ComponentCard = host === 'workspace'
|
|
58
|
-
? ({ component }) =>
|
|
59
|
-
|
|
82
|
+
? ({ component }) => {
|
|
83
|
+
var _a;
|
|
84
|
+
if ((_a = component.deprecation) === null || _a === void 0 ? void 0 : _a.isDeprecate)
|
|
85
|
+
return null;
|
|
86
|
+
const compDescriptor = compDescriptorById.get(component.id.toString());
|
|
87
|
+
if (!compDescriptor)
|
|
88
|
+
return null;
|
|
89
|
+
const cloudScope = cloudScopesById.get(component.id.scope);
|
|
90
|
+
const scope = cloudScope ||
|
|
91
|
+
(scopes_scope_id_1.ScopeID.isValid(component.id.scope) && { id: scopes_scope_id_1.ScopeID.fromString(component.id.scope) }) ||
|
|
92
|
+
undefined;
|
|
93
|
+
return (react_1.default.createElement(workspace_ui_workspace_component_card_1.WorkspaceComponentCard, { key: component.id.toString(), componentDescriptor: compDescriptor, component: component, plugins: plugins, scope: scope }));
|
|
94
|
+
}
|
|
95
|
+
: ({ component }) => {
|
|
96
|
+
const compDescriptor = compDescriptorById.get(component.id.toString());
|
|
97
|
+
return (react_1.default.createElement(scope_1.ScopeComponentCard, { key: component.id.toString(), component: component, plugins: plugins, componentDescriptor: compDescriptor }));
|
|
98
|
+
};
|
|
60
99
|
return (react_1.default.createElement("div", { className: lane_overview_module_scss_1.default.container },
|
|
61
100
|
react_1.default.createElement(lanes_ui_lane_details_1.LaneDetails, { className: lane_overview_module_scss_1.default.laneDetails, laneId: currentLane.id, description: '', componentCount: currentLane.components.length }),
|
|
62
|
-
react_1.default.createElement(explorer_ui_gallery_component_grid_1.ComponentGrid,
|
|
101
|
+
react_1.default.createElement(explorer_ui_gallery_component_grid_1.ComponentGrid, { className: lane_overview_module_scss_1.default.cardGrid }, components === null || components === void 0 ? void 0 : components.map((component, index) => (react_1.default.createElement(ComponentCard, { component: component, key: index })))),
|
|
63
102
|
routeSlot && react_1.default.createElement(ui_foundation_ui_react_router_slot_router_1.SlotRouter, { slot: routeSlot }),
|
|
64
103
|
overviewItems.length > 0 && overviewItems.map((Item, index) => react_1.default.createElement(Item, { key: index }))));
|
|
65
104
|
}
|
|
105
|
+
function useCardPlugins({ compModelsById, currentLane, }) {
|
|
106
|
+
const plugins = react_1.default.useMemo(() => [
|
|
107
|
+
{
|
|
108
|
+
preview: function Preview({ component, shouldShowPreview }) {
|
|
109
|
+
const compModel = compModelsById.get(component.id.toString());
|
|
110
|
+
if (!compModel)
|
|
111
|
+
return null;
|
|
112
|
+
return (react_1.default.createElement(preview_ui_preview_placeholder_1.PreviewPlaceholder, { componentDescriptor: component, component: compModel, shouldShowPreview: shouldShowPreview }));
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
previewBottomRight: function PreviewBottomRight({ component }) {
|
|
117
|
+
const env = component.get('teambit.envs/envs');
|
|
118
|
+
const envComponentId = (env === null || env === void 0 ? void 0 : env.id) ? component_id_1.ComponentID.fromString(env === null || env === void 0 ? void 0 : env.id) : undefined;
|
|
119
|
+
return (react_1.default.createElement("div", { className: lane_overview_module_scss_1.default.rightPreviewPlugins },
|
|
120
|
+
react_1.default.createElement("div", { className: lane_overview_module_scss_1.default.badge },
|
|
121
|
+
react_1.default.createElement(design_ui_tooltip_1.Tooltip, { delay: 300, content: envComponentId === null || envComponentId === void 0 ? void 0 : envComponentId.name },
|
|
122
|
+
react_1.default.createElement("img", { src: env === null || env === void 0 ? void 0 : env.icon, className: lane_overview_module_scss_1.default.envIcon })))));
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
new LinkPlugin(currentLane),
|
|
126
|
+
], [compModelsById.size, currentLane === null || currentLane === void 0 ? void 0 : currentLane.id.toString()]);
|
|
127
|
+
return plugins;
|
|
128
|
+
}
|
|
129
|
+
exports.useCardPlugins = useCardPlugins;
|
|
66
130
|
//# sourceMappingURL=lane-overview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lane-overview.js","sourceRoot":"","sources":["../lane-overview.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,sFAAwF;AACxF,oGAA4E;AAC5E,kHAA2F;AAC3F,
|
|
1
|
+
{"version":3,"file":"lane-overview.js","sourceRoot":"","sources":["../lane-overview.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,sFAAwF;AACxF,oGAA4E;AAC5E,kHAA2F;AAC3F,0EAA6E;AAC7E,wFAAuE;AACvE,8FAA6E;AAC7E,oEAAqC;AAErC,0CAAoD;AACpD,4FAA6E;AAC7E,kEAAqD;AACrD,wDAAoD;AAEpD,8DAAmD;AAEnD,0GAAwF;AACxF,0EAA6D;AAC7D,+DAA0D;AAE1D,4FAAiD;AAYjD,MAAa,UAAU;IACrB,YAAoB,WAAuB;QAAvB,g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cAAc,GAAG,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,EAAE,EAAC,CAAC,CAAC,0BAAW,CAAC,UAAU,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBAE7E,OAAO,CACL,uCAAK,SAAS,EAAE,mCAAM,CAAC,mBAAmB;oBACxC,uCAAK,SAAS,EAAE,mCAAM,CAAC,KAAK;wBAC1B,8BAAC,2BAAO,IAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI;4BAChD,uCAAK,GAAG,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,EAAE,SAAS,EAAE,mCAAM,CAAC,OAAO,GAAI,CAC1C,CACN,CACF,CACP,CAAC;YACJ,CAAC;SACF;QACD,IAAI,UAAU,CAAC,WAAW,CAAC;KAC5B,EACD,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAClD,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AA5CD,wCA4CC"}
|
|
@@ -8,3 +8,14 @@
|
|
|
8
8
|
.laneDetails {
|
|
9
9
|
padding-bottom: 32px;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
.cardGrid {
|
|
13
|
+
grid-column-gap: 10px;
|
|
14
|
+
grid-gap: 32px 24px;
|
|
15
|
+
-moz-column-gap: 10px;
|
|
16
|
+
column-gap: 10px;
|
|
17
|
+
display: grid;
|
|
18
|
+
gap: 32px 24px;
|
|
19
|
+
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
|
|
20
|
+
max-width: 1280px;
|
|
21
|
+
}
|
|
@@ -8,3 +8,14 @@
|
|
|
8
8
|
.laneDetails {
|
|
9
9
|
padding-bottom: 32px;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
.cardGrid {
|
|
13
|
+
grid-column-gap: 10px;
|
|
14
|
+
grid-gap: 32px 24px;
|
|
15
|
+
-moz-column-gap: 10px;
|
|
16
|
+
column-gap: 10px;
|
|
17
|
+
display: grid;
|
|
18
|
+
gap: 32px 24px;
|
|
19
|
+
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
|
|
20
|
+
max-width: 1280px;
|
|
21
|
+
}
|
package/lane-overview.tsx
CHANGED
|
@@ -2,12 +2,19 @@ import React, { useMemo, ComponentType } from 'react';
|
|
|
2
2
|
import { LaneModel, LanesModel, LanesHost } from '@teambit/lanes.ui.models.lanes-model';
|
|
3
3
|
import { ComponentGrid } from '@teambit/explorer.ui.gallery.component-grid';
|
|
4
4
|
import { RouteSlot, SlotRouter } from '@teambit/ui-foundation.ui.react-router.slot-router';
|
|
5
|
-
import { WorkspaceComponentCard } from '@teambit/workspace.ui.workspace-component-card';
|
|
6
5
|
import { useLanes as defaultUseLanes } from '@teambit/lanes.hooks.use-lanes';
|
|
6
|
+
import { useCloudScopes } from '@teambit/cloud.hooks.use-cloud-scopes';
|
|
7
7
|
import { useLaneComponents } from '@teambit/lanes.hooks.use-lane-components';
|
|
8
8
|
import flatten from 'lodash.flatten';
|
|
9
9
|
import { SlotRegistry } from '@teambit/harmony';
|
|
10
10
|
import { ScopeComponentCard } from '@teambit/scope';
|
|
11
|
+
import { PreviewPlaceholder } from '@teambit/preview.ui.preview-placeholder';
|
|
12
|
+
import { Tooltip } from '@teambit/design.ui.tooltip';
|
|
13
|
+
import { ComponentID } from '@teambit/component-id';
|
|
14
|
+
import { ComponentModel } from '@teambit/component';
|
|
15
|
+
import { ScopeID } from '@teambit/scopes.scope-id';
|
|
16
|
+
import { ComponentCardPluginType, PluginProps } from '@teambit/explorer.ui.component-card';
|
|
17
|
+
import { WorkspaceComponentCard } from '@teambit/workspace.ui.workspace-component-card';
|
|
11
18
|
import { LaneDetails } from '@teambit/lanes.ui.lane-details';
|
|
12
19
|
import { EmptyLaneOverview } from './empty-lane-overview';
|
|
13
20
|
|
|
@@ -23,6 +30,15 @@ export type LaneOverviewProps = {
|
|
|
23
30
|
useLanes?: () => { lanesModel?: LanesModel; loading?: boolean };
|
|
24
31
|
};
|
|
25
32
|
|
|
33
|
+
export class LinkPlugin {
|
|
34
|
+
constructor(private currentLane?: LaneModel) {}
|
|
35
|
+
|
|
36
|
+
link = (id) => {
|
|
37
|
+
if (!this.currentLane?.id) return id.fullName;
|
|
38
|
+
return LanesModel.getLaneComponentUrl(id, this.currentLane?.id);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
export function LaneOverview({
|
|
27
43
|
routeSlot,
|
|
28
44
|
overviewSlot,
|
|
@@ -55,24 +71,49 @@ type LaneOverviewWithPreviewProps = {
|
|
|
55
71
|
};
|
|
56
72
|
|
|
57
73
|
function LaneOverviewWithPreview({ currentLane, overviewItems, routeSlot, host }: LaneOverviewWithPreviewProps) {
|
|
58
|
-
const { loading, components } = useLaneComponents(currentLane.id);
|
|
74
|
+
const { loading, components, componentDescriptors } = useLaneComponents(currentLane.id);
|
|
75
|
+
const uniqueScopes = new Set(components?.map((c) => c.id.scope));
|
|
76
|
+
const uniqueScopesArr = Array.from(uniqueScopes);
|
|
77
|
+
const { cloudScopes = [] } = useCloudScopes(uniqueScopesArr);
|
|
78
|
+
const cloudScopesById = new Map(cloudScopes.map((scope) => [scope.id.toString(), scope]));
|
|
79
|
+
const compDescriptorById = new Map(componentDescriptors?.map((comp) => [comp.id.toString(), comp]));
|
|
80
|
+
const compModelsById = new Map(components?.map((comp) => [comp.id.toString(), comp]));
|
|
81
|
+
const plugins = useCardPlugins({ compModelsById, currentLane });
|
|
59
82
|
|
|
60
83
|
if (loading) return null;
|
|
61
84
|
|
|
62
85
|
const ComponentCard =
|
|
63
86
|
host === 'workspace'
|
|
64
|
-
? ({ component }) =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
? ({ component }) => {
|
|
88
|
+
if (component.deprecation?.isDeprecate) return null;
|
|
89
|
+
const compDescriptor = compDescriptorById.get(component.id.toString());
|
|
90
|
+
if (!compDescriptor) return null;
|
|
91
|
+
const cloudScope = cloudScopesById.get(component.id.scope);
|
|
92
|
+
const scope =
|
|
93
|
+
cloudScope ||
|
|
94
|
+
(ScopeID.isValid(component.id.scope) && { id: ScopeID.fromString(component.id.scope) }) ||
|
|
95
|
+
undefined;
|
|
96
|
+
return (
|
|
97
|
+
<WorkspaceComponentCard
|
|
98
|
+
key={component.id.toString()}
|
|
99
|
+
componentDescriptor={compDescriptor}
|
|
100
|
+
component={component}
|
|
101
|
+
plugins={plugins}
|
|
102
|
+
scope={scope}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
: ({ component }) => {
|
|
107
|
+
const compDescriptor = compDescriptorById.get(component.id.toString());
|
|
108
|
+
return (
|
|
109
|
+
<ScopeComponentCard
|
|
110
|
+
key={component.id.toString()}
|
|
111
|
+
component={component}
|
|
112
|
+
plugins={plugins}
|
|
113
|
+
componentDescriptor={compDescriptor}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
76
117
|
|
|
77
118
|
return (
|
|
78
119
|
<div className={styles.container}>
|
|
@@ -82,7 +123,7 @@ function LaneOverviewWithPreview({ currentLane, overviewItems, routeSlot, host }
|
|
|
82
123
|
description={''}
|
|
83
124
|
componentCount={currentLane.components.length}
|
|
84
125
|
></LaneDetails>
|
|
85
|
-
<ComponentGrid>
|
|
126
|
+
<ComponentGrid className={styles.cardGrid}>
|
|
86
127
|
{components?.map((component, index) => (
|
|
87
128
|
<ComponentCard component={component} key={index} />
|
|
88
129
|
))}
|
|
@@ -92,3 +133,49 @@ function LaneOverviewWithPreview({ currentLane, overviewItems, routeSlot, host }
|
|
|
92
133
|
</div>
|
|
93
134
|
);
|
|
94
135
|
}
|
|
136
|
+
|
|
137
|
+
export function useCardPlugins({
|
|
138
|
+
compModelsById,
|
|
139
|
+
currentLane,
|
|
140
|
+
}: {
|
|
141
|
+
compModelsById: Map<string, ComponentModel>;
|
|
142
|
+
currentLane?: LaneModel;
|
|
143
|
+
}): ComponentCardPluginType<PluginProps>[] {
|
|
144
|
+
const plugins = React.useMemo(
|
|
145
|
+
() => [
|
|
146
|
+
{
|
|
147
|
+
preview: function Preview({ component, shouldShowPreview }) {
|
|
148
|
+
const compModel = compModelsById.get(component.id.toString());
|
|
149
|
+
if (!compModel) return null;
|
|
150
|
+
return (
|
|
151
|
+
<PreviewPlaceholder
|
|
152
|
+
componentDescriptor={component}
|
|
153
|
+
component={compModel}
|
|
154
|
+
shouldShowPreview={shouldShowPreview}
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
previewBottomRight: function PreviewBottomRight({ component }) {
|
|
161
|
+
const env = component.get('teambit.envs/envs');
|
|
162
|
+
const envComponentId = env?.id ? ComponentID.fromString(env?.id) : undefined;
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<div className={styles.rightPreviewPlugins}>
|
|
166
|
+
<div className={styles.badge}>
|
|
167
|
+
<Tooltip delay={300} content={envComponentId?.name}>
|
|
168
|
+
<img src={env?.icon} className={styles.envIcon} />
|
|
169
|
+
</Tooltip>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
new LinkPlugin(currentLane),
|
|
176
|
+
],
|
|
177
|
+
[compModelsById.size, currentLane?.id.toString()]
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return plugins;
|
|
181
|
+
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/lanes.ui.lane-overview",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.211",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/lanes/ui/lane-overview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.lanes",
|
|
8
8
|
"name": "ui/lane-overview",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.211"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash.flatten": "4.4.0",
|
|
13
13
|
"core-js": "^3.0.0",
|
|
14
|
+
"@teambit/ui-foundation.ui.empty-component-gallery": "0.0.508",
|
|
15
|
+
"@teambit/component-id": "1.2.0",
|
|
16
|
+
"@teambit/design.ui.tooltip": "0.0.361",
|
|
17
|
+
"@teambit/explorer.ui.component-card": "0.0.30",
|
|
14
18
|
"@teambit/explorer.ui.gallery.component-grid": "0.0.496",
|
|
15
19
|
"@teambit/harmony": "0.4.6",
|
|
16
|
-
"@teambit/
|
|
17
|
-
"@teambit/lanes.
|
|
18
|
-
"@teambit/lanes.
|
|
19
|
-
"@teambit/
|
|
20
|
-
"@teambit/lanes.ui.models.lanes-model": "0.0.206",
|
|
20
|
+
"@teambit/lanes.hooks.use-lanes": "0.0.254",
|
|
21
|
+
"@teambit/lanes.ui.lane-details": "0.0.204",
|
|
22
|
+
"@teambit/lanes.ui.models.lanes-model": "0.0.207",
|
|
23
|
+
"@teambit/scopes.scope-id": "0.0.7",
|
|
21
24
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.506",
|
|
22
|
-
"@teambit/
|
|
25
|
+
"@teambit/cloud.hooks.use-cloud-scopes": "0.0.3",
|
|
26
|
+
"@teambit/lanes.hooks.use-lane-components": "0.0.255",
|
|
27
|
+
"@teambit/preview.ui.preview-placeholder": "0.0.508",
|
|
28
|
+
"@teambit/workspace.ui.workspace-component-card": "0.0.517"
|
|
23
29
|
},
|
|
24
30
|
"devDependencies": {
|
|
25
31
|
"@types/react": "^17.0.8",
|
|
@@ -36,6 +42,8 @@
|
|
|
36
42
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
37
43
|
},
|
|
38
44
|
"license": "Apache-2.0",
|
|
45
|
+
"optionalDependencies": {},
|
|
46
|
+
"peerDependenciesMeta": {},
|
|
39
47
|
"private": false,
|
|
40
48
|
"engines": {
|
|
41
49
|
"node": ">=12.22.0"
|
|
@@ -54,4 +62,4 @@
|
|
|
54
62
|
"angular",
|
|
55
63
|
"angular-components"
|
|
56
64
|
]
|
|
57
|
-
}
|
|
65
|
+
}
|
|
File without changes
|