@grafana/scenes 6.31.0 → 6.32.0--canary.1192.17234567041.0
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/esm/querying/SceneQueryRunner.js +1 -1
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/variables/groupby/GroupByValueContainer.js +37 -0
- package/dist/esm/variables/groupby/GroupByValueContainer.js.map +1 -0
- package/dist/esm/variables/groupby/GroupByVariable.js +43 -2
- package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +75 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3311,7 +3311,7 @@ function wrapInSafeSerializableSceneObject(sceneObject) {
|
|
|
3311
3311
|
function DefaultGroupByCustomIndicatorContainer(props) {
|
|
3312
3312
|
const { model } = props;
|
|
3313
3313
|
const theme = ui.useTheme2();
|
|
3314
|
-
const styles = getStyles$
|
|
3314
|
+
const styles = getStyles$i(theme);
|
|
3315
3315
|
const inputStyles = ui.getInputStyles({ theme, invalid: false });
|
|
3316
3316
|
const value = lodash.isArray(model.state.value) ? model.state.value : model.state.value ? [model.state.value] : [];
|
|
3317
3317
|
let buttons = [];
|
|
@@ -3393,7 +3393,7 @@ function DefaultGroupByCustomIndicatorContainer(props) {
|
|
|
3393
3393
|
buttons
|
|
3394
3394
|
);
|
|
3395
3395
|
}
|
|
3396
|
-
const getStyles$
|
|
3396
|
+
const getStyles$i = (theme) => ({
|
|
3397
3397
|
clearIcon: css.css({
|
|
3398
3398
|
color: theme.colors.action.disabledText,
|
|
3399
3399
|
cursor: "pointer",
|
|
@@ -3406,6 +3406,37 @@ const getStyles$h = (theme) => ({
|
|
|
3406
3406
|
})
|
|
3407
3407
|
});
|
|
3408
3408
|
|
|
3409
|
+
const GroupByValueContainer = ({
|
|
3410
|
+
keysApplicability,
|
|
3411
|
+
children
|
|
3412
|
+
}) => {
|
|
3413
|
+
var _a, _b;
|
|
3414
|
+
const theme = ui.useTheme2();
|
|
3415
|
+
const styles = ui.getSelectStyles(theme);
|
|
3416
|
+
const { nonApplicablePill } = getStyles$h(theme);
|
|
3417
|
+
const firstChild = React__default.default.Children.toArray(children)[0];
|
|
3418
|
+
let isApplicable = true;
|
|
3419
|
+
if (React__default.default.isValidElement(firstChild) && ((_b = (_a = firstChild.props) == null ? void 0 : _a.data) == null ? void 0 : _b.value)) {
|
|
3420
|
+
const value = firstChild.props.data.value;
|
|
3421
|
+
const applicability = keysApplicability == null ? void 0 : keysApplicability.find((item) => item.key === value);
|
|
3422
|
+
if (applicability && !applicability.applicable) {
|
|
3423
|
+
isApplicable = false;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: css.cx(styles.multiValueContainer, !isApplicable && nonApplicablePill) }, children);
|
|
3427
|
+
};
|
|
3428
|
+
const getStyles$h = (theme) => ({
|
|
3429
|
+
nonApplicablePill: css.css({
|
|
3430
|
+
background: theme.colors.action.selected,
|
|
3431
|
+
color: theme.colors.text.disabled,
|
|
3432
|
+
border: 0,
|
|
3433
|
+
"&:hover": {
|
|
3434
|
+
background: theme.colors.action.selected
|
|
3435
|
+
},
|
|
3436
|
+
textDecoration: "line-through"
|
|
3437
|
+
})
|
|
3438
|
+
});
|
|
3439
|
+
|
|
3409
3440
|
class GroupByVariable extends MultiValueVariable {
|
|
3410
3441
|
constructor(initialState) {
|
|
3411
3442
|
super({
|
|
@@ -3425,6 +3456,7 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3425
3456
|
this.isLazy = true;
|
|
3426
3457
|
this._urlSync = new GroupByVariableUrlSyncHandler(this);
|
|
3427
3458
|
this._activationHandler = () => {
|
|
3459
|
+
this._verifyApplicability();
|
|
3428
3460
|
if (this.state.defaultValue) {
|
|
3429
3461
|
if (this.checkIfRestorable(this.state.value)) {
|
|
3430
3462
|
this.setState({ restorable: true });
|
|
@@ -3542,6 +3574,40 @@ class GroupByVariable extends MultiValueVariable {
|
|
|
3542
3574
|
})
|
|
3543
3575
|
);
|
|
3544
3576
|
}
|
|
3577
|
+
getApplicableKeys() {
|
|
3578
|
+
const { value, keysApplicability } = this.state;
|
|
3579
|
+
const valueArray = lodash.isArray(value) ? value : value ? [value] : [];
|
|
3580
|
+
if (!keysApplicability || keysApplicability.length === 0) {
|
|
3581
|
+
return valueArray;
|
|
3582
|
+
}
|
|
3583
|
+
const applicableValues = valueArray.filter((val) => {
|
|
3584
|
+
const applicability = keysApplicability.find((item) => item.key === val);
|
|
3585
|
+
return !applicability || applicability.applicable !== false;
|
|
3586
|
+
});
|
|
3587
|
+
return applicableValues;
|
|
3588
|
+
}
|
|
3589
|
+
async _verifyApplicability() {
|
|
3590
|
+
const ds = await getDataSource(this.state.datasource, {
|
|
3591
|
+
__sceneObject: wrapInSafeSerializableSceneObject(this)
|
|
3592
|
+
});
|
|
3593
|
+
if (!ds.getFiltersApplicability) {
|
|
3594
|
+
return;
|
|
3595
|
+
}
|
|
3596
|
+
const queries = getQueriesForVariables(this);
|
|
3597
|
+
const timeRange = sceneGraph.getTimeRange(this).state.value;
|
|
3598
|
+
const value = this.state.value;
|
|
3599
|
+
const response = await ds.getFiltersApplicability({
|
|
3600
|
+
groupByKeys: Array.isArray(value) ? value.map((v) => String(v)) : value ? [String(value)] : [],
|
|
3601
|
+
queries,
|
|
3602
|
+
timeRange,
|
|
3603
|
+
scopes: sceneGraph.getScopes(this),
|
|
3604
|
+
...getEnrichedFiltersRequest(this)
|
|
3605
|
+
});
|
|
3606
|
+
if (!lodash.isEqual(response, this.state.keysApplicability)) {
|
|
3607
|
+
this.setState({ keysApplicability: response });
|
|
3608
|
+
this.publishEvent(new SceneVariableValueChangedEvent(this), true);
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3545
3611
|
// This method is related to the defaultValue property. We check if the current value
|
|
3546
3612
|
// is different from the default value. If it is, the groupBy will show a button
|
|
3547
3613
|
// allowing the user to restore the default values.
|
|
@@ -3580,7 +3646,8 @@ function GroupByVariableRenderer({ model }) {
|
|
|
3580
3646
|
options,
|
|
3581
3647
|
includeAll,
|
|
3582
3648
|
allowCustomValue = true,
|
|
3583
|
-
defaultValue
|
|
3649
|
+
defaultValue,
|
|
3650
|
+
keysApplicability
|
|
3584
3651
|
} = model.useState();
|
|
3585
3652
|
const values = React.useMemo(() => {
|
|
3586
3653
|
const arrayValue = lodash.isArray(value) ? value : [value];
|
|
@@ -3652,7 +3719,8 @@ function GroupByVariableRenderer({ model }) {
|
|
|
3652
3719
|
Option: OptionWithCheckbox,
|
|
3653
3720
|
...hasDefaultValue ? {
|
|
3654
3721
|
IndicatorsContainer: () => /* @__PURE__ */ React__default.default.createElement(DefaultGroupByCustomIndicatorContainer, { model })
|
|
3655
|
-
} : {}
|
|
3722
|
+
} : {},
|
|
3723
|
+
MultiValueContainer: ({ innerProps, children }) => /* @__PURE__ */ React__default.default.createElement(GroupByValueContainer, { innerProps, keysApplicability }, children)
|
|
3656
3724
|
},
|
|
3657
3725
|
onInputChange,
|
|
3658
3726
|
onBlur: () => {
|
|
@@ -3669,6 +3737,8 @@ function GroupByVariableRenderer({ model }) {
|
|
|
3669
3737
|
onChange: (newValue, action) => {
|
|
3670
3738
|
if (action.action === "clear" && noValueOnClear) {
|
|
3671
3739
|
model.changeValueTo([], void 0, true);
|
|
3740
|
+
} else {
|
|
3741
|
+
model._verifyApplicability();
|
|
3672
3742
|
}
|
|
3673
3743
|
setUncommittedValue(newValue);
|
|
3674
3744
|
},
|
|
@@ -6708,7 +6778,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
|
6708
6778
|
].filter((f) => isFilterComplete(f) && isFilterApplicable(f));
|
|
6709
6779
|
}
|
|
6710
6780
|
if (this._groupByVar) {
|
|
6711
|
-
request.groupByKeys = this._groupByVar.
|
|
6781
|
+
request.groupByKeys = this._groupByVar.getApplicableKeys();
|
|
6712
6782
|
}
|
|
6713
6783
|
request.targets = request.targets.map((query) => {
|
|
6714
6784
|
var _a2;
|