-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate components with MessageBar and type
- Loading branch information
Showing
22 changed files
with
222 additions
and
50 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Link, MessageBar, MessageBarBody, makeStyles} from '@fluentui/react-components'; | ||
|
||
import { getLoginType } from '../../../modules/authentication/authUtils'; | ||
import { LoginType } from '../../../types/enums'; | ||
import { translateMessage } from '../../utils/translate-messages'; | ||
|
||
const useHeaderStyles = makeStyles({ | ||
root: { | ||
marginBottom: '8', | ||
paddingLeft: '10' | ||
} | ||
}); | ||
|
||
export const headerMessagingV9 = (query: string): React.ReactNode => { | ||
const loginType = getLoginType(); | ||
const headerStyles = useHeaderStyles(); | ||
|
||
return ( | ||
<div className={headerStyles.root}> | ||
{loginType === LoginType.Popup && | ||
<MessageBar intent={'info'}> | ||
<MessageBarBody> | ||
{translateMessage('To try the full features')}, | ||
<Link | ||
tabIndex={0} | ||
inline | ||
href={query} | ||
target='_blank' rel='noopener noreferrer'> | ||
{translateMessage('full Graph Explorer')}. | ||
</Link> | ||
{translateMessage('running the query')}. | ||
</MessageBarBody> | ||
</MessageBar> | ||
} | ||
{loginType === LoginType.Redirect && <MessageBar intent={'warning'}> | ||
<MessageBarBody> | ||
{translateMessage('To try operations other than GET')}, | ||
<Link | ||
tabIndex={0} | ||
href={query} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
inline> | ||
{translateMessage('sign in')}. | ||
</Link> | ||
</MessageBarBody> | ||
</MessageBar>} | ||
</div>); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { MessageBar, MessageBarBody, MessageBarActions, MessageBarIntent, Button } from '@fluentui/react-components'; | ||
import { DismissRegular } from '@fluentui/react-icons'; | ||
import { useAppDispatch, useAppSelector } from '../../../store'; | ||
import { IQuery } from '../../../types/query-runner'; | ||
import { clearQueryStatus } from '../../services/slices/query-status.slice'; | ||
import { setSampleQuery } from '../../services/slices/sample-query.slice'; | ||
import { translateMessage } from '../../utils/translate-messages'; | ||
import MessageDisplay from '../common/message-display/MessageDisplay'; | ||
|
||
const intentMap: { [key: string]: MessageBarIntent } = { | ||
'info': 'info', | ||
'error': 'error', | ||
'warning': 'warning', | ||
'success': 'success' | ||
}; | ||
|
||
const StatusMessagesV9 = () => { | ||
const dispatch = useAppDispatch(); | ||
const queryRunnerStatus = useAppSelector((state)=> state.queryRunnerStatus); | ||
const sampleQuery = useAppSelector((state)=> state.sampleQuery); | ||
|
||
function setQuery(link: string) { | ||
const query: IQuery = { ...sampleQuery }; | ||
link = link.replace(/\.$/, ''); | ||
query.sampleUrl = link; | ||
query.selectedVerb = 'GET'; | ||
dispatch(setSampleQuery(query)); | ||
} | ||
|
||
if (queryRunnerStatus) { | ||
const { messageBarType, statusText, status, duration, hint } = queryRunnerStatus; return <MessageBar | ||
intent={intentMap[messageBarType]} | ||
politeness='assertive' | ||
> | ||
<MessageBarBody> | ||
<MessageDisplay message={`**${statusText} - **${status.toString()}`} onSetQuery={setQuery} /> | ||
|
||
{duration && <> | ||
{` - ${duration} ${translateMessage('milliseconds')}`} | ||
</>} | ||
|
||
{status === 403 && <> | ||
{translateMessage('consent to scopes')} | ||
<span style={{ fontWeight: 600 }}> | ||
{translateMessage('modify permissions')} | ||
</span> | ||
{translateMessage('tab')} | ||
</>} | ||
|
||
{hint && <div>{hint}</div>} | ||
</MessageBarBody> | ||
<MessageBarActions | ||
containerAction={ | ||
<Button | ||
onClick={() => dispatch(clearQueryStatus())} | ||
aria-label="dismiss" | ||
appearance="transparent" | ||
icon={<DismissRegular />} | ||
/> | ||
} | ||
/> | ||
</MessageBar>; | ||
} | ||
return <div />; | ||
} | ||
|
||
export default StatusMessagesV9; |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Link, makeStyles, Button, MessageBar, MessageBarActions, MessageBarBody } from '@fluentui/react-components'; | ||
import { DismissRegular } from '@fluentui/react-icons'; | ||
import { geLocale } from '../../../appLocale'; | ||
import { useAppDispatch, useAppSelector } from '../../../store'; | ||
import { componentNames, telemetry } from '../../../telemetry'; | ||
import { clearTermsOfUse } from '../../services/slices/terms-of-use.slice'; | ||
import { translateMessage } from '../../utils/translate-messages'; | ||
|
||
const useTermsStyles = makeStyles({ | ||
root: { | ||
position: 'relative' | ||
} | ||
}); | ||
|
||
const TermsOfUseMessageV9 = () => { | ||
|
||
const termsOfUse = useAppSelector((state) => state.termsOfUse); | ||
const termsStyles = useTermsStyles(); | ||
|
||
const dispatch = useAppDispatch(); | ||
if (termsOfUse) { | ||
return <MessageBar intent={'info'} | ||
className={termsStyles.root}> | ||
<MessageBarBody> | ||
{translateMessage('use the Microsoft Graph API')} | ||
<Link | ||
onClick={(e) => | ||
telemetry.trackLinkClickEvent((e.currentTarget as HTMLAnchorElement).href, | ||
componentNames.MICROSOFT_APIS_TERMS_OF_USE_LINK)} | ||
href={'https://learn.microsoft.com/' + geLocale + | ||
'/legal/microsoft-apis/terms-of-use?context=graph/context'} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
inline> | ||
{translateMessage('Terms of use')} | ||
</Link>. | ||
{translateMessage('View the')} | ||
<Link | ||
onClick={(e) => | ||
telemetry.trackLinkClickEvent((e.currentTarget as HTMLAnchorElement).href, | ||
componentNames.MICROSOFT_PRIVACY_STATEMENT_LINK)} | ||
href={'https://privacy.microsoft.com/' + geLocale + '/privacystatement'} | ||
target='_blank' | ||
rel='noopener noreferrer' | ||
inline> | ||
{translateMessage('Microsoft Privacy Statement')}</Link>. | ||
</MessageBarBody> | ||
<MessageBarActions | ||
containerAction={ | ||
<Button | ||
onClick={() => dispatch(clearTermsOfUse())} | ||
aria-label="dismiss" | ||
appearance="transparent" | ||
icon={<DismissRegular />} | ||
/> | ||
} | ||
/> | ||
</MessageBar>; | ||
} | ||
return <div />; | ||
} | ||
|
||
export default TermsOfUseMessageV9; |
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,7 +1,7 @@ | ||
import StatusMessages from './StatusMessages'; | ||
import TermsOfUseMessage from './TermsOfUseMessage'; | ||
import StatusMessagesV9 from './StatusMessagesV9'; | ||
import TermsOfUseMessageV9 from './TermsOfUseMessageV9'; | ||
|
||
export { | ||
StatusMessages, | ||
TermsOfUseMessage | ||
StatusMessagesV9, | ||
TermsOfUseMessageV9 | ||
}; |
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.