Skip to content

Conversation

@vidhikapadia2799
Copy link
Contributor

What does this PR do?

  • This feature is only enable if .env file has NEXT_PUBLIC_UNSPLASH_API_KEY is present
  • Rename "Image" to "Upload
  • Added a new tab called "Image" with a Search bar at the top and three columns of pictures calling unsplash api
  • On selecting the image, it will be visible in preview form

image

image

Fixes # (2279)

How should this be tested?

  • Create a new form.
  • Navigate to styling tab from the top.
  • Enable add custom style buttom and select background styling
  • Navigate to Image tab and select your background and on selecting view it in preview mode.

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

@vercel
Copy link

vercel bot commented Mar 26, 2024

@vidhikapadia2799 is attempting to deploy a commit to the formbricks Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Mar 26, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2024

Thank you for following the naming conventions for pull request titles! 🙏

@vidhikapadia2799 vidhikapadia2799 changed the title Feat unsplash api feat: Add Unsplash API for image backgrounds Mar 26, 2024
@vidhikapadia2799 vidhikapadia2799 changed the title feat: Add Unsplash API for image backgrounds feat: Added Unsplash API for image backgrounds Mar 26, 2024
@jobenjada
Copy link
Member

hey @vidhikapadia2799 thanks for your PR :) The screenshots look great!

Can you pls sign the Contributor CLA and fix the merge conflict?

@ShubhamPalriwala will then review your PR.

Cheers!

@vidhikapadia2799
Copy link
Contributor Author

Hi @jobenjada, resolved merge conflicts. Also signed contributor CLA.

@ShubhamPalriwala Can you please review the PR.

Thanks.

Copy link
Contributor

@ShubhamPalriwala ShubhamPalriwala left a comment

Choose a reason for hiding this comment

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

Hey @vidhikapadia2799 thanks a lot for the PR 💪🏼 I tested it and the core works pretty nicely. Just some small changes I think we can make to get the PR ready!

  1. I think you interchanged the headings by mistake (Image is where Search is, & Upload is the normal upload functionality)

  2. Since you are making the API call in a client side environment, the unsplash credentials are visible in the client browser which leads to leaking the secret key. So can you move this to a server side action?
    image

  3. Adding to the previous point, lets also make the env var away from NEXT_PUBLIC_ so that its only called server side + self hosters can set the variable at runtime itself.

I've also suggested some code changes below so please take a look!
Realyy excited to see your pace in shipping this 💪🏼 Let me know if you have any doubts or queries!

@vidhikapadia2799
Copy link
Contributor Author

vidhikapadia2799 commented Mar 30, 2024

Hey @ShubhamPalriwala , thanks for reviewing PR.

  1. I have mistakenly changes label for Image and Upload. Made changes to label and not to id otherwise need to make many change in already built in Image component.
  2. And called api on server side to prevent leaking secret key.
  3. Also removed NEXT_PUBLIC as suggested made server side api call.

Done with other suggested changes.Can you please have a look and let me know if any other changes required.

Looking forward to contribute to formbricks.

Thanks.

@ShubhamPalriwala
Copy link
Contributor

Hey @vidhikapadia2799, thanks a lot for making the changes! 😄 Looks great! It works nicely too, just one change to keep in line with the product's policies:

Currently, in the link survey rendering action, you load the image from unsplash API directly. This might cause issues with the Policy for the end-user who is filling the form as they will be making a call to the Unsplash domain.

To tackle this, what we can do is that, once the survey creator selects an image from Unsplash, we upload it in the same way we do if a manual image was uploaded on our servers! In this way, when an end-user views the survey, they get the image from the formbricks servers itself rather than a third-party.

Let me know if you have any doubts around this or need some help!

@vidhikapadia2799
Copy link
Contributor Author

Hi @ShubhamPalriwala , I have made the requested changes. Can you please have a look ?

Let me know if any changes are required.

Thanks

@ShubhamPalriwala
Copy link
Contributor

Hey @vidhikapadia2799, thanks a lot for your changes! They look good, I made some minor UX tweaks & passed the env var from a server component to the client components rather than getting them from a server action.

@vidhikapadia2799
Copy link
Contributor Author

Hi @ShubhamPalriwala , I have gone through the changes you made and will make sure from next time to keep following way.

One thing I noticed, there is one console.log and some commented code in your changes. Do we need to keep that or remove it ?

@ShubhamPalriwala
Copy link
Contributor

good catch 😁 i still have some work to do on this PR, once done, I'll ping you as well, so you can understand the changes! thanks again

@jobenjada
Copy link
Member

jobenjada commented Apr 22, 2024

Hey @ShubhamPalriwala

I'm getting the following error after clicking on one of the preselected images:

image

leads to

image
  1. We should pull 9 or 12 images, not 10:
image
  1. Some of the images don't work. I click on them and it does replace the text but not the image (see mismatch of author here):
image
  1. Image quality: I feel that we compress them a bit too much (or pull to small an image). Maybe it's my 4k screen but the images seem to be quite pixelated, especially detail shots don't really work.

Look at the resolution:
image


  1. Production app requirements: Please make sure all of this is applied correctly (as much as you can do it):
image
  1. I would love a "Load more" button which loads another 9 images. Since we're moving the scope anyways: Can you add that? 😉

Thanks! :)

@jobenjada jobenjada self-requested a review April 22, 2024 15:32
Copy link
Member

@jobenjada jobenjada left a comment

Choose a reason for hiding this comment

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

see comment

@ShubhamPalriwala
Copy link
Contributor

Fixed & Made all the changes as suggested, please take a look 🤞🏼

@jobenjada jobenjada added this pull request to the merge queue Apr 24, 2024
@jobenjada
Copy link
Member

/award 500

@oss-gg
Copy link

oss-gg bot commented Apr 24, 2024

Awarding vidhikapadia2799: 500 points!

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 24, 2024
@vercel
Copy link

vercel bot commented Apr 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 2:16pm
formbricks-com ⬜️ Ignored (Inspect) Visit Preview Apr 24, 2024 2:16pm

@mattinannt mattinannt added this pull request to the merge queue Apr 24, 2024
@jobenjada jobenjada removed this pull request from the merge queue due to a manual request Apr 24, 2024
@mattinannt mattinannt added this pull request to the merge queue Apr 24, 2024
Merged via the queue into formbricks:main with commit 2da2758 Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants