diff --git a/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.module.scss b/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.module.scss index 2c2f92f501..fbbd2163d3 100644 --- a/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.module.scss +++ b/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.module.scss @@ -31,6 +31,7 @@ } .table { + max-height: 150px; overflow: auto; padding: 4px 0px; diff --git a/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx b/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx index d36c3532a2..3aa328dd7e 100644 --- a/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx +++ b/src/containers/AddResponders/parts/AddRespondersPopup/AddRespondersPopup.tsx @@ -115,7 +115,7 @@ const AddRespondersPopup = observer( const handleSearchTermChange = useDebouncedCallback(() => { if (isCreateMode && activeOption === TabOptions.Teams) { - grafanaTeamStore.updateItems(searchTerm, false, true); + grafanaTeamStore.updateItems(searchTerm, false, true, false); } else { userStore.updateItems({ searchTerm, short: 'false' }); } diff --git a/src/models/grafana_team/grafana_team.ts b/src/models/grafana_team/grafana_team.ts index bb0b3cee80..023150be43 100644 --- a/src/models/grafana_team/grafana_team.ts +++ b/src/models/grafana_team/grafana_team.ts @@ -5,12 +5,14 @@ import { GrafanaTeam } from 'models/grafana_team/grafana_team.types'; import { makeRequest } from 'network'; import { RootStore } from 'state'; +type TeamItems = { [id: string]: GrafanaTeam }; + export class GrafanaTeamStore extends BaseStore { @observable - searchResult: { [key: string]: Array } = {}; + searchResult: Array = []; @observable.shallow - items: { [id: string]: GrafanaTeam } = {}; + items: TeamItems = {}; constructor(rootStore: RootStore) { super(rootStore); @@ -29,10 +31,11 @@ export class GrafanaTeamStore extends BaseStore { } @action - async updateItems(query = '', includeNoTeam = true, onlyIncludeNotifiableTeams = false) { - const result = await makeRequest(`${this.path}`, { + async updateItems(query = '', includeNoTeam = true, onlyIncludeNotifiableTeams = false, short = true) { + const result = await makeRequest(`${this.path}`, { params: { search: query, + short: short ? 'true' : 'false', include_no_team: includeNoTeam ? 'true' : 'false', only_include_notifiable_teams: onlyIncludeNotifiableTeams ? 'true' : 'false', }, @@ -40,8 +43,8 @@ export class GrafanaTeamStore extends BaseStore { this.items = { ...this.items, - ...result.reduce( - (acc: { [key: number]: GrafanaTeam }, item: GrafanaTeam) => ({ + ...result.reduce( + (acc, item) => ({ ...acc, [item.id]: item, }), @@ -49,17 +52,10 @@ export class GrafanaTeamStore extends BaseStore { ), }; - this.searchResult = { - ...this.searchResult, - [query]: result.map((item: GrafanaTeam) => item.id), - }; + this.searchResult = result.map((item: GrafanaTeam) => item.id); } - getSearchResult(query = '') { - if (!this.searchResult[query]) { - return []; - } - - return this.searchResult[query].map((teamId: GrafanaTeam['id']) => this.items[teamId]); + getSearchResult() { + return this.searchResult.map((teamId: GrafanaTeam['id']) => this.items[teamId]); } } diff --git a/src/models/grafana_team/grafana_team.types.ts b/src/models/grafana_team/grafana_team.types.ts index 8b0af3070d..97210b8b6c 100644 --- a/src/models/grafana_team/grafana_team.types.ts +++ b/src/models/grafana_team/grafana_team.types.ts @@ -4,5 +4,5 @@ export interface GrafanaTeam { email: string; avatar_url: string; is_sharing_resources_to_all: boolean; - number_of_users_currently_oncall: number; + number_of_users_currently_oncall?: number; } diff --git a/src/models/user/user.types.ts b/src/models/user/user.types.ts index a1bad61be3..11d6247b7d 100644 --- a/src/models/user/user.types.ts +++ b/src/models/user/user.types.ts @@ -43,6 +43,6 @@ export interface User { hidden_fields?: boolean; timezone: Timezone; working_hours: { [key: string]: [] }; - is_currently_oncall: boolean; - teams: GrafanaTeam[]; + is_currently_oncall?: boolean; + teams?: GrafanaTeam[]; }