-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[BREAK] Change apps/icon endpoint to return app's icon and use it to show on Ui Kit modal #16522
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -516,6 +516,33 @@ export class AppsRestApi { | |
}, | ||
}); | ||
|
||
this.api.addRoute('icon/:id', { authRequired: false }, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know I can be hated for this because there is another endpoint There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC the other one is not used anywhere? 🤔 I think I've searched for it before and haven't found anything. If that's the case, you can just change the behavior of the other one 😬 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're targeting a major version, I could introduce this breaking change. |
||
get() { | ||
const prl = manager.getOneById(this.urlParams.id); | ||
if (!prl) { | ||
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`); | ||
} | ||
|
||
const info = prl.getInfo(); | ||
if (!info || !info.iconFileContent) { | ||
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`); | ||
} | ||
|
||
const imageData = info.iconFileContent.split(';base64,'); | ||
|
||
const buf = Buffer.from(imageData[1], 'base64'); | ||
|
||
return { | ||
statusCode: 200, | ||
headers: { | ||
'Content-Length': buf.length, | ||
'Content-Type': imageData[0].replace('data:', ''), | ||
}, | ||
body: buf, | ||
}; | ||
}, | ||
}); | ||
|
||
this.api.addRoute(':id/languages', { authRequired: false }, { | ||
get() { | ||
const prl = manager.getOneById(this.urlParams.id); | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -44,7 +44,6 @@ const textParser = uiKitText(new class { | |||||
return text; | ||||||
} | ||||||
}()); | ||||||
const thumb = 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=='; | ||||||
|
||||||
// https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html | ||||||
|
||||||
|
@@ -134,7 +133,7 @@ export const modalBlockWithContext = ({ | |||||
<Modal open id={id} ref={ref}> | ||||||
<Modal.Header> | ||||||
{/* <Modal.Thumb url={`api/apps/${ context.appId }/icon`} /> */} | ||||||
<Modal.Thumb url={thumb} /> | ||||||
<Modal.Thumb url={`/api/apps/icon/${ data.appId }`} /> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not the best way to get the full URL, pls advice There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a context to set the prefix path There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have found:
but looks like I cannot use it because you're not using
what should I do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk the advantages using a context, so I changed to use |
||||||
<Modal.Title>{textParser([title])}</Modal.Title> | ||||||
<Modal.Close tabIndex={-1} onClick={onClose} /> | ||||||
</Modal.Header> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
༼ つ ◕_◕ ༽つ
name