Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feat/Appliance: Frontend Pulls Version Info from RelReg#64089

Merged
Chickensoupwithrice merged 4 commits into
mainfrom
al/REL-290/appliance-frontend-relreg
Jul 29, 2024
Merged

feat/Appliance: Frontend Pulls Version Info from RelReg#64089
Chickensoupwithrice merged 4 commits into
mainfrom
al/REL-290/appliance-frontend-relreg

Conversation

@Chickensoupwithrice

@Chickensoupwithrice Chickensoupwithrice commented Jul 25, 2024

Copy link
Copy Markdown
Contributor

Resolves REL-290 by making a single request to the release registry to get a list of versions

Test plan

manual tested

Changelog

  • feat(appliance): frontend pulls versions from relreg

@cla-bot cla-bot Bot added the cla-signed label Jul 25, 2024
@Chickensoupwithrice Chickensoupwithrice changed the title Appliance Frontend Pulls Version Info from RelReg feat/Appliance: Frontend Pulls Version Info from RelReg Jul 26, 2024
@Chickensoupwithrice

Copy link
Copy Markdown
Contributor Author

This feels like the wrong approach tbh, calling relregistry from clientside, when we have a release registry client in the backend is a bit silly. But then I'd have to expose the api endpoint on the backend that calls another api endpoint (the relreg)

Doing it this way means we need to pass another env var to the front end, which isn't the end of the world, but is annoying.

i'm also still struggling to get a build of the maintaince ui running to test this, so i'm not actually sure it works, hence it's a draft

@Chickensoupwithrice

Copy link
Copy Markdown
Contributor Author

Just remembered that I need to do the whole CORS dance 😭

@craigfurman craigfurman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, this errors in my browser due to lack of CORS bypass.

Sadly we appear to have lost unified instructions on how to kick the tires on the appliance in development since we introduced the new UI.

You should be able to test this by: run the appliance backend, using instructions in https://github.com/sourcegraph/sourcegraph/blob/main/cmd/appliance/README.md.

In another terminal:

cd internal/appliance/frontend/maintenance
pnpm i
pnpm run dev

Assuming you get no build errors, navigate to localhost:8889 in your browser and you should see the maintenance UI.

@Chickensoupwithrice

Copy link
Copy Markdown
Contributor Author

Thanks for the tips @craigfurman, I managed to get a test environment setup :)

However it looks like CORS headers aren't being set on the releaseregistry, so I'm gonna make a PR there too

@Chickensoupwithrice

Copy link
Copy Markdown
Contributor Author

Alright, finally got this tested, and working :)

image

Requires changes to releaseregistry such that it also passes CORS headers, which I've made here

@craigfurman craigfurman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work! 🚀

I haven't reproduced the testing since (if I understand correctly) I'd need to populate some data in a local relreg until the CORS headers PR lands.

const [version, setVersion] = useState<string[]>([])
const [selectedVersion, setSelectedVersion] = useState<string>('')

useEffect(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have zero react experience so take this with a tablespoon of salt, but this view file doesn't feel like quite the right place for this function. Maybe we put it in a ts file and import it? Totally non-blocking note in any case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is pretty typical in react with hooks in my experience

const data = await response.json()
setVersion(data)
if (data.length > 0) {
const publicVersions = data.filter(item => item.public).map(item => item.version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The critical bit here 👍🏼

@Chickensoupwithrice Chickensoupwithrice marked this pull request as ready for review July 29, 2024 17:48
@Chickensoupwithrice Chickensoupwithrice merged commit 98c6b97 into main Jul 29, 2024
@Chickensoupwithrice Chickensoupwithrice deleted the al/REL-290/appliance-frontend-relreg branch July 29, 2024 18:40
craigfurman pushed a commit that referenced this pull request Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants