Skip to content

Commit f6ba382

Browse files
authored
fix(admin): Persist region selection on search from home (#96809)
right now searching from the homepage will reset any region selected - now the region will be persisted fixes https://linear.app/getsentry/issue/RTC-1100/de-region-reverts-to-us-on-httpssentryio-admin
1 parent e7b01bb commit f6ba382

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

static/gsAdmin/components/resultGrid.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class ResultGrid extends Component<ResultGridProps, State> {
236236
constructor(props: any) {
237237
super(props);
238238
const queryParams = this.props.location?.query ?? {};
239-
const {cursor, query, sortBy} = queryParams;
239+
const {cursor, query, sortBy, regionUrl} = queryParams;
240240

241241
this.state = {
242242
rows: [],
@@ -245,14 +245,26 @@ class ResultGrid extends Component<ResultGridProps, State> {
245245
pageLinks: null,
246246
cursor: extractQuery(cursor),
247247
query: extractQuery(query),
248-
region: this.props.isRegional ? ConfigStore.get('regions')[0] : undefined,
248+
region: this.props.isRegional
249+
? regionUrl
250+
? ConfigStore.get('regions').find((r: any) => r.url === extractQuery(regionUrl))
251+
: ConfigStore.get('regions')[0]
252+
: undefined,
249253
sortBy: extractQuery(sortBy, this.props.defaultSort),
250254
filters: Object.assign({}, queryParams),
251255
};
252256
}
253257

254258
componentDidMount() {
255259
this.fetchData();
260+
261+
// Remove regionalUrl after setting state
262+
if (this.props.isRegional && this.props.location?.query?.regionUrl) {
263+
browserHistory.replace({
264+
pathname: this.props.location.pathname,
265+
query: {...this.props.location.query, regionUrl: undefined},
266+
});
267+
}
256268
}
257269

258270
componentDidUpdate(prevProps: ResultGridProps) {

static/gsAdmin/views/home.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function HomePage(props: Props) {
3030
pathname: '/_admin/customers/',
3131
query: {
3232
query,
33+
regionUrl,
3334
},
3435
});
3536
};
@@ -116,7 +117,9 @@ function HomePage(props: Props) {
116117
label: r.name,
117118
value: r.url,
118119
}))}
119-
onChange={opt => setRegionUrl(opt.value)}
120+
onChange={opt => {
121+
setRegionUrl(opt.value);
122+
}}
120123
/>
121124

122125
<SearchLabel>Organizations</SearchLabel>

0 commit comments

Comments
 (0)