diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7acb05..8d201ce3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +- User filter doesn't display current value on Alert Groups page ([1714](https://github.com/grafana/oncall/issues/1714)) +- Remove displaying rotation modal for Terraform/API based schedules +- Filters polishing ([3183](https://github.com/grafana/oncall/issues/3183)) + ## v1.3.62 (2023-11-21) ### Added diff --git a/grafana-plugin/src/components/LabelsFilter/LabelsFilter.tsx b/grafana-plugin/src/components/LabelsFilter/LabelsFilter.tsx index 652941f6..57547385 100644 --- a/grafana-plugin/src/components/LabelsFilter/LabelsFilter.tsx +++ b/grafana-plugin/src/components/LabelsFilter/LabelsFilter.tsx @@ -21,14 +21,15 @@ const LabelsFilter: FC = (props) => { const [search, setSearch] = useState(''); const handleChange = useCallback((value) => { - onChange(value.map((v) => v.value)); + onChange(value.map((v) => v.data)); }, []); const handleLoadOptions = (search) => { return onLoadOptions(search).then((options) => options.map((v) => ({ label: `${v.key[FieldName]} : ${v.value[FieldName]}`, - value: v, + value: `${v.key[FieldName]} : ${v.value[FieldName]}`, + data: v, })) ); }; @@ -37,7 +38,8 @@ const LabelsFilter: FC = (props) => { () => propsValue.map((v) => ({ label: `${v.key[FieldName]} : ${v.value[FieldName]}`, - value: v, + value: `${v.key[FieldName]} : ${v.value[FieldName]}`, + data: v, })), [propsValue] ); diff --git a/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx b/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx index 735d855f..769be69a 100644 --- a/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx +++ b/grafana-plugin/src/containers/RemoteFilters/RemoteFilters.tsx @@ -75,7 +75,7 @@ class RemoteFilters extends Component { const { filterOptions } = this.state; - let { filters, values } = parseFilters(query, filterOptions, query); + let { filters, values } = parseFilters({ ...query, ...filtersStore.globalValues }, filterOptions, query); this.setState({ filterOptions, filters, values }, () => this.onChange()); } @@ -273,6 +273,7 @@ class RemoteFilters extends Component { value={values[filter.name]} onChange={this.getRemoteOptionsChangeHandler(filter.name)} getOptionLabel={(item: SelectableValue) => } + predefinedOptions={filter.default ? [filter.default] : undefined} /> ); diff --git a/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx b/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx index b9572040..377af14f 100644 --- a/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx +++ b/grafana-plugin/src/containers/RemoteSelect/RemoteSelect.tsx @@ -27,6 +27,7 @@ interface RemoteSelectProps { showError?: boolean; maxMenuHeight?: number; requiredUserAction?: UserAction; + predefinedOptions?: any[]; } const RemoteSelect = inject('store')( @@ -49,6 +50,7 @@ const RemoteSelect = inject('store')( showError, maxMenuHeight, requiredUserAction, + predefinedOptions, } = props; const [noOptionsMessage, setNoOptionsMessage] = useState('No options found'); @@ -66,7 +68,7 @@ const RemoteSelect = inject('store')( return oldOptions.concat(newOptions.filter(({ value }) => !existingValues.includes(value))); } - const [options, setOptions] = useReducer(mergeOptions, []); + const [options, setOptions] = useReducer(mergeOptions, getOptions(predefinedOptions || [])); const loadOptionsCallback = useDebouncedCallback(async (query: string, cb) => { try { diff --git a/grafana-plugin/src/pages/schedule/Schedule.tsx b/grafana-plugin/src/pages/schedule/Schedule.tsx index a386332d..c1ceeda0 100644 --- a/grafana-plugin/src/pages/schedule/Schedule.tsx +++ b/grafana-plugin/src/pages/schedule/Schedule.tsx @@ -291,7 +291,13 @@ class SchedulePage extends React.Component shiftSwapIdToShowForm ? this.adjustShiftSwapForm : (event: Event) => { - this.handleShowForm(event.shift.pk); + const shiftId = event.shift.pk; + + if (event.shift.type === 2 && !disabledRotationForm) { + this.handleShowRotationForm(shiftId); + } else if (event.shift.type === 3 && !disabledOverrideForm) { + this.handleShowOverridesForm(shiftId); + } } } /> @@ -382,20 +388,6 @@ class SchedulePage extends React.Component }); }; - handleShowForm = async (shiftId: Shift['id'] | 'new') => { - const { - store: { scheduleStore }, - } = this.props; - - const shift = await scheduleStore.updateOncallShift(shiftId); - - if (shift.type === 2) { - this.handleShowRotationForm(shiftId); - } else if (shift.type === 3) { - this.handleShowOverridesForm(shiftId); - } - }; - handleShowRotationForm = (shiftId: Shift['id'] | 'new') => { this.setState({ shiftIdToShowRotationForm: shiftId }); };