mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Prettier 2.0 (#393)
This commit is contained in:
@@ -4,12 +4,12 @@ import { UserAgentApplication, Account, Configuration } from "msal";
|
||||
|
||||
const config: Configuration = {
|
||||
cache: {
|
||||
cacheLocation: "localStorage"
|
||||
cacheLocation: "localStorage",
|
||||
},
|
||||
auth: {
|
||||
authority: "https://login.microsoftonline.com/common",
|
||||
clientId: "203f1145-856a-4232-83d4-a43568fba23d"
|
||||
}
|
||||
clientId: "203f1145-856a-4232-83d4-a43568fba23d",
|
||||
},
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
@@ -56,9 +56,9 @@ export function useAADAuth(): ReturnType {
|
||||
}, []);
|
||||
|
||||
const switchTenant = React.useCallback(
|
||||
async id => {
|
||||
async (id) => {
|
||||
const response = await msal.loginPopup({
|
||||
authority: `https://login.microsoftonline.com/${id}`
|
||||
authority: `https://login.microsoftonline.com/${id}`,
|
||||
});
|
||||
setTenantId(response.tenantId);
|
||||
setAccount(response.account);
|
||||
@@ -73,14 +73,14 @@ export function useAADAuth(): ReturnType {
|
||||
// There is a bug in MSALv1 that requires us to refresh the token. Their internal cache is not respecting authority
|
||||
forceRefresh: true,
|
||||
authority: `https://login.microsoftonline.com/${tenantId}`,
|
||||
scopes: ["https://graph.windows.net//.default"]
|
||||
scopes: ["https://graph.windows.net//.default"],
|
||||
}),
|
||||
msal.acquireTokenSilent({
|
||||
// There is a bug in MSALv1 that requires us to refresh the token. Their internal cache is not respecting authority
|
||||
forceRefresh: true,
|
||||
authority: `https://login.microsoftonline.com/${tenantId}`,
|
||||
scopes: ["https://management.azure.com//.default"]
|
||||
})
|
||||
scopes: ["https://management.azure.com//.default"],
|
||||
}),
|
||||
]).then(([graphTokenResponse, armTokenResponse]) => {
|
||||
setGraphToken(graphTokenResponse.accessToken);
|
||||
setArmToken(armTokenResponse.accessToken);
|
||||
@@ -96,6 +96,6 @@ export function useAADAuth(): ReturnType {
|
||||
armToken,
|
||||
login,
|
||||
logout,
|
||||
switchTenant
|
||||
switchTenant,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export function useDirectories(armToken: string): Tenant[] {
|
||||
|
||||
useEffect(() => {
|
||||
if (armToken) {
|
||||
fetchDirectories(armToken).then(response => setState(response));
|
||||
fetchDirectories(armToken).then((response) => setState(response));
|
||||
}
|
||||
}, [armToken]);
|
||||
return state || [];
|
||||
|
||||
@@ -9,10 +9,10 @@ export async function fetchPhoto(accessToken: string): Promise<Blob | void> {
|
||||
|
||||
const options = {
|
||||
method: "GET",
|
||||
headers: headers
|
||||
headers: headers,
|
||||
};
|
||||
|
||||
return fetch("https://graph.windows.net/me/thumbnailPhoto?api-version=1.6", options).then(response =>
|
||||
return fetch("https://graph.windows.net/me/thumbnailPhoto?api-version=1.6", options).then((response) =>
|
||||
response.blob()
|
||||
);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export function useGraphPhoto(graphToken: string): string {
|
||||
|
||||
useEffect(() => {
|
||||
if (graphToken) {
|
||||
fetchPhoto(graphToken).then(response => setPhoto(URL.createObjectURL(response)));
|
||||
fetchPhoto(graphToken).then((response) => setPhoto(URL.createObjectURL(response)));
|
||||
}
|
||||
}, [graphToken]);
|
||||
return photo;
|
||||
|
||||
@@ -12,15 +12,15 @@ export async function fetchAccessData(portalToken: string): Promise<AccessInputM
|
||||
|
||||
const options = {
|
||||
method: "GET",
|
||||
headers: headers
|
||||
headers: headers,
|
||||
};
|
||||
|
||||
return (
|
||||
fetch(url, options)
|
||||
.then(response => response.json())
|
||||
.then((response) => response.json())
|
||||
// Portal encrypted token API quirk: The response is double JSON encoded
|
||||
.then(json => JSON.parse(json))
|
||||
.catch(error => console.error(error))
|
||||
.then((json) => JSON.parse(json))
|
||||
.catch((error) => console.error(error))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function useTokenMetadata(token: string): AccessInputMetadata {
|
||||
|
||||
useEffect(() => {
|
||||
if (token) {
|
||||
fetchAccessData(token).then(response => setState(response));
|
||||
fetchAccessData(token).then((response) => setState(response));
|
||||
}
|
||||
}, [token]);
|
||||
return state;
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function fetchSubscriptions(accessToken: string): Promise<Subscript
|
||||
}
|
||||
nextLink = result.nextLink;
|
||||
const validSubscriptions = result.value.filter(
|
||||
sub => sub.state === "Enabled" || sub.state === "Warned" || sub.state === "PastDue"
|
||||
(sub) => sub.state === "Enabled" || sub.state === "Warned" || sub.state === "PastDue"
|
||||
);
|
||||
subscriptions = [...subscriptions, ...validSubscriptions];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user