Skip to content

Commit 2829baa

Browse files
adrwsvc-squareup-copybara
authored andcommitted
Update web actions to prioritize product endpoints over
container defaults # Before <img width="1047" alt="Screenshot 2025-06-04 at 14 38 41" src="https://github.com/user-attachments/assets/2f1117bf-1149-483a-a630-0e795128cb12" /> # After <img width="1045" alt="Screenshot 2025-06-04 at 14 35 58" src="https://github.com/user-attachments/assets/cc6973ed-fe29-46cc-9875-943c3f374665" /> GitOrigin-RevId: bf28605d0f482825ea4717199f800de372c7037f
1 parent 99c02e9 commit 2829baa

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

misk-admin-web-actions/src/web-actions/ui/EndpointSelection.tsx

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,58 @@ export default class EndpointSelection extends React.Component<Props, State> {
4040
};
4141
}
4242

43+
// TODO consider moving this to an isMiskEndpoint boolean on the metadata from the server
44+
private isMiskEndpoint(route: MiskRoute): boolean {
45+
const routes = [
46+
'/',
47+
'/_liveness',
48+
'/_readiness',
49+
'/_status',
50+
'/api/{id}/metadata',
51+
'/api/v1/database/query/metadata',
52+
'/api/service/metadata',
53+
'/{path:.*}',
54+
];
55+
const routePrefixes = [
56+
'/_admin',
57+
'/v2/_admin',
58+
'/_tab',
59+
'/api/dashboard/',
60+
'/@misk',
61+
'/static',
62+
];
63+
return (
64+
routes.includes(route.path) ||
65+
routePrefixes.some((prefix) => route.path.startsWith(prefix))
66+
);
67+
}
68+
4369
componentDidMount() {
4470
this.metadataClient.fetchMetadata().then((actions: MiskRoute[]) => {
45-
this.options = actions
46-
.map((actionGroup) => ({
47-
label: `${actionGroup.httpMethod} ${actionGroup.path} (${actionGroup.actionName})`,
48-
termsString:
49-
`${actionGroup.httpMethod} ${actionGroup.path} ${actionGroup.actionName}`.toLowerCase(),
50-
value: actionGroup,
51-
}))
71+
const appEndpoints = actions
72+
.filter((action) => !this.isMiskEndpoint(action))
5273
.sort((a, b) => {
5374
// Sort by path first, then by HTTP method
54-
const pathCompare = a.value.path.localeCompare(b.value.path);
75+
const pathCompare = a.path.localeCompare(b.path);
5576
if (pathCompare !== 0) return pathCompare;
56-
return a.value.httpMethod.localeCompare(b.value.httpMethod);
77+
return a.httpMethod.localeCompare(b.httpMethod);
5778
});
79+
const miskEndpoints = actions
80+
.filter((action) => this.isMiskEndpoint(action))
81+
.sort((a, b) => {
82+
// Sort by path first, then by HTTP method
83+
const pathCompare = a.path.localeCompare(b.path);
84+
if (pathCompare !== 0) return pathCompare;
85+
return a.httpMethod.localeCompare(b.httpMethod);
86+
});
87+
88+
// Combine app and Misk endpoints, ensuring Misk endpoints are always after app endpoints for less scrolling
89+
this.options = [...appEndpoints, ...miskEndpoints].map((actionGroup) => ({
90+
label: `${actionGroup.httpMethod} ${actionGroup.path} (${actionGroup.actionName})`,
91+
termsString:
92+
`${actionGroup.httpMethod} ${actionGroup.path} ${actionGroup.actionName}`.toLowerCase(),
93+
value: actionGroup,
94+
}));
5895

5996
this.setState({ filteredOptions: this.options });
6097
this.focusSelect();

0 commit comments

Comments
 (0)