-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert some class components to functions.
- Loading branch information
Showing
31 changed files
with
1,019 additions
and
1,510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,31 @@ | ||
import { Component } from 'react'; | ||
import { useCallback } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { IIIFIFrameCommunication } from './IIIFIFrameCommunication'; | ||
|
||
/** | ||
* Opens a new window for click | ||
*/ | ||
export class AccessTokenSender extends Component { | ||
/** */ | ||
constructor(props) { | ||
super(props); | ||
|
||
this.onReceiveAccessTokenMessage = this.onReceiveAccessTokenMessage.bind(this); | ||
} | ||
|
||
/** @private */ | ||
onReceiveAccessTokenMessage(e) { | ||
const { handleAccessTokenMessage, url } = this.props; | ||
export function AccessTokenSender({ handleAccessTokenMessage, url = undefined }) { | ||
const onReceiveAccessTokenMessage = useCallback((e) => { | ||
if (e.data && e.data.messageId && e.data.messageId === url) handleAccessTokenMessage(e.data); | ||
} | ||
}, [handleAccessTokenMessage, url]); | ||
|
||
/** */ | ||
render() { | ||
const { url } = this.props; | ||
if (!url) return null; | ||
if (!url) return null; | ||
|
||
/** | ||
login, clickthrough/kiosk open @id, wait for close | ||
external, no-op | ||
*/ | ||
return ( | ||
<IIIFIFrameCommunication | ||
src={`${url}?origin=${window.origin}&messageId=${url}`} | ||
title="AccessTokenSender" | ||
handleReceiveMessage={this.onReceiveAccessTokenMessage} | ||
/> | ||
); | ||
} | ||
/** | ||
login, clickthrough/kiosk open @id, wait for close | ||
external, no-op | ||
*/ | ||
return ( | ||
<IIIFIFrameCommunication | ||
src={`${url}?origin=${window.origin}&messageId=${url}`} | ||
title="AccessTokenSender" | ||
handleReceiveMessage={onReceiveAccessTokenMessage} | ||
/> | ||
); | ||
} | ||
|
||
AccessTokenSender.propTypes = { | ||
handleAccessTokenMessage: PropTypes.func.isRequired, | ||
url: PropTypes.string, | ||
}; | ||
|
||
AccessTokenSender.defaultProps = { | ||
url: undefined, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.