Revert "add missing @action.bound (#3647)"
This reverts commit af8e61c733.
This commit is contained in:
parent
47286bd50c
commit
a34feca44f
29 changed files with 139 additions and 247 deletions
|
|
@ -68,7 +68,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
this.path = '/alert_receive_channels/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(_query = '') {
|
||||
if (!this.searchResult) {
|
||||
return undefined;
|
||||
|
|
@ -79,7 +78,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getPaginatedSearchResult(_query = '') {
|
||||
if (!this.paginatedSearchResult) {
|
||||
return undefined;
|
||||
|
|
@ -94,7 +92,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
};
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async loadItem(id: AlertReceiveChannel['id'], skipErrorHandling = false): Promise<AlertReceiveChannel> {
|
||||
const alertReceiveChannel = await this.getById(id, skipErrorHandling);
|
||||
|
||||
|
|
@ -111,7 +109,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
return alertReceiveChannel;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query: any = '') {
|
||||
const params = typeof query === 'string' ? { search: query } : query;
|
||||
|
||||
|
|
@ -141,7 +139,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
return results;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async updatePaginatedItems({
|
||||
filters,
|
||||
page = 1,
|
||||
|
|
@ -189,7 +186,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
return results;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
populateHearbeats(alertReceiveChannels: AlertReceiveChannel[]) {
|
||||
const heartbeats = alertReceiveChannels.reduce((acc: any, alertReceiveChannel: AlertReceiveChannel) => {
|
||||
if (alertReceiveChannel.heartbeat) {
|
||||
|
|
@ -225,7 +221,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateChannelFilters(alertReceiveChannelId: AlertReceiveChannel['id'], isOverwrite = false) {
|
||||
const response = await makeRequest(`/channel_filters/`, {
|
||||
params: { alert_receive_channel: alertReceiveChannelId },
|
||||
|
|
@ -263,7 +259,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateChannelFilter(channelFilterId: ChannelFilter['id']) {
|
||||
const response = await makeRequest(`/channel_filters/${channelFilterId}/`, {});
|
||||
|
||||
|
|
@ -274,14 +270,13 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
};
|
||||
});
|
||||
}
|
||||
@action.bound
|
||||
|
||||
async migrateChannel(id: AlertReceiveChannel['id']) {
|
||||
return await makeRequest(`/alert_receive_channels/${id}/migrate`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async createChannelFilter(data: Partial<ChannelFilter>) {
|
||||
return await makeRequest('/channel_filters/', {
|
||||
method: 'POST',
|
||||
|
|
@ -289,7 +284,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async saveChannelFilter(channelFilterId: ChannelFilter['id'], data: Partial<ChannelFilter>) {
|
||||
const response = await makeRequest(`/channel_filters/${channelFilterId}/`, {
|
||||
method: 'PUT',
|
||||
|
|
@ -306,7 +301,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
return response;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async moveChannelFilterToPosition(
|
||||
alertReceiveChannelId: AlertReceiveChannel['id'],
|
||||
oldIndex: number,
|
||||
|
|
@ -325,7 +320,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
this.updateChannelFilters(alertReceiveChannelId, true);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async deleteChannelFilter(channelFilterId: ChannelFilter['id']) {
|
||||
const channelFilter = this.channelFilters[channelFilterId];
|
||||
|
||||
|
|
@ -350,7 +345,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getIntegration(alertReceiveChannel: Partial<AlertReceiveChannel>): SelectOption {
|
||||
return (
|
||||
this.alertReceiveChannelOptions &&
|
||||
|
|
@ -374,12 +368,11 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async deleteAlertReceiveChannel(id: AlertReceiveChannel['id']) {
|
||||
return await this.delete(id);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateTemplates(alertReceiveChannelId: AlertReceiveChannel['id'], alertGroupId?: Alert['pk']) {
|
||||
const response = await makeRequest(`/alert_receive_channel_templates/${alertReceiveChannelId}/`, {
|
||||
params: { alert_group_id: alertGroupId },
|
||||
|
|
@ -394,7 +387,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItem(id: AlertReceiveChannel['id']) {
|
||||
const item = await this.getById(id);
|
||||
|
||||
|
|
@ -406,7 +399,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async saveTemplates(alertReceiveChannelId: AlertReceiveChannel['id'], data: Partial<AlertTemplatesDTO>) {
|
||||
const response = await makeRequest(`/alert_receive_channel_templates/${alertReceiveChannelId}/`, {
|
||||
method: 'PUT',
|
||||
|
|
@ -422,12 +415,11 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getGrafanaAlertingContactPoints() {
|
||||
return await makeRequest(`${this.path}contact_points/`, {}).catch(showApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateConnectedContactPoints(alertReceiveChannelId: AlertReceiveChannel['id']) {
|
||||
const response = await makeRequest(`${this.path}${alertReceiveChannelId}/connected_contact_points `, {});
|
||||
|
||||
|
|
@ -451,7 +443,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async connectContactPoint(
|
||||
alertReceiveChannelId: AlertReceiveChannel['id'],
|
||||
datasource_uid: string,
|
||||
|
|
@ -466,7 +457,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async disconnectContactPoint(
|
||||
alertReceiveChannelId: AlertReceiveChannel['id'],
|
||||
datasource_uid: string,
|
||||
|
|
@ -481,7 +471,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async createContactPoint(
|
||||
alertReceiveChannelId: AlertReceiveChannel['id'],
|
||||
datasource_uid: string,
|
||||
|
|
@ -496,14 +485,12 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getAccessLogs(alertReceiveChannelId: AlertReceiveChannel['id']) {
|
||||
const { integration_log } = await makeRequest(`/alert_receive_channel_access_log/${alertReceiveChannelId}/`, {});
|
||||
|
||||
return integration_log;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async sendDemoAlert(id: AlertReceiveChannel['id'], payload: string = undefined) {
|
||||
const requestConfig: any = {
|
||||
method: 'POST',
|
||||
|
|
@ -518,12 +505,10 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
await makeRequest(`${this.path}${id}/send_demo_alert/`, requestConfig).catch(showApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async sendDemoAlertToParticularRoute(id: ChannelFilter['id']) {
|
||||
await makeRequest(`/channel_filters/${id}/send_demo_alert/`, { method: 'POST' }).catch(showApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async convertRegexpTemplateToJinja2Template(id: ChannelFilter['id']) {
|
||||
const result = await makeRequest(`/channel_filters/${id}/convert_from_regex_to_jinja2/`, { method: 'POST' }).catch(
|
||||
showApiError
|
||||
|
|
@ -531,7 +516,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
return result;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async renderPreview(id: AlertReceiveChannel['id'], template_name: string, template_body: string, payload: JSON) {
|
||||
return await makeRequest(`${this.path}${id}/preview_template/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -539,7 +523,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async changeTeam(id: AlertReceiveChannel['id'], teamId: GrafanaTeam['id']) {
|
||||
return await makeRequest(`${this.path}${id}/change_team`, {
|
||||
params: { team_id: String(teamId) },
|
||||
|
|
@ -547,7 +530,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateCounters() {
|
||||
const counters = await makeRequest(`${this.path}counters`, {
|
||||
method: 'GET',
|
||||
|
|
@ -558,7 +541,7 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateCountersForIntegration(id: AlertReceiveChannel['id']): Promise<any> {
|
||||
const counters = await makeRequest(`${this.path}${id}/counters`, {
|
||||
method: 'GET',
|
||||
|
|
@ -576,7 +559,6 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
return counters;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
startMaintenanceMode = (id: AlertReceiveChannel['id'], mode: MaintenanceMode, duration: number): Promise<void> =>
|
||||
makeRequest<null>(`${this.path}${id}/start_maintenance/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -586,13 +568,11 @@ export class AlertReceiveChannelStore extends BaseStore {
|
|||
},
|
||||
});
|
||||
|
||||
@action.bound
|
||||
stopMaintenanceMode = (id: AlertReceiveChannel['id']) =>
|
||||
makeRequest<null>(`${this.path}${id}/stop_maintenance/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
@action.bound
|
||||
addLabel = (id: AlertReceiveChannel['id'], data) => {
|
||||
makeRequest(`${this.path}${id}/associate_label`, {
|
||||
method: 'POST',
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ export class AlertReceiveChannelFiltersStore extends BaseStore {
|
|||
this.path = '/alert_receive_channels/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult() {
|
||||
if (!this.searchResult) {
|
||||
return undefined;
|
||||
|
|
@ -29,7 +28,7 @@ export class AlertReceiveChannelFiltersStore extends BaseStore {
|
|||
return this.searchResult.map((value: SelectOption['value']) => this.items?.[value]);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query = '') {
|
||||
const results = await makeRequest(`${this.path}`, {
|
||||
params: { search: query, filters: true },
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
this.path = '/alertgroups/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async attachAlert(pk: Alert['pk'], rootPk: Alert['pk']) {
|
||||
return await makeRequest(`${this.path}${pk}/attach/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -92,14 +91,13 @@ export class AlertGroupStore extends BaseStore {
|
|||
}).catch(showApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async unattachAlert(pk: Alert['pk']) {
|
||||
return await makeRequest(`${this.path}${pk}/unattach/`, {
|
||||
method: 'POST',
|
||||
}).catch(showApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItem(id: Alert['pk']) {
|
||||
const item = await this.getById(id);
|
||||
|
||||
|
|
@ -111,7 +109,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
@ -120,7 +117,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
return this.searchResult[query].map((id: Alert['pk']) => this.items[id]);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getAlertGroupsForIntegration(integrationId: AlertReceiveChannel['id']) {
|
||||
const { results } = await makeRequest(`${this.path}`, {
|
||||
params: { integration: integrationId },
|
||||
|
|
@ -128,12 +124,10 @@ export class AlertGroupStore extends BaseStore {
|
|||
return results;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getAlertsFromGroup(pk: Alert['pk']) {
|
||||
return await makeRequest(`${this.path}${pk}`, {});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async updateSilenceOptions() {
|
||||
const result = await makeRequest(`${this.path}silence_options/`, {});
|
||||
|
||||
|
|
@ -142,7 +136,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async resolve(id: Alert['pk'], delay: number) {
|
||||
await makeRequest(`${this.path}${id}/silence/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -150,28 +143,24 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async unresolve(id: Alert['pk']) {
|
||||
await makeRequest(`${this.path}${id}/unresolve/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async acknowledge(id: Alert['pk']) {
|
||||
await makeRequest(`${this.path}${id}/acknowledge/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async unacknowledge(id: Alert['pk']) {
|
||||
await makeRequest(`${this.path}${id}/unacknowledge/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async silence(id: Alert['pk'], delay: number) {
|
||||
await makeRequest(`${this.path}${id}/silence/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -179,14 +168,13 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async unsilence(id: Alert['pk']) {
|
||||
await makeRequest(`${this.path}${id}/unsilence/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateBulkActions() {
|
||||
const response = await makeRequest(`${this.path}bulk_action_options/`, {});
|
||||
|
||||
|
|
@ -201,7 +189,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async bulkAction(data: any) {
|
||||
return await makeRequest(`${this.path}bulk_action/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -209,7 +196,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async renderPreview(id: Alert['pk'], template_name: string, template_body: string) {
|
||||
return await makeRequest(`${this.path}${id}/preview_template/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -219,7 +205,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
|
||||
// methods were moved from rootBaseStore.
|
||||
// TODO check if methods are dublicating existing ones
|
||||
@action.bound
|
||||
async updateIncidents() {
|
||||
await Promise.all([
|
||||
this.getNewIncidentsStats(),
|
||||
|
|
@ -232,12 +217,12 @@ export class AlertGroupStore extends BaseStore {
|
|||
this.setLiveUpdatesPaused(false);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
setLiveUpdatesPaused(value: boolean) {
|
||||
this.liveUpdatesPaused = value;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateIncidentFilters(params: any, keepCursor = false) {
|
||||
if (!keepCursor) {
|
||||
this.setIncidentsCursor(undefined);
|
||||
|
|
@ -248,28 +233,28 @@ export class AlertGroupStore extends BaseStore {
|
|||
await this.updateIncidents();
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateIncidentsCursor(cursor: string) {
|
||||
this.setIncidentsCursor(cursor);
|
||||
|
||||
this.updateAlertGroups();
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async setIncidentsCursor(cursor: string) {
|
||||
this.incidentsCursor = cursor;
|
||||
|
||||
LocationHelper.update({ cursor }, 'partial');
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async setIncidentsItemsPerPage() {
|
||||
this.setIncidentsCursor(undefined);
|
||||
|
||||
this.updateAlertGroups();
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateAlertGroups() {
|
||||
this.alertGroupsLoading = true;
|
||||
|
||||
|
|
@ -313,7 +298,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getAlertSearchResult(query: string) {
|
||||
const result = this.alertsSearchResult[query];
|
||||
if (!result) {
|
||||
|
|
@ -328,7 +312,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
};
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getAlert(pk: Alert['pk']) {
|
||||
return await makeRequest(`${this.path}${pk}`, {}).then((alert: Alert) => {
|
||||
runInAction(() => {
|
||||
|
|
@ -343,7 +326,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
return await makeRequest(`/alerts/${pk}`, {});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async getNewIncidentsStats() {
|
||||
const result = await makeRequest(`${this.path}stats/`, {
|
||||
params: {
|
||||
|
|
@ -357,7 +340,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async getAcknowledgedIncidentsStats() {
|
||||
const result = await makeRequest(`${this.path}stats/`, {
|
||||
params: {
|
||||
|
|
@ -371,7 +354,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async getResolvedIncidentsStats() {
|
||||
const result = await makeRequest(`${this.path}stats/`, {
|
||||
params: {
|
||||
|
|
@ -385,7 +368,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async getSilencedIncidentsStats() {
|
||||
const result = await makeRequest(`${this.path}stats/`, {
|
||||
params: {
|
||||
|
|
@ -399,7 +382,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async doIncidentAction(alertId: Alert['pk'], action: AlertAction, isUndo = false, data?: any) {
|
||||
this.updateAlert(alertId, { loading: true });
|
||||
|
||||
|
|
@ -446,7 +429,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
}
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateAlert(pk: Alert['pk'], value: Partial<Alert>) {
|
||||
this.alerts.set(pk, {
|
||||
...(this.alerts.get(pk) as Alert),
|
||||
|
|
@ -454,7 +437,6 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async unpageUser(alertId: Alert['pk'], userId: User['pk']) {
|
||||
return await makeRequest(`${this.path}${alertId}/unpage_user`, {
|
||||
method: 'POST',
|
||||
|
|
@ -462,7 +444,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
}).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async fetchTableSettings(): Promise<void> {
|
||||
const tableSettings = await makeRequest('/alertgroup_table_settings', {});
|
||||
|
||||
|
|
@ -477,7 +459,7 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
@AutoLoadingState(ActionKey.ADD_NEW_COLUMN_TO_ALERT_GROUP)
|
||||
async updateTableSettings(
|
||||
columns: { visible: AlertGroupColumn[]; hidden: AlertGroupColumn[] },
|
||||
|
|
@ -495,21 +477,18 @@ export class AlertGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async resetTableSettings(): Promise<void> {
|
||||
return await makeRequest('/alertgroup_table_settings/reset', { method: 'POST' }).catch(() =>
|
||||
openErrorNotification('There was an error resetting the table settings')
|
||||
);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async loadLabelsKeys(): Promise<Array<ApiSchemas['LabelKey']>> {
|
||||
return await makeRequest(`/alertgroups/labels/keys/`, {}).catch(() =>
|
||||
openErrorNotification('There was an error processing your request')
|
||||
);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async loadValuesForLabelKey(
|
||||
key: ApiSchemas['LabelKey']['id'],
|
||||
search = ''
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class ApiTokenStore extends BaseStore {
|
|||
this.path = '/tokens/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query = '') {
|
||||
const results = await makeRequest(`${this.path}`, {
|
||||
params: { search: query },
|
||||
|
|
@ -46,7 +46,6 @@ export class ApiTokenStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
@ -55,7 +54,6 @@ export class ApiTokenStore extends BaseStore {
|
|||
return this.searchResult[query].map((apiTokenId: ApiToken['id']) => this.items[apiTokenId]);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async revokeApiToken(id: ApiToken['id']) {
|
||||
return await makeRequest(`${this.path}${id}/`, {
|
||||
method: 'DELETE',
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export default class BaseStore {
|
|||
throw error;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async getAll(query = '') {
|
||||
return await makeRequest(`${this.path}`, {
|
||||
params: { search: query },
|
||||
|
|
@ -50,7 +50,7 @@ export default class BaseStore {
|
|||
}).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async getById(id: string, skipErrorHandling = false, fromOrganization = false) {
|
||||
return await makeRequest(`${this.path}${id}`, {
|
||||
method: 'GET',
|
||||
|
|
@ -58,7 +58,7 @@ export default class BaseStore {
|
|||
}).catch((error) => this.onApiError(error, skipErrorHandling));
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async create<RT = any>(data: any, skipErrorHandling = false): Promise<RT | void> {
|
||||
return await makeRequest<RT>(this.path, {
|
||||
method: 'POST',
|
||||
|
|
@ -68,7 +68,7 @@ export default class BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async update<RT = any>(id: any, data: any, params: any = null, skipErrorHandling = false): Promise<RT | void> {
|
||||
const result = await makeRequest<RT>(`${this.path}${id}/`, {
|
||||
method: 'PUT',
|
||||
|
|
@ -83,7 +83,7 @@ export default class BaseStore {
|
|||
return result;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async delete(id: any) {
|
||||
const result = await makeRequest(`${this.path}${id}/`, {
|
||||
method: 'DELETE',
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export class CloudStore extends BaseStore {
|
|||
this.path = '/cloud_users/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(page = 1) {
|
||||
const { matched_users_count, results } = await makeRequest(this.path, {
|
||||
params: { page },
|
||||
|
|
@ -49,7 +49,6 @@ export class CloudStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult() {
|
||||
return {
|
||||
matched_users_count: this.searchResult.matched_users_count,
|
||||
|
|
@ -57,22 +56,18 @@ export class CloudStore extends BaseStore {
|
|||
};
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async syncCloudUsers() {
|
||||
return await makeRequest(`${this.path}`, { method: 'POST' });
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async syncCloudUser(id: string) {
|
||||
return await makeRequest(`${this.path}${id}/sync/`, { method: 'POST' });
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getCloudHeartbeat() {
|
||||
return await makeRequest(`/cloud_heartbeat/`, { method: 'POST' });
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getCloudUser(id: string) {
|
||||
return await makeRequest(`${this.path}${id}`, { method: 'GET' });
|
||||
}
|
||||
|
|
@ -86,12 +81,10 @@ export class CloudStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getCloudConnectionStatus() {
|
||||
return await makeRequest(`/cloud_connection/`, { method: 'GET' });
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async disconnectToCloud() {
|
||||
return await makeRequest(`/cloud_connection/`, { method: 'DELETE' });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export class DirectPagingStore extends BaseStore {
|
|||
this.path = '/direct_paging/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
addUserToSelectedUsers = (user: UserCurrentlyOnCall) => {
|
||||
this.selectedUserResponders = [
|
||||
...this.selectedUserResponders,
|
||||
|
|
@ -40,22 +40,22 @@ export class DirectPagingStore extends BaseStore {
|
|||
];
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
resetSelectedUsers = () => {
|
||||
this.selectedUserResponders = [];
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
updateSelectedTeam = (team: GrafanaTeam) => {
|
||||
this.selectedTeamResponder = team;
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
resetSelectedTeam = () => {
|
||||
this.selectedTeamResponder = null;
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
removeSelectedUser(index: number) {
|
||||
this.selectedUserResponders = [
|
||||
...this.selectedUserResponders.slice(0, index),
|
||||
|
|
@ -63,7 +63,7 @@ export class DirectPagingStore extends BaseStore {
|
|||
];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
updateSelectedUserImportantStatus(index: number, important: boolean) {
|
||||
this.selectedUserResponders = [
|
||||
...this.selectedUserResponders.slice(0, index),
|
||||
|
|
@ -75,7 +75,6 @@ export class DirectPagingStore extends BaseStore {
|
|||
];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async createManualAlertRule(data: ManualAlertGroupPayload): Promise<DirectPagingResponse | void> {
|
||||
return await makeRequest<DirectPagingResponse>(this.path, {
|
||||
method: 'POST',
|
||||
|
|
@ -83,7 +82,6 @@ export class DirectPagingStore extends BaseStore {
|
|||
}).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async updateAlertGroup(alertId: Alert['pk'], data: ManualAlertGroupPayload): Promise<DirectPagingResponse | void> {
|
||||
return await makeRequest<DirectPagingResponse>(this.path, {
|
||||
method: 'POST',
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export class EscalationChainStore extends BaseStore {
|
|||
this.path = '/escalation_chains/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async loadItem(id: EscalationChain['id'], skipErrorHandling = false): Promise<EscalationChain> {
|
||||
const escalationChain = await this.getById(id, skipErrorHandling);
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ export class EscalationChainStore extends BaseStore {
|
|||
return escalationChain;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateById(id: EscalationChain['id']) {
|
||||
const response = await this.getById(id);
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ export class EscalationChainStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async save(id: EscalationChain['id'], data: Partial<EscalationChain>) {
|
||||
const response = await super.update(id, data);
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ export class EscalationChainStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateEscalationChainDetails(id: EscalationChain['id']) {
|
||||
const response = await makeRequest(`${this.path}${id}/details/`, {});
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ export class EscalationChainStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItem(id: EscalationChain['id'], skipErrorHandling = false): Promise<EscalationChain> {
|
||||
let escalationChain;
|
||||
try {
|
||||
|
|
@ -107,7 +107,7 @@ export class EscalationChainStore extends BaseStore {
|
|||
return escalationChain;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query: any = '') {
|
||||
const params = typeof query === 'string' ? { search: query } : query;
|
||||
|
||||
|
|
@ -140,7 +140,6 @@ export class EscalationChainStore extends BaseStore {
|
|||
this.loading = false;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
@ -149,7 +148,6 @@ export class EscalationChainStore extends BaseStore {
|
|||
return this.searchResult[query].map((escalationChainId: EscalationChain['id']) => this.items[escalationChainId]);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
clone = (escalationChainId: EscalationChain['id'], data: Partial<EscalationChain>): Promise<EscalationChain> =>
|
||||
makeRequest<EscalationChain>(`${this.path}${escalationChainId}/copy/`, {
|
||||
method: 'POST',
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export class EscalationPolicyStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateEscalationPolicies(escalationChainId: EscalationChain['id']) {
|
||||
const response = await makeRequest(this.path, {
|
||||
params: { escalation_chain: escalationChainId },
|
||||
|
|
@ -91,7 +91,7 @@ export class EscalationPolicyStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
createEscalationPolicy(escalationChainId: EscalationChain['id'], data: Partial<EscalationPolicy>) {
|
||||
return super.create({
|
||||
...data,
|
||||
|
|
@ -99,7 +99,7 @@ export class EscalationPolicyStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async saveEscalationPolicy(id: EscalationPolicy['id'], data: Partial<EscalationPolicy>) {
|
||||
this.items[id] = {
|
||||
...this.items[id],
|
||||
|
|
@ -113,7 +113,7 @@ export class EscalationPolicyStore extends BaseStore {
|
|||
}
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async moveEscalationPolicyToPosition(oldIndex: any, newIndex: any, escalationChainId: EscalationChain['id']) {
|
||||
const escalationPolicyId = this.escalationChainToEscalationPolicy[escalationChainId][oldIndex];
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ export class EscalationPolicyStore extends BaseStore {
|
|||
this.updateEscalationPolicies(escalationChainId);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async deleteEscalationPolicy(data: Partial<EscalationPolicy>) {
|
||||
const index = this.escalationChainToEscalationPolicy[data.escalation_chain].findIndex(
|
||||
(escalationPolicyId: EscalationPolicy['id']) => escalationPolicyId === data.id
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ export class FiltersStore extends BaseStore {
|
|||
}
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
setNeedToParseFilters(value: boolean) {
|
||||
this.needToParseFilters = value;
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ export class FiltersStore extends BaseStore {
|
|||
return this._globalValues;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
public async updateOptionsForPage(page: string) {
|
||||
const result = await makeRequest(`/${getApiPathByPage(page)}/filters/`, {});
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ export class FiltersStore extends BaseStore {
|
|||
return result;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
updateValuesForPage(page: string, value: FiltersValues) {
|
||||
this.values = {
|
||||
...this.values,
|
||||
|
|
@ -81,12 +81,12 @@ export class FiltersStore extends BaseStore {
|
|||
};
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
setCurrentTablePageNum(page: PAGE, currentTablePageNum: number) {
|
||||
this.currentTablePageNum[page] = currentTablePageNum;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
applyLabelFilter = (label: LabelKeyValue, page: PAGE) => {
|
||||
const currentLabelFilterValues = this.values[page]?.label || [];
|
||||
const labelToAddString = `${label.key.id}:${label.value.id}`;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export class GlobalSettingStore extends BaseStore {
|
|||
this.path = '/live_settings/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateById(id: GlobalSetting['id']) {
|
||||
const response = await this.getById(id);
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ export class GlobalSettingStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query = '') {
|
||||
const results = await this.getAll();
|
||||
|
||||
|
|
@ -55,7 +55,6 @@ export class GlobalSettingStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
@ -64,7 +63,6 @@ export class GlobalSettingStore extends BaseStore {
|
|||
return this.searchResult[query].map((globalSettingId: GlobalSetting['id']) => this.items[globalSettingId]);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getGlobalSettingItemByName(name: string) {
|
||||
const results = await this.getAll();
|
||||
return results.find((element: { name: string }) => element.name === name);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export class GrafanaTeamStore extends BaseStore {
|
|||
this.path = '/teams/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateTeam(id: GrafanaTeam['id'], data: Partial<GrafanaTeam>) {
|
||||
const result = await this.update(id, data);
|
||||
|
||||
|
|
@ -61,7 +61,6 @@ export class GrafanaTeamStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult() {
|
||||
return this.searchResult.map((teamId: GrafanaTeam['id']) => this.items[teamId]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export class HeartbeatStore extends BaseStore {
|
|||
this.path = '/heartbeats/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateTimeoutOptions() {
|
||||
const result = await makeRequest(`${this.path}timeout_options/`, {});
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ export class HeartbeatStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async saveHeartbeat(id: Heartbeat['id'], data: Partial<Heartbeat>) {
|
||||
const response = await super.update<Heartbeat>(id, data);
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ export class HeartbeatStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async createHeartbeat(alertReceiveChannelId: AlertReceiveChannel['id'], data: Partial<Heartbeat>) {
|
||||
const response = await super.create<Heartbeat>({
|
||||
alert_receive_channel: alertReceiveChannelId,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ export class LabelStore extends BaseStore {
|
|||
}
|
||||
|
||||
@WithGlobalNotification({ success: 'New key has been added', failure: 'Failed to add new key' })
|
||||
@action.bound
|
||||
async createKey(name: string) {
|
||||
const data = await makeRequest(`${this.path}`, {
|
||||
method: 'POST',
|
||||
|
|
@ -66,7 +65,6 @@ export class LabelStore extends BaseStore {
|
|||
}
|
||||
|
||||
@WithGlobalNotification({ success: 'New value has been added', failure: 'Failed to add new value' })
|
||||
@action.bound
|
||||
async createValue(keyId: ApiSchemas['LabelKey']['id'], value: string) {
|
||||
const result = await makeRequest(`${this.path}id/${keyId}/values`, {
|
||||
method: 'POST',
|
||||
|
|
@ -76,7 +74,6 @@ export class LabelStore extends BaseStore {
|
|||
}
|
||||
|
||||
@WithGlobalNotification({ success: 'Key has been renamed', failure: 'Failed to rename key' })
|
||||
@action.bound
|
||||
async updateKey(keyId: ApiSchemas['LabelKey']['id'], name: string) {
|
||||
const result = await makeRequest(`${this.path}id/${keyId}`, {
|
||||
method: 'PUT',
|
||||
|
|
@ -86,7 +83,6 @@ export class LabelStore extends BaseStore {
|
|||
}
|
||||
|
||||
@WithGlobalNotification({ success: 'Value has been renamed', failure: 'Failed to rename value' })
|
||||
@action.bound
|
||||
async updateKeyValue(keyId: ApiSchemas['LabelKey']['id'], valueId: ApiSchemas['LabelValue']['id'], name: string) {
|
||||
const result = await makeRequest(`${this.path}id/${keyId}/values/${valueId}`, {
|
||||
method: 'PUT',
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class LoaderStoreClass {
|
|||
makeObservable(this);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
setLoadingAction(actionKey: string, isLoading: boolean) {
|
||||
this.items[actionKey] = isLoading;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export class MSTeamsChannelStore extends BaseStore {
|
|||
this.path = '/msteams/channels/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateMSTeamsChannels() {
|
||||
const response = await makeRequest(this.path, {});
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ export class MSTeamsChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateById(id: MSTeamsChannel['id']) {
|
||||
const response = await this.getById(id);
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ export class MSTeamsChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query = '') {
|
||||
const result = await this.getAll();
|
||||
|
||||
|
|
@ -83,7 +83,6 @@ export class MSTeamsChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
@ -96,38 +95,31 @@ export class MSTeamsChannelStore extends BaseStore {
|
|||
return Boolean(this.getSearchResult('')?.length);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async startAutoUpdate() {
|
||||
this.autoUpdateTimer = setInterval(this.updateMSTeamsChannels.bind(this), 3000);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async stopAutoUpdate() {
|
||||
if (this.autoUpdateTimer) {
|
||||
clearInterval(this.autoUpdateTimer);
|
||||
}
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getMSTeamsChannelVerificationCode() {
|
||||
return await makeRequest(`/current_team/get_channel_verification_code/?backend=MSTEAMS`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async makeMSTeamsChannelDefault(id: MSTeamsChannel['id']) {
|
||||
return makeRequest(`/msteams/channels/${id}/set_default/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async deleteMSTeamsChannel(id: MSTeamsChannel['id']) {
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getMSTeamsChannels() {
|
||||
return super.getAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ export class OrganizationStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async saveCurrentOrganization(data: Partial<Organization>) {
|
||||
this.currentOrganization = await makeRequest(this.path, {
|
||||
method: 'PUT',
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export class OutgoingWebhookStore extends BaseStore {
|
|||
this.path = '/webhooks/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async loadItem(id: OutgoingWebhook['id'], skipErrorHandling = false): Promise<OutgoingWebhook> {
|
||||
const outgoingWebhook = await this.getById(id, skipErrorHandling);
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ export class OutgoingWebhookStore extends BaseStore {
|
|||
return outgoingWebhook;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateById(id: OutgoingWebhook['id']) {
|
||||
const response = await this.getById(id);
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ export class OutgoingWebhookStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItem(id: OutgoingWebhook['id'], fromOrganization = false) {
|
||||
const response = await this.getById(id, false, fromOrganization);
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ export class OutgoingWebhookStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query: any = '') {
|
||||
const params = typeof query === 'string' ? { search: query } : query;
|
||||
|
||||
|
|
@ -95,7 +95,6 @@ export class OutgoingWebhookStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
@ -104,14 +103,12 @@ export class OutgoingWebhookStore extends BaseStore {
|
|||
return this.searchResult[query].map((outgoingWebhookId: OutgoingWebhook['id']) => this.items[outgoingWebhookId]);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getLastResponses(id: OutgoingWebhook['id']) {
|
||||
const result = await makeRequest(`${this.path}${id}/responses`, {});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async renderPreview(id: OutgoingWebhook['id'], template_name: string, template_body: string, payload) {
|
||||
return await makeRequest(`${this.path}${id}/preview_template/`, {
|
||||
method: 'POST',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import { action, makeObservable } from 'mobx';
|
||||
|
||||
import { Alert } from 'models/alertgroup/alertgroup.types';
|
||||
import BaseStore from 'models/base_store';
|
||||
import { makeRequest } from 'network';
|
||||
|
|
@ -8,12 +6,10 @@ import { RootStore } from 'state';
|
|||
export class ResolutionNotesStore extends BaseStore {
|
||||
constructor(rootStore: RootStore) {
|
||||
super(rootStore);
|
||||
makeObservable(this);
|
||||
|
||||
this.path = '/resolution_notes/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async createResolutionNote(alertGroupId: Alert['pk'], text: string) {
|
||||
return await makeRequest(`${this.path}`, {
|
||||
method: 'POST',
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ export class ScheduleStore extends BaseStore {
|
|||
this.path = '/schedules/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async loadItem(id: Schedule['id'], skipErrorHandling = false): Promise<Schedule> {
|
||||
const schedule = await this.getById(id, skipErrorHandling);
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ export class ScheduleStore extends BaseStore {
|
|||
return schedule;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(
|
||||
f: RemoteFiltersType | string = { searchTerm: '', type: undefined, used: undefined },
|
||||
page = 1,
|
||||
|
|
@ -182,7 +182,7 @@ export class ScheduleStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItem(id: Schedule['id'], fromOrganization = false) {
|
||||
if (id) {
|
||||
let schedule;
|
||||
|
|
@ -211,7 +211,6 @@ export class ScheduleStore extends BaseStore {
|
|||
}
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult() {
|
||||
return {
|
||||
page_size: this.searchResult.page_size,
|
||||
|
|
@ -231,28 +230,24 @@ export class ScheduleStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async reloadIcal(scheduleId: Schedule['id']) {
|
||||
await makeRequest(`/schedules/${scheduleId}/reload_ical/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getICalLink(scheduleId: Schedule['id']) {
|
||||
return await makeRequest(`/schedules/${scheduleId}/export_token/`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async createICalLink(scheduleId: Schedule['id']) {
|
||||
return await makeRequest(`/schedules/${scheduleId}/export_token/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async deleteICalLink(scheduleId: Schedule['id']) {
|
||||
await makeRequest(`/schedules/${scheduleId}/export_token/`, {
|
||||
method: 'DELETE',
|
||||
|
|
@ -261,7 +256,7 @@ export class ScheduleStore extends BaseStore {
|
|||
|
||||
// ------- NEW SCHEDULES API ENDPOINTS ---------
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async createRotation(scheduleId: Schedule['id'], isOverride: boolean, params: Partial<Shift>) {
|
||||
const type = isOverride ? 3 : 2;
|
||||
|
||||
|
|
@ -282,12 +277,10 @@ export class ScheduleStore extends BaseStore {
|
|||
return response;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
setRotationFormLiveParams(params: RotationFormLiveParams) {
|
||||
this.rotationFormLiveParams = params;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async updateRotationPreview(
|
||||
scheduleId: Schedule['id'],
|
||||
shiftId: Shift['id'] | 'new',
|
||||
|
|
@ -331,7 +324,7 @@ export class ScheduleStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateShiftsSwapPreview(scheduleId: Schedule['id'], startMoment: dayjs.Dayjs, params: Partial<ShiftSwap>) {
|
||||
const fromString = getFromString(startMoment);
|
||||
|
||||
|
|
@ -357,7 +350,7 @@ export class ScheduleStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
clearPreview() {
|
||||
this.finalPreview = undefined;
|
||||
this.rotationPreview = undefined;
|
||||
|
|
@ -366,7 +359,7 @@ export class ScheduleStore extends BaseStore {
|
|||
this.rotationFormLiveParams = undefined;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateRotation(shiftId: Shift['id'], params: Partial<Shift>) {
|
||||
const response = await makeRequest(`/oncall_shifts/${shiftId}`, {
|
||||
params: { force: true },
|
||||
|
|
@ -384,7 +377,7 @@ export class ScheduleStore extends BaseStore {
|
|||
return response;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateRotationAsNew(shiftId: Shift['id'], params: Partial<Shift>) {
|
||||
const response = await makeRequest(`/oncall_shifts/${shiftId}`, {
|
||||
data: { ...params },
|
||||
|
|
@ -401,7 +394,7 @@ export class ScheduleStore extends BaseStore {
|
|||
return response;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
updateRelatedEscalationChains = async (id: Schedule['id']) => {
|
||||
const response = await makeRequest(`/schedules/${id}/related_escalation_chains`, {
|
||||
method: 'GET',
|
||||
|
|
@ -417,7 +410,7 @@ export class ScheduleStore extends BaseStore {
|
|||
return response;
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
updateRelatedUsers = async (id: Schedule['id']) => {
|
||||
const { users } = await makeRequest(`/schedules/${id}/next_shifts_per_user`, {
|
||||
method: 'GET',
|
||||
|
|
@ -433,7 +426,7 @@ export class ScheduleStore extends BaseStore {
|
|||
return users;
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateOncallShifts(scheduleId: Schedule['id']) {
|
||||
const { results } = await makeRequest(`/oncall_shifts/`, {
|
||||
params: {
|
||||
|
|
@ -456,7 +449,7 @@ export class ScheduleStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateOncallShift(shiftId: Shift['id']) {
|
||||
if (this.shiftsCurrentlyUpdating[shiftId]) {
|
||||
return;
|
||||
|
|
@ -478,7 +471,7 @@ export class ScheduleStore extends BaseStore {
|
|||
return response;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async saveOncallShift(shiftId: Shift['id'], data: Partial<Shift>) {
|
||||
const response = await makeRequest(`/oncall_shifts/${shiftId}`, { method: 'PUT', data });
|
||||
|
||||
|
|
@ -492,7 +485,6 @@ export class ScheduleStore extends BaseStore {
|
|||
return response;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async deleteOncallShift(shiftId: Shift['id'], force?: boolean) {
|
||||
return await makeRequest(`/oncall_shifts/${shiftId}`, {
|
||||
method: 'DELETE',
|
||||
|
|
@ -500,7 +492,7 @@ export class ScheduleStore extends BaseStore {
|
|||
}).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateEvents(scheduleId: Schedule['id'], startMoment: dayjs.Dayjs, type: RotationType = 'rotation', days = 9) {
|
||||
const dayBefore = startMoment.subtract(1, 'day');
|
||||
|
||||
|
|
@ -556,14 +548,13 @@ export class ScheduleStore extends BaseStore {
|
|||
]);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async updateFrequencyOptions() {
|
||||
return await makeRequest(`/oncall_shifts/frequency_options/`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateDaysOptions() {
|
||||
const result = await makeRequest(`/oncall_shifts/days_options/`, {
|
||||
method: 'GET',
|
||||
|
|
@ -574,22 +565,19 @@ export class ScheduleStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async createShiftSwap(params: Partial<ShiftSwap>) {
|
||||
return await makeRequest(`/shift_swaps/`, { method: 'POST', data: params }).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async deleteShiftSwap(shiftSwapId: ShiftSwap['id']) {
|
||||
return await makeRequest(`/shift_swaps/${shiftSwapId}`, { method: 'DELETE' }).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async takeShiftSwap(shiftSwapId: ShiftSwap['id']) {
|
||||
return await makeRequest(`/shift_swaps/${shiftSwapId}/take`, { method: 'POST' }).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async loadShiftSwap(id: ShiftSwap['id']) {
|
||||
const result = await makeRequest(`/shift_swaps/${id}`, { params: { expand_users: true } });
|
||||
|
||||
|
|
@ -600,7 +588,7 @@ export class ScheduleStore extends BaseStore {
|
|||
return result;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateShiftSwaps(scheduleId: Schedule['id'], startMoment: dayjs.Dayjs, days = 9) {
|
||||
const fromString = getFromString(startMoment);
|
||||
|
||||
|
|
@ -642,7 +630,7 @@ export class ScheduleStore extends BaseStore {
|
|||
}
|
||||
|
||||
@AutoLoadingState(ActionKey.UPDATE_PERSONAL_EVENTS)
|
||||
@action.bound
|
||||
@action
|
||||
async updatePersonalEvents(userPk: User['pk'], startMoment: dayjs.Dayjs, days = 9, isUpdateOnCallNow = false) {
|
||||
const fromString = getFromString(startMoment);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class SlackStore extends BaseStore {
|
|||
makeObservable(this);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateSlackSettings() {
|
||||
const result = await makeRequest('/slack_settings/', {});
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ export class SlackStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async saveSlackSettings(data: Partial<SlackSettings>) {
|
||||
const result = await makeRequest('/slack_settings/', {
|
||||
data,
|
||||
|
|
@ -40,7 +40,7 @@ export class SlackStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async setGeneralLogChannelId(id: SlackChannel['id']) {
|
||||
return await makeRequest('/set_general_channel/', {
|
||||
method: 'POST',
|
||||
|
|
@ -48,7 +48,7 @@ export class SlackStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateSlackIntegrationData(slack_id: string) {
|
||||
const result = await makeRequest('/slack_integration/', {
|
||||
params: { slack_id },
|
||||
|
|
@ -61,7 +61,6 @@ export class SlackStore extends BaseStore {
|
|||
return result;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async reinstallSlackIntegration(slack_id: string) {
|
||||
return await makeRequest('/slack_integration/', {
|
||||
validateStatus: function (status) {
|
||||
|
|
@ -72,19 +71,16 @@ export class SlackStore extends BaseStore {
|
|||
}).catch(this.onApiError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async slackLogin() {
|
||||
const url_for_redirect = await makeRequest('/login/slack-login/', {});
|
||||
window.location = url_for_redirect;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async installSlackIntegration() {
|
||||
const url_for_redirect = await makeRequest('/login/slack-install-free/', {});
|
||||
window.location = url_for_redirect;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async removeSlackIntegration() {
|
||||
return await makeRequest('/slack/reset_slack/', { method: 'POST' });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class SlackChannelStore extends BaseStore {
|
|||
this.path = '/slack_channels/';
|
||||
}
|
||||
|
||||
@action.bound // deprecated, use updateItem instead
|
||||
@action // deprecated, use updateItem instead
|
||||
async updateById(id: SlackChannel['id']) {
|
||||
const response = await this.getById(id);
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ export class SlackChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItem(id: SlackChannel['id']) {
|
||||
const response = await this.getById(id);
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ export class SlackChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query = '') {
|
||||
const { results } = await makeRequest(`${this.path}`, {
|
||||
params: { search: query },
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export class TelegramChannelStore extends BaseStore {
|
|||
this.path = '/telegram_channels/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateTelegramChannels() {
|
||||
const response = await makeRequest(this.path, {});
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ export class TelegramChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateById(id: TelegramChannel['id']) {
|
||||
const response = await this.getById(id);
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ export class TelegramChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query = '') {
|
||||
const result = await this.getAll();
|
||||
|
||||
|
|
@ -83,7 +83,6 @@ export class TelegramChannelStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
@ -96,38 +95,34 @@ export class TelegramChannelStore extends BaseStore {
|
|||
return Boolean(this.getSearchResult('')?.length);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async startAutoUpdate() {
|
||||
this.autoUpdateTimer = setInterval(this.updateTelegramChannels.bind(this), 3000);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async stopAutoUpdate() {
|
||||
if (this.autoUpdateTimer) {
|
||||
clearInterval(this.autoUpdateTimer);
|
||||
}
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getTelegramVerificationCode() {
|
||||
return await makeRequest(`/current_team/get_telegram_verification_code/`, {
|
||||
withCredentials: true,
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async makeTelegramChannelDefault(id: TelegramChannel['id']) {
|
||||
return makeRequest(`/telegram_channels/${id}/set_default/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async deleteTelegramChannel(id: TelegramChannel['id']) {
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getTelegramChannels() {
|
||||
return super.getAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ describe('UserStore.unlinkBackend', () => {
|
|||
test('it makes the proper API call and returns the response', async () => {
|
||||
makeRequest.mockResolvedValueOnce('hello');
|
||||
|
||||
Object.defineProperty(userStore, 'loadCurrentUser', { value: jest.fn() });
|
||||
userStore.loadCurrentUser = jest.fn();
|
||||
|
||||
await userStore.unlinkBackend(userPk, backend);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export class UserStore extends BaseStore {
|
|||
return this.items[this.currentUserPk as User['pk']];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async loadCurrentUser() {
|
||||
const response = await makeRequest('/user/', {});
|
||||
const timezone = await this.refreshTimezone(response.pk);
|
||||
|
|
@ -74,7 +74,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async refreshTimezone(id: User['pk']) {
|
||||
const { timezone: grafanaPreferencesTimezone } = config.bootData.user;
|
||||
const timezone = grafanaPreferencesTimezone === 'browser' ? dayjs.tz.guess() : grafanaPreferencesTimezone;
|
||||
|
|
@ -87,7 +87,7 @@ export class UserStore extends BaseStore {
|
|||
return timezone;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async loadUser(userPk: User['pk'], skipErrorHandling = false): Promise<User> {
|
||||
const user = await this.getById(userPk, skipErrorHandling);
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ export class UserStore extends BaseStore {
|
|||
return user;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItem(userPk: User['pk']) {
|
||||
if (this.itemsCurrentlyUpdating[userPk]) {
|
||||
return;
|
||||
|
|
@ -124,7 +124,6 @@ export class UserStore extends BaseStore {
|
|||
/**
|
||||
* NOTE: if is_currently_oncall=all the backend will not paginate the results, it will send back an array of ALL users
|
||||
*/
|
||||
@action.bound
|
||||
async search<RT = PaginatedUsersResponse<User>>(f: any = { searchTerm: '' }, page = 1): Promise<RT> {
|
||||
const filters = typeof f === 'string' ? { searchTerm: f } : f; // for GSelect compatibility
|
||||
const { searchTerm: search, ...restFilters } = filters;
|
||||
|
|
@ -133,7 +132,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(f: any = { searchTerm: '' }, page = 1, invalidateFn?: () => boolean): Promise<any> {
|
||||
const response = await this.search(f, page);
|
||||
|
||||
|
|
@ -168,7 +167,6 @@ export class UserStore extends BaseStore {
|
|||
return response;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult() {
|
||||
return {
|
||||
page_size: this.searchResult.page_size,
|
||||
|
|
@ -177,12 +175,11 @@ export class UserStore extends BaseStore {
|
|||
};
|
||||
}
|
||||
|
||||
@action.bound
|
||||
sendTelegramConfirmationCode = async (userPk: User['pk']) => {
|
||||
return await makeRequest(`/users/${userPk}/get_telegram_verification_code/`, {});
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
unlinkSlack = async (userPk: User['pk']) => {
|
||||
await makeRequest(`/users/${userPk}/unlink_slack/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -198,7 +195,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
unlinkTelegram = async (userPk: User['pk']) => {
|
||||
await makeRequest(`/users/${userPk}/unlink_telegram/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -214,13 +211,12 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
};
|
||||
|
||||
@action.bound
|
||||
sendBackendConfirmationCode = (userPk: User['pk'], backend: string) =>
|
||||
makeRequest<string>(`/users/${userPk}/get_backend_verification_code?backend=${backend}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
unlinkBackend = async (userPk: User['pk'], backend: string) => {
|
||||
await makeRequest(`/users/${userPk}/unlink_backend/?backend=${backend}`, {
|
||||
method: 'POST',
|
||||
|
|
@ -229,7 +225,7 @@ export class UserStore extends BaseStore {
|
|||
this.loadCurrentUser();
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async createUser(data: any) {
|
||||
const user = await this.create(data);
|
||||
|
||||
|
|
@ -243,7 +239,7 @@ export class UserStore extends BaseStore {
|
|||
return user;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateUser(data: Partial<User>) {
|
||||
const user = await makeRequest(`/users/${data.pk}/`, {
|
||||
method: 'PUT',
|
||||
|
|
@ -265,7 +261,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateCurrentUser(data: Partial<User>) {
|
||||
const user = await makeRequest(`/user/`, {
|
||||
method: 'PUT',
|
||||
|
|
@ -283,7 +279,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async fetchVerificationCode(userPk: User['pk'], recaptchaToken: string) {
|
||||
await makeRequest(`/users/${userPk}/get_verification_code/`, {
|
||||
method: 'GET',
|
||||
|
|
@ -291,7 +287,7 @@ export class UserStore extends BaseStore {
|
|||
}).catch(throttlingError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async fetchVerificationCall(userPk: User['pk'], recaptchaToken: string) {
|
||||
await makeRequest(`/users/${userPk}/get_verification_call/`, {
|
||||
method: 'GET',
|
||||
|
|
@ -299,21 +295,21 @@ export class UserStore extends BaseStore {
|
|||
}).catch(throttlingError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async verifyPhone(userPk: User['pk'], token: string) {
|
||||
return await makeRequest(`/users/${userPk}/verify_number/?token=${token}`, {
|
||||
method: 'PUT',
|
||||
}).catch(throttlingError);
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async forgetPhone(userPk: User['pk']) {
|
||||
return await makeRequest(`/users/${userPk}/forget_number/`, {
|
||||
method: 'PUT',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateNotificationPolicies(id: User['pk']) {
|
||||
const importantEPs = await makeRequest('/notification_policies/', {
|
||||
params: { user: id, important: true },
|
||||
|
|
@ -331,7 +327,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async moveNotificationPolicyToPosition(userPk: User['pk'], oldIndex: number, newIndex: number, offset: number) {
|
||||
const notificationPolicy = this.notificationPolicies[userPk][oldIndex + offset];
|
||||
|
||||
|
|
@ -346,7 +342,7 @@ export class UserStore extends BaseStore {
|
|||
this.updateItem(userPk); // to update notification_chain_verbal
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async addNotificationPolicy(userPk: User['pk'], important: NotificationPolicyType['important']) {
|
||||
await makeRequest(`/notification_policies/`, {
|
||||
method: 'POST',
|
||||
|
|
@ -358,7 +354,7 @@ export class UserStore extends BaseStore {
|
|||
this.updateItem(userPk); // to update notification_chain_verbal
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateNotificationPolicy(userPk: User['pk'], id: NotificationPolicyType['id'], value: NotificationPolicyType) {
|
||||
this.notificationPolicies = {
|
||||
...this.notificationPolicies,
|
||||
|
|
@ -384,7 +380,7 @@ export class UserStore extends BaseStore {
|
|||
this.updateItem(userPk); // to update notification_chain_verbal
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async deleteNotificationPolicy(userPk: User['pk'], id: NotificationPolicyType['id']) {
|
||||
await makeRequest(`/notification_policies/${id}`, { method: 'DELETE' }).catch(this.onApiError);
|
||||
|
||||
|
|
@ -404,7 +400,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async sendTestPushNotification(userId: User['pk'], isCritical: boolean) {
|
||||
return await makeRequest(`/users/${userId}/send_test_push`, {
|
||||
method: 'POST',
|
||||
|
|
@ -423,7 +419,7 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async makeTestCall(userPk: User['pk']) {
|
||||
this.isTestCallInProgress = true;
|
||||
|
||||
|
|
@ -438,7 +434,6 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async sendTestSms(userPk: User['pk']) {
|
||||
this.isTestCallInProgress = true;
|
||||
|
||||
|
|
@ -451,21 +446,18 @@ export class UserStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async getiCalLink(userPk: User['pk']) {
|
||||
return await makeRequest(`/users/${userPk}/export_token/`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async createiCalLink(userPk: User['pk']) {
|
||||
return await makeRequest(`/users/${userPk}/export_token/`, {
|
||||
method: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
async deleteiCalLink(userPk: User['pk']) {
|
||||
await makeRequest(`/users/${userPk}/export_token/`, {
|
||||
method: 'DELETE',
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class UserGroupStore extends BaseStore {
|
|||
this.path = '/user_groups/';
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async updateItems(query = '') {
|
||||
const result = await makeRequest(`${this.path}`, {
|
||||
params: { search: query },
|
||||
|
|
@ -46,7 +46,6 @@ export class UserGroupStore extends BaseStore {
|
|||
});
|
||||
}
|
||||
|
||||
@action.bound
|
||||
getSearchResult(query = '') {
|
||||
if (!this.searchResult[query]) {
|
||||
return undefined;
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ const Insights = observer(() => {
|
|||
setDatasource(`${text}`);
|
||||
});
|
||||
return () => {
|
||||
stackListener?.unsubscribe?.();
|
||||
dataSourceListener?.unsubscribe?.();
|
||||
stackListener?.unsubscribe();
|
||||
dataSourceListener?.unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ export class RootBaseStore {
|
|||
this.setIsBasicDataLoaded(true);
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
loadMasterData = async () => {
|
||||
Promise.all([
|
||||
this.userStore.updateNotificationPolicyOptions(),
|
||||
|
|
@ -151,12 +151,12 @@ export class RootBaseStore {
|
|||
]);
|
||||
};
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
setIsBasicDataLoaded(value: boolean) {
|
||||
this.isBasicDataLoaded = value;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
setupPluginError(errorMsg: string) {
|
||||
this.initializationError = errorMsg;
|
||||
}
|
||||
|
|
@ -327,12 +327,12 @@ export class RootBaseStore {
|
|||
this.pageTitle = title;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async removeSlackIntegration() {
|
||||
await this.slackStore.removeSlackIntegration();
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@action
|
||||
async installSlackIntegration() {
|
||||
await this.slackStore.installSlackIntegration();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ describe('rootBaseStore', () => {
|
|||
});
|
||||
isUserActionAllowed.mockReturnValueOnce(true);
|
||||
PluginState.installPlugin = jest.fn().mockResolvedValueOnce(null);
|
||||
Object.defineProperty(rootBaseStore.userStore, 'loadCurrentUser', { value: mockedLoadCurrentUser });
|
||||
rootBaseStore.userStore.loadCurrentUser = mockedLoadCurrentUser;
|
||||
|
||||
// test
|
||||
await rootBaseStore.setupPlugin(generatePluginData(onCallApiUrl));
|
||||
|
|
@ -224,7 +224,7 @@ describe('rootBaseStore', () => {
|
|||
});
|
||||
isUserActionAllowed.mockReturnValueOnce(true);
|
||||
PluginState.installPlugin = jest.fn().mockResolvedValueOnce(null);
|
||||
Object.defineProperty(rootBaseStore.userStore, 'loadCurrentUser', { value: mockedLoadCurrentUser });
|
||||
rootBaseStore.userStore.loadCurrentUser = mockedLoadCurrentUser;
|
||||
|
||||
// test
|
||||
await rootBaseStore.setupPlugin(generatePluginData(onCallApiUrl));
|
||||
|
|
@ -300,7 +300,7 @@ describe('rootBaseStore', () => {
|
|||
version: 'asdfasdf',
|
||||
license: 'asdfasdf',
|
||||
});
|
||||
Object.defineProperty(rootBaseStore.userStore, 'loadCurrentUser', { value: mockedLoadCurrentUser });
|
||||
rootBaseStore.userStore.loadCurrentUser = mockedLoadCurrentUser;
|
||||
|
||||
// test
|
||||
await rootBaseStore.setupPlugin(generatePluginData(onCallApiUrl));
|
||||
|
|
@ -329,7 +329,7 @@ describe('rootBaseStore', () => {
|
|||
license: 'asdfasdf',
|
||||
});
|
||||
PluginState.updatePluginStatus = jest.fn().mockResolvedValueOnce(updatePluginStatusError);
|
||||
Object.defineProperty(rootBaseStore.userStore, 'loadCurrentUser', { value: mockedLoadCurrentUser });
|
||||
rootBaseStore.userStore.loadCurrentUser = mockedLoadCurrentUser;
|
||||
|
||||
// test
|
||||
await rootBaseStore.setupPlugin(generatePluginData(onCallApiUrl));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue