Skip to content

Commit 3185119

Browse files
committed
Adding signed-in attribute to mgt-mock-provider (#189)
1 parent 4db4063 commit 3185119

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
depends-on="mgt-teams-provider"
3030
></mgt-msal-provider>
3131

32-
<!-- <mgt-mock-provider></mgt-mock-provider> -->
32+
<!-- <mgt-mock-provider signed-in></mgt-mock-provider> -->
3333

3434
<mgt-login></mgt-login>
3535
<mgt-person person-query="me" show-name show-email person-card="hover"></mgt-person>

src/mock/mgt-mock-provider.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8-
import { customElement, LitElement } from 'lit-element';
8+
import { customElement, LitElement, property } from 'lit-element';
99
import { Providers } from '../Providers';
1010
import { MockProvider } from './MockProvider';
1111
/**
@@ -17,8 +17,25 @@ import { MockProvider } from './MockProvider';
1717
*/
1818
@customElement('mgt-mock-provider')
1919
export class MgtMockProvider extends LitElement {
20+
/**
21+
* A property to allow the developer to start the sample logged out if they desired.
22+
*
23+
* @memberof MgtMockProvider
24+
*/
25+
@property({
26+
attribute: 'signed-in',
27+
type: Boolean
28+
})
29+
public signedIn;
30+
2031
constructor() {
2132
super();
22-
Providers.globalProvider = new MockProvider(true);
33+
34+
// Access the 'signed-in' attribute directly.
35+
// LitElement doesn't parse attributes early enough for us enact on them from the constructor.
36+
const signedInVal = (<any>this).getAttribute('signed-in');
37+
this.signedIn = signedInVal !== 'false' && signedInVal !== null;
38+
39+
Providers.globalProvider = new MockProvider(this.signedIn);
2340
}
2441
}

0 commit comments

Comments
 (0)