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

🐛 Fetch target images in auth envs #1420

Merged
merged 2 commits into from
Oct 2, 2023
Merged

Conversation

ibolton336
Copy link
Member

Closes https://issues.redhat.com/browse/MTA-1249?filter=-1

  • Image was not being fetched in envs with auth enabled. Image tags () in HTML do not follow the same request mechanism as AJAX or fetch requests. They do not use the XMLHttpRequest or axios API, so they were not intercepted by axios middleware interceptor we have set up for API requests.

@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (bc0fe72) 41.25% compared to head (2e4ddcf) 41.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1420      +/-   ##
==========================================
- Coverage   41.25%   41.20%   -0.05%     
==========================================
  Files         138      139       +1     
  Lines        4349     4371      +22     
  Branches     1005     1007       +2     
==========================================
+ Hits         1794     1801       +7     
- Misses       2543     2558      +15     
  Partials       12       12              
Flag Coverage Δ
client 41.20% <33.33%> (-0.05%) ⬇️
server ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...pages/applications/analysis-wizard/set-targets.tsx 10.95% <100.00%> (ø)
...ent/src/app/components/target-card/target-card.tsx 19.35% <50.00%> (ø)
...mponents/target-card/hooks/useFetchImageDataUrl.ts 24.00% <24.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

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

Great catch to see the 302 response is the request missing auth headers!

A few suggestions to tighten things up.

The biggest issue is getting the content correct in the data url. Try creating your own custom target with a png or jpg image upload..

@@ -68,6 +69,8 @@ export const TargetCard: React.FC<TargetCardProps> = ({
const { t } = useTranslation();
const [isCardSelected, setCardSelected] = React.useState(cardSelected);

const [imageDataUrl, setImageDataUrl] = React.useState<string | null>(null);
Copy link
Member

@sjd78 sjd78 Sep 29, 2023

Choose a reason for hiding this comment

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

It's not really a url anymore, it's just the image data itself, so.... s/imageDataUrl/imageData/

Copy link
Member

Choose a reason for hiding this comment

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

Ok, so reading it again today (with less blurry eyes and more coffee) and it really is a data-url. So the name does make sense!

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 Updated

client/src/app/components/TargetCard.tsx Outdated Show resolved Hide resolved
client/src/app/components/TargetCard.tsx Outdated Show resolved Hide resolved
Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

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

Doing all the work in a hook is a great idea!

I tested with custom targets that have png and jpg icons. It all looks good!

image

@ibolton336 ibolton336 merged commit 0275e63 into konveyor:main Oct 2, 2023
6 checks passed
ibolton336 added a commit to ibolton336/tackle2-ui that referenced this pull request Oct 2, 2023
Closes https://issues.redhat.com/browse/MTA-1249?filter=-1

- Image was not being fetched in envs with auth enabled. Image tags
(<img>) in HTML do not follow the same request mechanism as AJAX or
fetch requests. They do not use the XMLHttpRequest or axios API, so they
were not intercepted by axios middleware interceptor we have set up for
API requests.

---------

Signed-off-by: ibolton336 <[email protected]>
@sjd78 sjd78 linked an issue Oct 5, 2023 that may be closed by this pull request
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.

Images missing for migration targets when running app with auth enabled
2 participants