Skip to content

Commit

Permalink
fix: admin rpc endpoint selector bug fix (#6641)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemumma authored Dec 10, 2024
1 parent 3805250 commit 71cdfde
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions snuba/admin/static/rpc_endpoints/endpoint_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EndpointSelectorProps } from 'SnubaAdmin/rpc_endpoints/types';
export const EndpointSelector = ({
endpoints,
selectedEndpoint,
selectedVersion,
handleEndpointSelect
}: EndpointSelectorProps) => (
<>
Expand All @@ -13,10 +14,10 @@ export const EndpointSelector = ({
label="Select an endpoint"
placeholder="Choose an endpoint"
data={endpoints.map(endpoint => ({
value: endpoint.name,
value: `${endpoint.name}_${endpoint.version}`,
label: `${endpoint.name} (${endpoint.version})`
}))}
value={selectedEndpoint}
value={selectedEndpoint + "_" + selectedVersion}
onChange={handleEndpointSelect}
style={{ width: '100%', marginBottom: '1rem' }}
/>
Expand Down
14 changes: 11 additions & 3 deletions snuba/admin/static/rpc_endpoints/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ function RpcEndpoints() {
abortControllerRef.current.abort();
}

setSelectedEndpoint(value);
const selectedEndpointData = getEndpointData(endpoints, value || '');
setSelectedVersion(selectedEndpointData?.version || null);
if (value == null) {
setSelectedEndpoint(null);
setSelectedVersion(null);
} else {
// underscore splits the key between endpointname_version
const split = value.lastIndexOf('_');
setSelectedEndpoint(value.substring(0, value.lastIndexOf('_')));
setSelectedVersion(value.substring(split + 1, value.length));
}

setRequestBody('');
setResponse(null);
setDebugMode(false);
Expand Down Expand Up @@ -122,6 +129,7 @@ function RpcEndpoints() {
<EndpointSelector
endpoints={endpoints}
selectedEndpoint={selectedEndpoint}
selectedVersion={selectedVersion}
handleEndpointSelect={handleEndpointSelect}
/>
<Space h="md" />
Expand Down
1 change: 1 addition & 0 deletions snuba/admin/static/rpc_endpoints/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface StyledSpanProps {
interface EndpointSelectorProps {
endpoints: Array<{ name: string; version: string }>;
selectedEndpoint: string | null;
selectedVersion: string | null;
handleEndpointSelect: (value: string | null) => void;
}

Expand Down
9 changes: 1 addition & 8 deletions snuba/admin/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4447,7 +4447,7 @@ prop-types-extra@^1.1.0:
react-is "^16.3.2"
warning "^4.0.0"

prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
prop-types@^15.6.2, prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down Expand Up @@ -4643,13 +4643,6 @@ randombytes@^2.1.0:
dependencies:
safe-buffer "^5.1.0"

react-bootstrap-icons@^1.11.5:
version "1.11.5"
resolved "https://registry.yarnpkg.com/react-bootstrap-icons/-/react-bootstrap-icons-1.11.5.tgz#9b91a0bf0d5505d92c3574f1f990bb52f36a3ec0"
integrity sha512-eOhtFJMUqw98IJcfKJsSMZkFHCeNPTTwXZAe9V9d4mT22ARmbrISxPO9GmtWWuf72zQctLeZMGodX/q6wrbYYg==
dependencies:
prop-types "^15.7.2"

react-bootstrap@^2.10.5:
version "2.10.5"
resolved "https://registry.yarnpkg.com/react-bootstrap/-/react-bootstrap-2.10.5.tgz#2d3416fb4178d0f460ddafbfcab0aebfbbf1cf25"
Expand Down

0 comments on commit 71cdfde

Please sign in to comment.