Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove edit button only for terraform enterprise #2564

Merged
merged 7 commits into from
Sep 12, 2024

Conversation

rmainwork
Copy link
Contributor

@rmainwork rmainwork commented Sep 10, 2024

πŸ”— Relevant links

πŸ—’οΈ What

Hide "Edit this page on GitHub" link for PTFE since (most) people looking at the page will be unable to do so and clicking the link takes them to a 404.

🀷 Why

The initial implementation of this ticket was driven by this support request that came in because a customer had pointed out that the "Edit this page on GitHub" link took them to a 404. This PR was in turn a re-hash of #2540 (which turned out to be too broad and hid the link for ALL Terraform docs - which turned out not to be correct) after it was reverted by #2562.

πŸ› οΈ How

The initial implementation checked for product.slug + currentPathUnderProduct !== 'terraform/enterprise' which works but is a little messy. Shout-out to @heatlikeheatwave who instead proposed checking the JSON returned by fetchDocument to determine if the product was PTFE(rather than string matching the URL). They also suggested moving this logic(and related logic for isPublicContentRepo) out of server.ts and into the loader(which is much cleaner IMO πŸŽ‰)

πŸ§ͺ Testing

  1. Navigate to Terraform docs prod and confirm that the "Edit this page on GitHub" link is visible
  2. Navigate to Terraform docs preview and verify that the "Edit this page on GitHub" link is visible
  3. Navigate to PTFE docs preview and ensure that the "Edit this page on GitHub" link is not visible
  4. Navigate to HCP docs preview and ensure that the "Edit this page on GitHub" link is not visible
  5. Navigate to Sentinel docs preview and ensure that the "Edit this page on GitHub" link is not visible
  6. Navigate to the docs preview for another product(Boundary for example) and ensure that the "Edit this page on GitHub" link is visible

In summary:

  • ℹ️ Link is visible on developer.hashicorp.com (currently)
  • βœ… Link should be visible on regular Terraform docs
  • βœ… Link should be visible on other product pages
  • ❌ Link should not be visible on PTFE (Private Terraform Enterprise)
  • ❌ Link should not be visible on HCP
  • ❌ Link should not be visible on Sentinel

rmainwork and others added 3 commits September 6, 2024 16:33
Since `isHcp` and `isSentinel` aren't used elsewhere, this expression can be
simplified down to a one-liner

Co-authored-by:  Heat Hamilton <[email protected]>
This will hide the "Edit on GitHub" link for terraform enterprise only
Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
dev-portal βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Sep 12, 2024 6:16pm

Copy link

github-actions bot commented Sep 10, 2024

πŸ“¦ Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action πŸ€–

This PR introduced no changes to the javascript bundle πŸ™Œ

Since logic was implemented in the loader to hide the "Edit this page on
GitHub" link for PTFE, it makes sense to move the other (similar) logic
there too to keep everything together.

Additionally, this also allows the expression to be cleaned up to use
`this.opts.product` and `Array.includes()` to detect private repos.
Copy link
Collaborator

@RubenSandwich RubenSandwich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. πŸ‘πŸ»

@rmainwork rmainwork enabled auto-merge (squash) September 12, 2024 18:13
@rmainwork rmainwork merged commit 1512f68 into main Sep 12, 2024
6 checks passed
@rmainwork rmainwork deleted the rm/remove-edit-button-only-for-terraform-enterprise branch September 12, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants