Skip to content

Commit

Permalink
fix(ui): improve endpoints ordering (#3041)
Browse files Browse the repository at this point in the history
# Changes

- Improve endpoints ordering
We were only pushing items up if the comparison was directly different,
so when we compared POST to DELETE, POST was not pushed up.
  • Loading branch information
bodinsamuel authored Nov 25, 2024
1 parent 449637d commit 74fe8b5
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { EndpointsList } from './components/List';
import { EndpointOne } from './components/One';
import PageNotFound from '../../../PageNotFound';

const METHOD_PRIORITY = { GET: 1, POST: 2, PUT: 3, PATCH: 4, DELETE: 5 };

export const EndpointsShow: React.FC<{ integration: GetIntegration['Success']['data'] }> = ({ integration }) => {
const env = useStore((state) => state.env);
const { providerConfigKey } = useParams();
Expand Down Expand Up @@ -61,11 +63,7 @@ export const EndpointsShow: React.FC<{ integration: GetIntegration['Success']['d
if (a.endpoint.path !== b.endpoint.path) return 0;

// Sort by method
if (a.endpoint.method === 'GET' && b.endpoint.method !== 'GET') return -1;
else if (a.endpoint.method === 'POST' && b.endpoint.method === 'PUT') return -1;
else if (a.endpoint.method === 'PUT' && b.endpoint.method === 'PATCH') return -1;
else if (a.endpoint.method === 'PATCH' && b.endpoint.method === 'DELETE') return -1;
else return 0;
return METHOD_PRIORITY[a.endpoint.method] - METHOD_PRIORITY[b.endpoint.method];
})
});
}
Expand Down

0 comments on commit 74fe8b5

Please sign in to comment.