chore: Add functionality to fetch apiPaths
Purpose
The purpose of this PR is to render the list of api-paths dynamically on the config page.
Approach
We first fetch the latest deploymentId, scoped by the selected projectId, and use this deploymentId to then fetch a deploymentSummary. We filter this data based on serverlessFunctions that are of type Page and include 'api' within the path.
https://github.com/contentful/apps/assets/58186851/8d235ef1-802e-4fd0-bec1-67588499c845
Testing steps
Paste a valid token, select a project, and select an api path on the vercel config page. You should be able to change projects and render the new list of paths as well.
Follow-up
As you will notice in the comments I have added there are a few follow-up items:
- Ensure we are scoping the
listDeploymentSummaryendpoint appropriately by team. It seems that if we scope by project, this should suffice. - Ensure we grabbing the latest
deploymentIdwhen fetching it using thegetLatestDeploymentId. - Cleanup the behavior of the dropdown. i.e ensure that an appropriate default is selected or just render the placeholder, especially when switching between projects.
Deploy Preview for ecommerce-app-base-components canceled.
| Name | Link |
|---|---|
| Latest commit | 8160f5bd5af881e3125887d7c2a773964014b160 |
| Latest deploy log | https://app.netlify.com/sites/ecommerce-app-base-components/deploys/66154c80bc42fc000851194e |
AWESOME this makes sense to me 😄 Looks really good overall, amazing work! I'm wondering if we should go ahead and make the paths prefixed with
/i.e.:/api/enable-draftinstead ofapi/enable-drafthere 🤔 Not blocking at all but something we need to consider or update user interface/app action I believe
Yeah super good point! Maybe worth discussing a bit further in terms of determining if we reserve that logic for user-interface to manipulate as needed. Or perhaps we add it here for visual sake. Will capture in follow-up work!