@teambit/component.ui.component-filters.env-filter 0.0.0-0e0d9d06bb0bbc7c40e8a6b302956f30fe7cdc96
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/envs-filter.d.ts +17 -0
- package/dist/envs-filter.js +181 -0
- package/dist/envs-filter.js.map +1 -0
- package/dist/envs-filter.module.scss +94 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1753216294870.js +7 -0
- package/envs-filter.module.scss +94 -0
- package/envs-filter.tsx +238 -0
- package/index.ts +1 -0
- package/package.json +57 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentID } from '@teambit/component';
|
|
2
|
+
import { ComponentFilterCriteria } from '@teambit/component.ui.component-filters.component-filter-context';
|
|
3
|
+
type EnvFilterEnvState = {
|
|
4
|
+
active: boolean;
|
|
5
|
+
icon?: string;
|
|
6
|
+
displayName: string;
|
|
7
|
+
id: string;
|
|
8
|
+
description: string;
|
|
9
|
+
componentId: ComponentID;
|
|
10
|
+
};
|
|
11
|
+
export type EnvFilterState = {
|
|
12
|
+
envsState: Map<string, EnvFilterEnvState>;
|
|
13
|
+
dropdownState: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type EnvsFilterCriteria = ComponentFilterCriteria<EnvFilterState>;
|
|
16
|
+
export declare const EnvsFilter: EnvsFilterCriteria;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.EnvsFilter = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const design_inputs_selectors_multi_select_1 = require("@teambit/design.inputs.selectors.multi-select");
|
|
32
|
+
const component_1 = require("@teambit/component");
|
|
33
|
+
const component_modules_component_url_1 = require("@teambit/component.modules.component-url");
|
|
34
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
35
|
+
const design_ui_styles_ellipsis_1 = require("@teambit/design.ui.styles.ellipsis");
|
|
36
|
+
const design_ui_tooltip_1 = require("@teambit/design.ui.tooltip");
|
|
37
|
+
const base_react_navigation_link_1 = require("@teambit/base-react.navigation.link");
|
|
38
|
+
const component_ui_component_filters_component_filter_context_1 = require("@teambit/component.ui.component-filters.component-filter-context");
|
|
39
|
+
const envs_filter_module_scss_1 = __importDefault(require("./envs-filter.module.scss"));
|
|
40
|
+
// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest
|
|
41
|
+
const Link = base_react_navigation_link_1.Link;
|
|
42
|
+
exports.EnvsFilter = {
|
|
43
|
+
id: 'envs',
|
|
44
|
+
match: ({ component }, filter) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const { envsState } = filter;
|
|
47
|
+
const areAllEnvsActive = [...envsState.values()].every((envState) => envState.active);
|
|
48
|
+
const activeEnvs = [...envsState.values()].filter((envState) => envState.active).map((envState) => envState.id);
|
|
49
|
+
// match everything when no envs are set or all envs are set
|
|
50
|
+
if (activeEnvs.length === 0 || areAllEnvsActive)
|
|
51
|
+
return true;
|
|
52
|
+
const envId = component.environment && ((_a = component_1.ComponentID.tryFromString(component.environment.id)) === null || _a === void 0 ? void 0 : _a.toStringWithoutVersion());
|
|
53
|
+
const matches = !!envId && activeEnvs.indexOf(envId) >= 0;
|
|
54
|
+
return matches;
|
|
55
|
+
},
|
|
56
|
+
state: {
|
|
57
|
+
envsState: new Map(),
|
|
58
|
+
dropdownState: false,
|
|
59
|
+
},
|
|
60
|
+
order: 1,
|
|
61
|
+
render: envsFilter,
|
|
62
|
+
};
|
|
63
|
+
const deriveEnvsFilterState = (components) => {
|
|
64
|
+
return (0, react_1.useMemo)(() => {
|
|
65
|
+
const defaultState = {
|
|
66
|
+
dropdownState: false,
|
|
67
|
+
envsState: new Map(),
|
|
68
|
+
};
|
|
69
|
+
const componentEnvSet = new Set();
|
|
70
|
+
const componentsEnvsWithIcons = components
|
|
71
|
+
.filter((component) => {
|
|
72
|
+
const envId = component.environment && component_1.ComponentID.tryFromString(component.environment.id);
|
|
73
|
+
if (!envId)
|
|
74
|
+
return false;
|
|
75
|
+
const envKey = envId.toStringWithoutVersion();
|
|
76
|
+
if (componentEnvSet.has(envKey))
|
|
77
|
+
return false;
|
|
78
|
+
componentEnvSet.add(envKey);
|
|
79
|
+
return true;
|
|
80
|
+
})
|
|
81
|
+
.map((component) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const envId = component_1.ComponentID.fromString((_a = component.environment) === null || _a === void 0 ? void 0 : _a.id);
|
|
84
|
+
return {
|
|
85
|
+
displayName: envId.name,
|
|
86
|
+
id: envId.toStringWithoutVersion(),
|
|
87
|
+
description: `${envId.scope}${envId.namespace ? '/'.concat(envId.namespace) : ''}`,
|
|
88
|
+
icon: (_b = component.environment) === null || _b === void 0 ? void 0 : _b.icon,
|
|
89
|
+
componentId: envId,
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
componentsEnvsWithIcons.forEach((componentEnvWithIcon) => {
|
|
93
|
+
defaultState.envsState.set(componentEnvWithIcon.id, Object.assign(Object.assign({}, componentEnvWithIcon), { active: true }));
|
|
94
|
+
});
|
|
95
|
+
return defaultState;
|
|
96
|
+
}, [components]);
|
|
97
|
+
};
|
|
98
|
+
function envsFilter({ components, className, lanes }) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
const [filters = []] = (0, component_ui_component_filters_component_filter_context_1.useComponentFilters)() || [];
|
|
101
|
+
const filtersExceptEnv = filters.filter((filter) => filter.id !== exports.EnvsFilter.id);
|
|
102
|
+
const filteredComponents = (0, react_1.useMemo)(() => (0, component_ui_component_filters_component_filter_context_1.runAllFilters)(filtersExceptEnv, { components, lanes }), [JSON.stringify(filtersExceptEnv), (_a = lanes === null || lanes === void 0 ? void 0 : lanes.viewedLane) === null || _a === void 0 ? void 0 : _a.id.toString()]);
|
|
103
|
+
const envsFilterState = deriveEnvsFilterState(filteredComponents);
|
|
104
|
+
const filterContext = (0, component_ui_component_filters_component_filter_context_1.useComponentFilter)(exports.EnvsFilter.id, envsFilterState);
|
|
105
|
+
const envs = envsFilterState.envsState;
|
|
106
|
+
const [currentFilter, updateFilter] = filterContext || [];
|
|
107
|
+
/**
|
|
108
|
+
* this will not work if other filters in a single re-render
|
|
109
|
+
* result in the same number of components with different ids
|
|
110
|
+
*/
|
|
111
|
+
(0, react_1.useEffect)(() => {
|
|
112
|
+
updateFilter === null || updateFilter === void 0 ? void 0 : updateFilter((currentState) => {
|
|
113
|
+
currentState.state = envsFilterState;
|
|
114
|
+
return currentState;
|
|
115
|
+
});
|
|
116
|
+
}, [filteredComponents.length, (_b = lanes === null || lanes === void 0 ? void 0 : lanes.viewedLane) === null || _b === void 0 ? void 0 : _b.id.toString()]);
|
|
117
|
+
const selectList = [];
|
|
118
|
+
envs.forEach((state) => {
|
|
119
|
+
var _a;
|
|
120
|
+
selectList.push({
|
|
121
|
+
value: state.id,
|
|
122
|
+
icon: state.icon,
|
|
123
|
+
description: state.description,
|
|
124
|
+
checked: !!((_a = currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.state.envsState.get(state.id)) === null || _a === void 0 ? void 0 : _a.active),
|
|
125
|
+
element: react_1.default.createElement(EnvsDropdownItem, Object.assign({}, state)),
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
const onCheck = (value, e) => {
|
|
129
|
+
const checked = e.target.checked;
|
|
130
|
+
updateFilter === null || updateFilter === void 0 ? void 0 : updateFilter((currentState) => {
|
|
131
|
+
if (checked && !currentState.state.dropdownState) {
|
|
132
|
+
currentState.state.dropdownState = true;
|
|
133
|
+
}
|
|
134
|
+
const currentEnvState = currentState.state.envsState.get(value);
|
|
135
|
+
if (!currentEnvState)
|
|
136
|
+
return currentState;
|
|
137
|
+
currentState.state.envsState.set(value, Object.assign(Object.assign({}, currentEnvState), { active: checked }));
|
|
138
|
+
return currentState;
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
const onClear = () => {
|
|
142
|
+
updateFilter === null || updateFilter === void 0 ? void 0 : updateFilter((currentState) => {
|
|
143
|
+
currentState.state.envsState.forEach((value, key) => {
|
|
144
|
+
currentState.state.envsState.set(key, Object.assign(Object.assign({}, value), { active: false }));
|
|
145
|
+
});
|
|
146
|
+
return currentState;
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
const onSubmit = () => {
|
|
150
|
+
updateFilter === null || updateFilter === void 0 ? void 0 : updateFilter((currentState) => {
|
|
151
|
+
currentState.state.dropdownState = false;
|
|
152
|
+
return currentState;
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const onDropdownToggled = (event, open) => {
|
|
156
|
+
updateFilter === null || updateFilter === void 0 ? void 0 : updateFilter((currentState) => {
|
|
157
|
+
currentState.state.dropdownState = open;
|
|
158
|
+
return currentState;
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(envs_filter_module_scss_1.default.envsFilterContainer, className) },
|
|
162
|
+
react_1.default.createElement(design_inputs_selectors_multi_select_1.MultiSelect, { itemsList: selectList, placeholder: react_1.default.createElement(EnvsPlaceholder, null), onSubmit: onSubmit, onCheck: onCheck, onClear: onClear, onChange: onDropdownToggled, open: !!(currentFilter === null || currentFilter === void 0 ? void 0 : currentFilter.state.dropdownState), dropdownBorder: false, className: envs_filter_module_scss_1.default.envFilterDropdownContainer, dropClass: envs_filter_module_scss_1.default.envFilterDropdown })));
|
|
163
|
+
}
|
|
164
|
+
function EnvsPlaceholder() {
|
|
165
|
+
return (react_1.default.createElement("div", { className: envs_filter_module_scss_1.default.filterIcon },
|
|
166
|
+
react_1.default.createElement("img", { src: "https://static.bit.dev/bit-icons/env.svg" }),
|
|
167
|
+
react_1.default.createElement("span", { className: envs_filter_module_scss_1.default.filterIconLabel }, "Environments"),
|
|
168
|
+
react_1.default.createElement("div", { className: envs_filter_module_scss_1.default.dropdownArrow },
|
|
169
|
+
react_1.default.createElement("img", { src: "https://static.bit.dev/bit-icons/fat-arrow-down.svg" }))));
|
|
170
|
+
}
|
|
171
|
+
function EnvsDropdownItem({ displayName, icon, description, componentId, id }) {
|
|
172
|
+
return (react_1.default.createElement(design_ui_tooltip_1.Tooltip, { placement: "right", content: react_1.default.createElement(Link, { className: envs_filter_module_scss_1.default.envLink, href: component_modules_component_url_1.ComponentUrl.toUrl(componentId, { includeVersion: false }), external: true }, id) },
|
|
173
|
+
react_1.default.createElement("div", { className: envs_filter_module_scss_1.default.envDropdownItemContainer },
|
|
174
|
+
react_1.default.createElement("div", { className: envs_filter_module_scss_1.default.envDropdownItem },
|
|
175
|
+
react_1.default.createElement(design_ui_styles_ellipsis_1.Ellipsis, null, displayName),
|
|
176
|
+
react_1.default.createElement("div", { className: envs_filter_module_scss_1.default.envDropdownItemIconContainer },
|
|
177
|
+
react_1.default.createElement("img", { className: envs_filter_module_scss_1.default.envDropdownItemIcon, src: icon }))),
|
|
178
|
+
react_1.default.createElement("div", { className: envs_filter_module_scss_1.default.description },
|
|
179
|
+
react_1.default.createElement(design_ui_styles_ellipsis_1.Ellipsis, { className: envs_filter_module_scss_1.default.descriptionText }, description)))));
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=envs-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envs-filter.js","sourceRoot":"","sources":["../envs-filter.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,wGAAsF;AACtF,kDAAiE;AACjE,8FAAwE;AACxE,4DAAoC;AACpC,kFAA8D;AAC9D,kEAAqD;AACrD,oFAAuE;AACvE,8IAM0E;AAE1E,wFAA+C;AAE/C,kGAAkG;AAClG,MAAM,IAAI,GAAG,iCAAe,CAAC;AAgBhB,QAAA,UAAU,GAAuB;IAC5C,EAAE,EAAE,MAAM;IACV,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE;;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,MAAM,gBAAgB,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtF,MAAM,UAAU,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAA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,GAAG,EAAC,qDAAqD,GAAG,CAC7D,CACF,CACP,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,EAAqB;IAC9F,OAAO,CACL,8BAAC,2BAAO,IACN,SAAS,EAAC,OAAO,EACjB,OAAO,EACL,8BAAC,IAAI,IACH,SAAS,EAAE,iCAAM,CAAC,OAAO,EACzB,IAAI,EAAE,8CAAY,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAChE,QAAQ,EAAE,IAAI,IAEb,EAAE,CACE;QAGT,uCAAK,SAAS,EAAE,iCAAM,CAAC,wBAAwB;YAC7C,uCAAK,SAAS,EAAE,iCAAM,CAAC,eAAe;gBACpC,8BAAC,oCAAQ,QAAE,WAAW,CAAY;gBAClC,uCAAK,SAAS,EAAE,iCAAM,CAAC,4BAA4B;oBACjD,uCAAK,SAAS,EAAE,iCAAM,CAAC,mBAAmB,EAAE,GAAG,EAAE,IAAI,GAAQ,CACzD,CACF;YACN,uCAAK,SAAS,EAAE,iCAAM,CAAC,WAAW;gBAChC,8BAAC,oCAAQ,IAAC,SAAS,EAAE,iCAAM,CAAC,eAAe,IAAG,WAAW,CAAY,CACjE,CACF,CACE,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@import '@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
|
+
.envsFilterContainer {
|
|
3
|
+
> div {
|
|
4
|
+
line-height: 16px;
|
|
5
|
+
display: flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.filterIcon {
|
|
9
|
+
display: flex;
|
|
10
|
+
padding: 8px;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
background: var(--bit-bg-heavy, #f6f6f6);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
img {
|
|
19
|
+
width: 16px;
|
|
20
|
+
filter: invert(44%) sepia(7%) saturate(560%) hue-rotate(187deg) brightness(96%) contrast(91%);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.filterIconLabel {
|
|
24
|
+
margin: 0px 8px;
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.dropdownArrow {
|
|
29
|
+
display: flex;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.envFilterDropdownContainer {
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.envFilterDropdown {
|
|
39
|
+
width: 100%;
|
|
40
|
+
// otherwise when the dropdown is open it clashes with the content of the tree
|
|
41
|
+
// (this is bizarre, the tree has no position absolute)
|
|
42
|
+
z-index: $nav-z-index;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.envDropdownItemContainer {
|
|
46
|
+
display: flex;
|
|
47
|
+
width: calc(100% - 24px);
|
|
48
|
+
align-items: baseline;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.envDropdownItemIconContainer {
|
|
53
|
+
display: flex;
|
|
54
|
+
height: 16px;
|
|
55
|
+
width: 16px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.envDropdownItem {
|
|
59
|
+
padding-left: 8px;
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
width: 100%;
|
|
63
|
+
font-size: var(--bit-p-md, 16px);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.envDropdownItemLabel,
|
|
67
|
+
.envDropdownItemIcon {
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
padding-left: 8px;
|
|
71
|
+
}
|
|
72
|
+
.description {
|
|
73
|
+
font-size: var(--bit-p-xs, 14px);
|
|
74
|
+
padding-left: 8px;
|
|
75
|
+
padding-right: 16px;
|
|
76
|
+
color: var(--bit-text-color-light, #6c707c);
|
|
77
|
+
width: calc(100% - 24px);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.envDropdownItemContainerWithIcon {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: row;
|
|
83
|
+
justify-content: space-between;
|
|
84
|
+
width: calc(100% - 24px);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.descriptionText {
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.envLink {
|
|
92
|
+
color: white;
|
|
93
|
+
text-decoration: none;
|
|
94
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EnvsFilter } from './envs-filter';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EnvsFilter = void 0;
|
|
4
|
+
var envs_filter_1 = require("./envs-filter");
|
|
5
|
+
Object.defineProperty(exports, "EnvsFilter", { enumerable: true, get: function () { return envs_filter_1.EnvsFilter; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@import '@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
|
2
|
+
.envsFilterContainer {
|
|
3
|
+
> div {
|
|
4
|
+
line-height: 16px;
|
|
5
|
+
display: flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.filterIcon {
|
|
9
|
+
display: flex;
|
|
10
|
+
padding: 8px;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
background: var(--bit-bg-heavy, #f6f6f6);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
img {
|
|
19
|
+
width: 16px;
|
|
20
|
+
filter: invert(44%) sepia(7%) saturate(560%) hue-rotate(187deg) brightness(96%) contrast(91%);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.filterIconLabel {
|
|
24
|
+
margin: 0px 8px;
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.dropdownArrow {
|
|
29
|
+
display: flex;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.envFilterDropdownContainer {
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.envFilterDropdown {
|
|
39
|
+
width: 100%;
|
|
40
|
+
// otherwise when the dropdown is open it clashes with the content of the tree
|
|
41
|
+
// (this is bizarre, the tree has no position absolute)
|
|
42
|
+
z-index: $nav-z-index;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.envDropdownItemContainer {
|
|
46
|
+
display: flex;
|
|
47
|
+
width: calc(100% - 24px);
|
|
48
|
+
align-items: baseline;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.envDropdownItemIconContainer {
|
|
53
|
+
display: flex;
|
|
54
|
+
height: 16px;
|
|
55
|
+
width: 16px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.envDropdownItem {
|
|
59
|
+
padding-left: 8px;
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
width: 100%;
|
|
63
|
+
font-size: var(--bit-p-md, 16px);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.envDropdownItemLabel,
|
|
67
|
+
.envDropdownItemIcon {
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
padding-left: 8px;
|
|
71
|
+
}
|
|
72
|
+
.description {
|
|
73
|
+
font-size: var(--bit-p-xs, 14px);
|
|
74
|
+
padding-left: 8px;
|
|
75
|
+
padding-right: 16px;
|
|
76
|
+
color: var(--bit-text-color-light, #6c707c);
|
|
77
|
+
width: calc(100% - 24px);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.envDropdownItemContainerWithIcon {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: row;
|
|
83
|
+
justify-content: space-between;
|
|
84
|
+
width: calc(100% - 24px);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.descriptionText {
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.envLink {
|
|
92
|
+
color: white;
|
|
93
|
+
text-decoration: none;
|
|
94
|
+
}
|
package/envs-filter.tsx
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import React, { useMemo, useEffect } from 'react';
|
|
2
|
+
import { MultiSelect, ItemType } from '@teambit/design.inputs.selectors.multi-select';
|
|
3
|
+
import { ComponentID, ComponentModel } from '@teambit/component';
|
|
4
|
+
import { ComponentUrl } from '@teambit/component.modules.component-url';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { Ellipsis } from '@teambit/design.ui.styles.ellipsis';
|
|
7
|
+
import { Tooltip } from '@teambit/design.ui.tooltip';
|
|
8
|
+
import { Link as BaseLink } from '@teambit/base-react.navigation.link';
|
|
9
|
+
import {
|
|
10
|
+
ComponentFilterCriteria,
|
|
11
|
+
ComponentFilterRenderProps,
|
|
12
|
+
useComponentFilter,
|
|
13
|
+
useComponentFilters,
|
|
14
|
+
runAllFilters,
|
|
15
|
+
} from '@teambit/component.ui.component-filters.component-filter-context';
|
|
16
|
+
|
|
17
|
+
import styles from './envs-filter.module.scss';
|
|
18
|
+
|
|
19
|
+
// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest
|
|
20
|
+
const Link = BaseLink as any;
|
|
21
|
+
|
|
22
|
+
type EnvFilterEnvState = {
|
|
23
|
+
active: boolean;
|
|
24
|
+
icon?: string;
|
|
25
|
+
displayName: string;
|
|
26
|
+
id: string;
|
|
27
|
+
description: string;
|
|
28
|
+
componentId: ComponentID;
|
|
29
|
+
};
|
|
30
|
+
export type EnvFilterState = {
|
|
31
|
+
envsState: Map<string, EnvFilterEnvState>;
|
|
32
|
+
dropdownState: boolean;
|
|
33
|
+
};
|
|
34
|
+
export type EnvsFilterCriteria = ComponentFilterCriteria<EnvFilterState>;
|
|
35
|
+
|
|
36
|
+
export const EnvsFilter: EnvsFilterCriteria = {
|
|
37
|
+
id: 'envs',
|
|
38
|
+
match: ({ component }, filter) => {
|
|
39
|
+
const { envsState } = filter;
|
|
40
|
+
const areAllEnvsActive = [...envsState.values()].every((envState) => envState.active);
|
|
41
|
+
const activeEnvs = [...envsState.values()].filter((envState) => envState.active).map((envState) => envState.id);
|
|
42
|
+
// match everything when no envs are set or all envs are set
|
|
43
|
+
if (activeEnvs.length === 0 || areAllEnvsActive) return true;
|
|
44
|
+
|
|
45
|
+
const envId =
|
|
46
|
+
component.environment && ComponentID.tryFromString(component.environment.id)?.toStringWithoutVersion();
|
|
47
|
+
|
|
48
|
+
const matches = !!envId && activeEnvs.indexOf(envId) >= 0;
|
|
49
|
+
return matches;
|
|
50
|
+
},
|
|
51
|
+
state: {
|
|
52
|
+
envsState: new Map<string, EnvFilterEnvState>(),
|
|
53
|
+
dropdownState: false,
|
|
54
|
+
},
|
|
55
|
+
order: 1,
|
|
56
|
+
render: envsFilter,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const deriveEnvsFilterState = (components: ComponentModel[]) => {
|
|
60
|
+
return useMemo(() => {
|
|
61
|
+
const defaultState = {
|
|
62
|
+
dropdownState: false,
|
|
63
|
+
envsState: new Map<string, EnvFilterEnvState>(),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const componentEnvSet = new Set<string>();
|
|
67
|
+
|
|
68
|
+
const componentsEnvsWithIcons = components
|
|
69
|
+
.filter((component) => {
|
|
70
|
+
const envId = component.environment && ComponentID.tryFromString(component.environment.id);
|
|
71
|
+
|
|
72
|
+
if (!envId) return false;
|
|
73
|
+
|
|
74
|
+
const envKey = envId.toStringWithoutVersion();
|
|
75
|
+
|
|
76
|
+
if (componentEnvSet.has(envKey)) return false;
|
|
77
|
+
|
|
78
|
+
componentEnvSet.add(envKey);
|
|
79
|
+
|
|
80
|
+
return true;
|
|
81
|
+
})
|
|
82
|
+
.map((component) => {
|
|
83
|
+
const envId = ComponentID.fromString(component.environment?.id as string);
|
|
84
|
+
return {
|
|
85
|
+
displayName: envId.name,
|
|
86
|
+
id: envId.toStringWithoutVersion(),
|
|
87
|
+
description: `${envId.scope}${envId.namespace ? '/'.concat(envId.namespace) : ''}`,
|
|
88
|
+
icon: component.environment?.icon,
|
|
89
|
+
componentId: envId,
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
componentsEnvsWithIcons.forEach((componentEnvWithIcon) => {
|
|
94
|
+
defaultState.envsState.set(componentEnvWithIcon.id, { ...componentEnvWithIcon, active: true });
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return defaultState;
|
|
98
|
+
}, [components]);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
function envsFilter({ components, className, lanes }: ComponentFilterRenderProps) {
|
|
102
|
+
const [filters = []] = useComponentFilters() || [];
|
|
103
|
+
const filtersExceptEnv = filters.filter((filter) => filter.id !== EnvsFilter.id);
|
|
104
|
+
|
|
105
|
+
const filteredComponents = useMemo(
|
|
106
|
+
() => runAllFilters(filtersExceptEnv, { components, lanes }),
|
|
107
|
+
[JSON.stringify(filtersExceptEnv), lanes?.viewedLane?.id.toString()]
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const envsFilterState = deriveEnvsFilterState(filteredComponents);
|
|
111
|
+
|
|
112
|
+
const filterContext = useComponentFilter(EnvsFilter.id, envsFilterState);
|
|
113
|
+
|
|
114
|
+
const envs = envsFilterState.envsState;
|
|
115
|
+
|
|
116
|
+
const [currentFilter, updateFilter] = filterContext || [];
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* this will not work if other filters in a single re-render
|
|
120
|
+
* result in the same number of components with different ids
|
|
121
|
+
*/
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
updateFilter?.((currentState) => {
|
|
124
|
+
currentState.state = envsFilterState;
|
|
125
|
+
return currentState;
|
|
126
|
+
});
|
|
127
|
+
}, [filteredComponents.length, lanes?.viewedLane?.id.toString()]);
|
|
128
|
+
|
|
129
|
+
const selectList: ItemType[] = [];
|
|
130
|
+
|
|
131
|
+
envs.forEach((state) => {
|
|
132
|
+
selectList.push({
|
|
133
|
+
value: state.id,
|
|
134
|
+
icon: state.icon,
|
|
135
|
+
description: state.description,
|
|
136
|
+
checked: !!currentFilter?.state.envsState.get(state.id)?.active,
|
|
137
|
+
element: <EnvsDropdownItem {...state} />,
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const onCheck = (value: string, e: React.ChangeEvent<HTMLInputElement>) => {
|
|
142
|
+
const checked = e.target.checked;
|
|
143
|
+
|
|
144
|
+
updateFilter?.((currentState) => {
|
|
145
|
+
if (checked && !currentState.state.dropdownState) {
|
|
146
|
+
currentState.state.dropdownState = true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const currentEnvState = currentState.state.envsState.get(value);
|
|
150
|
+
|
|
151
|
+
if (!currentEnvState) return currentState;
|
|
152
|
+
|
|
153
|
+
currentState.state.envsState.set(value, { ...currentEnvState, active: checked });
|
|
154
|
+
return currentState;
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const onClear = () => {
|
|
159
|
+
updateFilter?.((currentState) => {
|
|
160
|
+
currentState.state.envsState.forEach((value, key) => {
|
|
161
|
+
currentState.state.envsState.set(key, { ...value, active: false });
|
|
162
|
+
});
|
|
163
|
+
return currentState;
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const onSubmit = () => {
|
|
168
|
+
updateFilter?.((currentState) => {
|
|
169
|
+
currentState.state.dropdownState = false;
|
|
170
|
+
return currentState;
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const onDropdownToggled = (event, open) => {
|
|
175
|
+
updateFilter?.((currentState) => {
|
|
176
|
+
currentState.state.dropdownState = open;
|
|
177
|
+
return currentState;
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<div className={classNames(styles.envsFilterContainer, className)}>
|
|
183
|
+
<MultiSelect
|
|
184
|
+
itemsList={selectList}
|
|
185
|
+
placeholder={<EnvsPlaceholder />}
|
|
186
|
+
onSubmit={onSubmit}
|
|
187
|
+
onCheck={onCheck}
|
|
188
|
+
onClear={onClear}
|
|
189
|
+
onChange={onDropdownToggled}
|
|
190
|
+
open={!!currentFilter?.state.dropdownState}
|
|
191
|
+
dropdownBorder={false}
|
|
192
|
+
className={styles.envFilterDropdownContainer}
|
|
193
|
+
dropClass={styles.envFilterDropdown}
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function EnvsPlaceholder() {
|
|
200
|
+
return (
|
|
201
|
+
<div className={styles.filterIcon}>
|
|
202
|
+
<img src="https://static.bit.dev/bit-icons/env.svg" />
|
|
203
|
+
<span className={styles.filterIconLabel}>Environments</span>
|
|
204
|
+
<div className={styles.dropdownArrow}>
|
|
205
|
+
<img src="https://static.bit.dev/bit-icons/fat-arrow-down.svg" />
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function EnvsDropdownItem({ displayName, icon, description, componentId, id }: EnvFilterEnvState) {
|
|
212
|
+
return (
|
|
213
|
+
<Tooltip
|
|
214
|
+
placement="right"
|
|
215
|
+
content={
|
|
216
|
+
<Link
|
|
217
|
+
className={styles.envLink}
|
|
218
|
+
href={ComponentUrl.toUrl(componentId, { includeVersion: false })}
|
|
219
|
+
external={true}
|
|
220
|
+
>
|
|
221
|
+
{id}
|
|
222
|
+
</Link>
|
|
223
|
+
}
|
|
224
|
+
>
|
|
225
|
+
<div className={styles.envDropdownItemContainer}>
|
|
226
|
+
<div className={styles.envDropdownItem}>
|
|
227
|
+
<Ellipsis>{displayName}</Ellipsis>
|
|
228
|
+
<div className={styles.envDropdownItemIconContainer}>
|
|
229
|
+
<img className={styles.envDropdownItemIcon} src={icon}></img>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
<div className={styles.description}>
|
|
233
|
+
<Ellipsis className={styles.descriptionText}>{description}</Ellipsis>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
</Tooltip>
|
|
237
|
+
);
|
|
238
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EnvsFilter } from './envs-filter';
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/component.ui.component-filters.env-filter",
|
|
3
|
+
"version": "0.0.0-0e0d9d06bb0bbc7c40e8a6b302956f30fe7cdc96",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/component/ui/component-filters/env-filter",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"componentId": {
|
|
7
|
+
"scope": "teambit.component",
|
|
8
|
+
"name": "ui/component-filters/env-filter",
|
|
9
|
+
"version": "0e0d9d06bb0bbc7c40e8a6b302956f30fe7cdc96"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"classnames": "2.2.6",
|
|
13
|
+
"core-js": "^3.0.0",
|
|
14
|
+
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.504",
|
|
15
|
+
"@teambit/component.ui.component-filters.component-filter-context": "0.0.238",
|
|
16
|
+
"@teambit/design.inputs.selectors.multi-select": "0.0.20",
|
|
17
|
+
"@teambit/design.ui.styles.ellipsis": "0.0.357",
|
|
18
|
+
"@teambit/design.ui.tooltip": "0.0.378",
|
|
19
|
+
"@teambit/component.modules.component-url": "0.0.0-84089beb8bf36eeeeaf8f3bed660d264bf60fc6b"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/classnames": "2.2.11",
|
|
23
|
+
"@types/react": "^17.0.8",
|
|
24
|
+
"@types/mocha": "9.1.0",
|
|
25
|
+
"@types/node": "12.20.4",
|
|
26
|
+
"@types/react-dom": "^17.0.5",
|
|
27
|
+
"@types/jest": "^26.0.0",
|
|
28
|
+
"@babel/runtime": "7.20.0",
|
|
29
|
+
"@types/testing-library__jest-dom": "5.9.5"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^16.8.0 || ^17.0.0",
|
|
33
|
+
"react-dom": "^16.8.0 || ^17.0.0",
|
|
34
|
+
"@teambit/base-react.navigation.link": "2.0.33"
|
|
35
|
+
},
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"optionalDependencies": {},
|
|
38
|
+
"peerDependenciesMeta": {},
|
|
39
|
+
"private": false,
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=12.22.0"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/teambit/bit"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"bit",
|
|
49
|
+
"components",
|
|
50
|
+
"collaboration",
|
|
51
|
+
"web",
|
|
52
|
+
"react",
|
|
53
|
+
"react-components",
|
|
54
|
+
"angular",
|
|
55
|
+
"angular-components"
|
|
56
|
+
]
|
|
57
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|