-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into a11y/fix-btn-chevron
- Loading branch information
Showing
15 changed files
with
272 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* ------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. | ||
* See License in the project root for license information. | ||
* ------------------------------------------------------------------------------------------- | ||
*/ | ||
|
||
import { expect } from '@open-wc/testing'; | ||
import { MockProvider } from '../mock/MockProvider'; | ||
import { ProviderState } from '../providers/IProvider'; | ||
import { Providers } from '../providers/Providers'; | ||
import { isSignedIn } from './isSignedIn'; | ||
|
||
describe('signedInState', () => { | ||
it('should change', () => { | ||
/* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
Providers.globalProvider = new MockProvider(false); | ||
expect(isSignedIn()).to.be.false; | ||
Providers.globalProvider.setState(ProviderState.SignedIn); | ||
expect(isSignedIn()).to.be.true; | ||
}); | ||
}); |
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,19 @@ | ||
/** | ||
* ------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. | ||
* See License in the project root for license information. | ||
* ------------------------------------------------------------------------------------------- | ||
*/ | ||
|
||
import { ProviderState } from '../providers/IProvider'; | ||
import { Providers } from '../providers/Providers'; | ||
|
||
/** | ||
* Checks the provider state if it's in signed in. | ||
* | ||
* @returns true if signed in, otherwise false. | ||
*/ | ||
export const isSignedIn = (): boolean => { | ||
const provider = Providers.globalProvider; | ||
return provider && provider.state === ProviderState.SignedIn; | ||
}; |
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,8 @@ | ||
/** | ||
* ------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. | ||
* See License in the project root for license information. | ||
* ------------------------------------------------------------------------------------------- | ||
*/ | ||
|
||
export * from './useIsSignedIn'; |
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,31 @@ | ||
/** | ||
* ------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. | ||
* See License in the project root for license information. | ||
* ------------------------------------------------------------------------------------------- | ||
*/ | ||
|
||
import { isSignedIn, Providers } from '@microsoft/mgt-element'; | ||
import { useState, useEffect } from 'react'; | ||
|
||
/** | ||
* Hook to check if a user is signed in. | ||
* | ||
* @returns true if a user is signed on, otherwise false. | ||
*/ | ||
export const useIsSignedIn = (): [boolean] => { | ||
const [signedIn, setIsSignedIn] = useState(false); | ||
useEffect(() => { | ||
const updateState = () => { | ||
setIsSignedIn(isSignedIn()); | ||
}; | ||
|
||
Providers.onProviderUpdated(updateState); | ||
updateState(); | ||
|
||
return () => { | ||
Providers.removeProviderUpdatedListener(updateState); | ||
}; | ||
}, [setIsSignedIn]); | ||
return [signedIn]; | ||
}; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.