Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters polishing, remove displaying rotation modal for Terraform/API based schedules #3259

Merged
merged 8 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions grafana-plugin/src/components/LabelsFilter/LabelsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ const LabelsFilter: FC<LabelsFilterProps> = (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,
}))
);
};
Expand All @@ -37,7 +38,8 @@ const LabelsFilter: FC<LabelsFilterProps> = (props) => {
() =>
propsValue.map((v) => ({
label: `${v.key[FieldName]} : ${v.value[FieldName]}`,
value: v,
value: `${v.key[FieldName]} : ${v.value[FieldName]}`,
data: v,
})),
[propsValue]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class RemoteFilters extends Component<RemoteFiltersProps, RemoteFiltersState> {

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());
}
Expand Down Expand Up @@ -273,6 +273,7 @@ class RemoteFilters extends Component<RemoteFiltersProps, RemoteFiltersState> {
value={values[filter.name]}
onChange={this.getRemoteOptionsChangeHandler(filter.name)}
getOptionLabel={(item: SelectableValue) => <Emoji text={item.label || ''} />}
predefinedOptions={filter.default ? [filter.default] : undefined}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface RemoteSelectProps {
showError?: boolean;
maxMenuHeight?: number;
requiredUserAction?: UserAction;
predefinedOptions?: any[];
}

const RemoteSelect = inject('store')(
Expand All @@ -49,6 +50,7 @@ const RemoteSelect = inject('store')(
showError,
maxMenuHeight,
requiredUserAction,
predefinedOptions,
} = props;

const [noOptionsMessage, setNoOptionsMessage] = useState<string>('No options found');
Expand All @@ -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 {
Expand Down
22 changes: 7 additions & 15 deletions grafana-plugin/src/pages/schedule/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,13 @@ class SchedulePage extends React.Component<SchedulePageProps, SchedulePageState>
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);
}
}
}
/>
Expand Down Expand Up @@ -382,20 +388,6 @@ class SchedulePage extends React.Component<SchedulePageProps, SchedulePageState>
});
};

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 });
};
Expand Down