apps icon indicating copy to clipboard operation
apps copied to clipboard

chore: Add functionality to fetch apiPaths

Open lilbitner opened this issue 1 year ago • 1 comments

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:

  1. Ensure we are scoping the listDeploymentSummary endpoint appropriately by team. It seems that if we scope by project, this should suffice.
  2. Ensure we grabbing the latest deploymentId when fetching it using the getLatestDeploymentId.
  3. 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.

lilbitner avatar Apr 08 '24 21:04 lilbitner

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

netlify[bot] avatar Apr 08 '24 21:04 netlify[bot]

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-draft instead of api/enable-draft here 🤔 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!

lilbitner avatar Apr 09 '24 14:04 lilbitner