Skip to content

Commit

Permalink
fixed mutability issue in dashboard dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
peterholmberg committed Nov 13, 2018
1 parent 1194ff2 commit 03cf238
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions public/app/features/org/OrgPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export class OrgPreferences extends PureComponent<Props> {
setOrganizationTheme,
} = this.props;

starredDashboards.unshift({ id: 0, title: 'Default', tags: [], type: '', uid: '', uri: '', url: '' });
const dashboards: DashboardSearchHit[] = [
{ id: 0, title: 'Default', tags: [], type: '', uid: '', uri: '', url: '' },
...starredDashboards,
];

return (
<form className="section gf-form-group" onSubmit={this.onSubmitForm}>
Expand All @@ -66,11 +69,11 @@ export class OrgPreferences extends PureComponent<Props> {
Home Dashboard
</Label>
<SimplePicker
defaultValue={starredDashboards.find(dashboard => dashboard.id === preferences.homeDashboardId)}
defaultValue={dashboards.find(dashboard => dashboard.id === preferences.homeDashboardId)}
getOptionValue={i => i.id}
getOptionLabel={i => i.title}
onSelected={(dashboard: DashboardSearchHit) => setOrganizationHomeDashboard(dashboard.id)}
options={starredDashboards}
options={dashboards}
placeholder="Chose default dashboard"
width={20}
/>
Expand Down
9 changes: 6 additions & 3 deletions public/app/features/teams/TeamPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export class TeamPreferences extends PureComponent<Props> {
render() {
const { preferences, starredDashboards, setTeamHomeDashboard, setTeamTimezone, setTeamTheme } = this.props;

starredDashboards.unshift({ id: 0, title: 'Default', tags: [], type: '', uid: '', uri: '', url: '' });
const dashboards: DashboardSearchHit[] = [
{ id: 0, title: 'Default', tags: [], type: '', uid: '', uri: '', url: '' },
...starredDashboards,
];

return (
<form className="section gf-form-group" onSubmit={this.onSubmitForm}>
Expand All @@ -55,11 +58,11 @@ export class TeamPreferences extends PureComponent<Props> {
Home Dashboard
</Label>
<SimplePicker
defaultValue={starredDashboards.find(dashboard => dashboard.id === preferences.homeDashboardId)}
defaultValue={dashboards.find(dashboard => dashboard.id === preferences.homeDashboardId)}
getOptionValue={i => i.id}
getOptionLabel={i => i.title}
onSelected={(dashboard: DashboardSearchHit) => setTeamHomeDashboard(dashboard.id)}
options={starredDashboards}
options={dashboards}
placeholder="Chose default dashboard"
width={20}
/>
Expand Down

0 comments on commit 03cf238

Please sign in to comment.