2019-03-19 15:42:25 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import type { Dispatch } from 'redux';
|
|
|
|
|
2018-08-17 19:34:41 +00:00
|
|
|
import { getShareInfoText } from '../invite';
|
2018-08-02 21:56:36 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
SET_GOOGLE_API_PROFILE,
|
|
|
|
SET_GOOGLE_API_STATE
|
|
|
|
} from './actionTypes';
|
|
|
|
import { GOOGLE_API_STATES } from './constants';
|
|
|
|
import googleApi from './googleApi';
|
|
|
|
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
/**
|
|
|
|
* Retrieves the current calendar events.
|
|
|
|
*
|
|
|
|
* @param {number} fetchStartDays - The number of days to go back when fetching.
|
|
|
|
* @param {number} fetchEndDays - The number of days to fetch.
|
2019-03-19 15:42:25 +00:00
|
|
|
* @returns {function(Dispatch<any>): Promise<CalendarEntries>}
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
*/
|
|
|
|
export function getCalendarEntries(
|
|
|
|
fetchStartDays: ?number, fetchEndDays: ?number) {
|
|
|
|
return () =>
|
|
|
|
googleApi.get()
|
|
|
|
.then(() =>
|
|
|
|
googleApi._getCalendarEntries(fetchStartDays, fetchEndDays));
|
|
|
|
}
|
|
|
|
|
2018-08-02 21:56:36 +00:00
|
|
|
/**
|
|
|
|
* Loads Google API.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2020-02-11 15:14:01 +00:00
|
|
|
export function loadGoogleAPI() {
|
2019-03-19 15:42:25 +00:00
|
|
|
return (dispatch: Dispatch<any>, getState: Function) =>
|
2018-08-02 21:56:36 +00:00
|
|
|
googleApi.get()
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
.then(() => {
|
2020-02-11 15:14:01 +00:00
|
|
|
const {
|
|
|
|
liveStreamingEnabled,
|
|
|
|
enableCalendarIntegration,
|
|
|
|
googleApiApplicationClientID
|
|
|
|
} = getState()['features/base/config'];
|
|
|
|
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
if (getState()['features/google-api'].googleAPIState
|
|
|
|
=== GOOGLE_API_STATES.NEEDS_LOADING) {
|
2020-02-11 15:14:01 +00:00
|
|
|
return googleApi.initializeClient(
|
|
|
|
googleApiApplicationClientID, liveStreamingEnabled, enableCalendarIntegration);
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.resolve();
|
|
|
|
})
|
2018-08-10 10:30:00 +00:00
|
|
|
.then(() => dispatch(setGoogleAPIState(GOOGLE_API_STATES.LOADED)))
|
2018-08-02 21:56:36 +00:00
|
|
|
.then(() => googleApi.isSignedIn())
|
|
|
|
.then(isSignedIn => {
|
|
|
|
if (isSignedIn) {
|
2018-08-10 10:30:00 +00:00
|
|
|
dispatch(setGoogleAPIState(GOOGLE_API_STATES.SIGNED_IN));
|
2018-08-02 21:56:36 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes a request for a list of all YouTube broadcasts associated with
|
|
|
|
* user currently signed in to the Google API Client Library.
|
|
|
|
*
|
|
|
|
* @returns {function(): (Promise<*>|Promise<any[] | never>)}
|
|
|
|
*/
|
|
|
|
export function requestAvailableYouTubeBroadcasts() {
|
|
|
|
return () =>
|
|
|
|
googleApi.requestAvailableYouTubeBroadcasts()
|
|
|
|
.then(response => {
|
|
|
|
// Takes in a list of broadcasts from the YouTube API,
|
|
|
|
// removes dupes, removes broadcasts that cannot get a stream key,
|
|
|
|
// and parses the broadcasts into flat objects.
|
|
|
|
const broadcasts = response.result.items;
|
|
|
|
|
|
|
|
const parsedBroadcasts = {};
|
|
|
|
|
|
|
|
for (let i = 0; i < broadcasts.length; i++) {
|
|
|
|
const broadcast = broadcasts[i];
|
|
|
|
const boundStreamID = broadcast.contentDetails.boundStreamId;
|
|
|
|
|
|
|
|
if (boundStreamID && !parsedBroadcasts[boundStreamID]) {
|
|
|
|
parsedBroadcasts[boundStreamID] = {
|
|
|
|
boundStreamID,
|
|
|
|
id: broadcast.id,
|
|
|
|
status: broadcast.status.lifeCycleStatus,
|
|
|
|
title: broadcast.snippet.title
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Object.values(parsedBroadcasts);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches the stream key for a YouTube broadcast and updates the internal
|
|
|
|
* state to display the associated stream key as being entered.
|
|
|
|
*
|
|
|
|
* @param {string} boundStreamID - The bound stream ID associated with the
|
|
|
|
* broadcast from which to get the stream key.
|
|
|
|
* @returns {function(): (Promise<*>|Promise<{
|
|
|
|
* streamKey: (*|string),
|
|
|
|
* selectedBoundStreamID: *} | never>)}
|
|
|
|
*/
|
|
|
|
export function requestLiveStreamsForYouTubeBroadcast(boundStreamID: string) {
|
|
|
|
return () =>
|
|
|
|
googleApi.requestLiveStreamsForYouTubeBroadcast(boundStreamID)
|
|
|
|
.then(response => {
|
|
|
|
const broadcasts = response.result.items;
|
|
|
|
const streamName = broadcasts
|
|
|
|
&& broadcasts[0]
|
|
|
|
&& broadcasts[0].cdn.ingestionInfo.streamName;
|
|
|
|
const streamKey = streamName || '';
|
|
|
|
|
|
|
|
return {
|
|
|
|
streamKey,
|
|
|
|
selectedBoundStreamID: boundStreamID
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-08-10 10:30:00 +00:00
|
|
|
/**
|
|
|
|
* Sets the current Google API state.
|
|
|
|
*
|
|
|
|
* @param {number} googleAPIState - The state to be set.
|
|
|
|
* @param {Object} googleResponse - The last response from Google.
|
|
|
|
* @returns {{
|
|
|
|
* type: SET_GOOGLE_API_STATE,
|
|
|
|
* googleAPIState: number
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function setGoogleAPIState(
|
|
|
|
googleAPIState: number, googleResponse: ?Object) {
|
|
|
|
return {
|
|
|
|
type: SET_GOOGLE_API_STATE,
|
|
|
|
googleAPIState,
|
|
|
|
googleResponse
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-08-02 21:56:36 +00:00
|
|
|
/**
|
|
|
|
* Forces the Google web client application to prompt for a sign in, such as
|
|
|
|
* when changing account, and will then fetch available YouTube broadcasts.
|
|
|
|
*
|
|
|
|
* @returns {function(): (Promise<*>|Promise<{
|
|
|
|
* streamKey: (*|string),
|
|
|
|
* selectedBoundStreamID: *} | never>)}
|
|
|
|
*/
|
|
|
|
export function showAccountSelection() {
|
|
|
|
return () =>
|
|
|
|
googleApi.showAccountSelection();
|
|
|
|
}
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prompts the participant to sign in to the Google API Client Library.
|
|
|
|
*
|
2019-03-19 15:42:25 +00:00
|
|
|
* @returns {function(Dispatch<any>): Promise<string | never>}
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
*/
|
|
|
|
export function signIn() {
|
2019-03-19 15:42:25 +00:00
|
|
|
return (dispatch: Dispatch<any>) => googleApi.get()
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
.then(() => googleApi.signInIfNotSignedIn())
|
|
|
|
.then(() => dispatch({
|
|
|
|
type: SET_GOOGLE_API_STATE,
|
|
|
|
googleAPIState: GOOGLE_API_STATES.SIGNED_IN
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logs out the user.
|
|
|
|
*
|
2019-03-19 15:42:25 +00:00
|
|
|
* @returns {function(Dispatch<any>): Promise<string | never>}
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
*/
|
|
|
|
export function signOut() {
|
2019-03-19 15:42:25 +00:00
|
|
|
return (dispatch: Dispatch<any>) =>
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
googleApi.get()
|
|
|
|
.then(() => googleApi.signOut())
|
|
|
|
.then(() => {
|
|
|
|
dispatch({
|
|
|
|
type: SET_GOOGLE_API_STATE,
|
|
|
|
googleAPIState: GOOGLE_API_STATES.LOADED
|
|
|
|
});
|
|
|
|
dispatch({
|
|
|
|
type: SET_GOOGLE_API_PROFILE,
|
|
|
|
profileEmail: ''
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the profile data that is currently used.
|
|
|
|
*
|
2019-03-19 15:42:25 +00:00
|
|
|
* @returns {function(Dispatch<any>): Promise<string | never>}
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
*/
|
|
|
|
export function updateProfile() {
|
2019-03-19 15:42:25 +00:00
|
|
|
return (dispatch: Dispatch<any>) => googleApi.get()
|
Google & Microsoft calendar API integration (#3340)
* Refactor calendar-sync feature to be loaded on web.
For the web part it just adds new property to enable/disable calendar web integration, disabled by default.
* Initial implementation of retrieving google calendar events.
* Initial implementation of retrieving microsoft calendar events.
* Fixes comments.
* Rework to use the promise part of microsoft-graph-client api.
* Moves dispatching some actions, fixing comments.
* Makes sure we do not initializeClient google-api client multiple times.
* Do not try to login when fetching calendar entries.
The case where there is a calendar type google selected, but not logged in, trying to login on loading welcome page will show a warning that it tried to open a popup, which was denied by browser.
* Updates profile display data on sign in.
* Propagate google-api state to calendar-sync only if we use google cal.
* Adds sign out action.
* Clears the event listener when the popup closes.
* Clears calendarIntegrationInstance on signOut.
* WIP: UI for calendar settings, refactor auth flows
* Clean up some unused constants, functions and exports.
* break circular dependency of function and constant
* Exports only isCalendarEnabled from functions.
* Checks isSignedIn when doing fetchCalendarEntries on web.
* address comments
List microsoftApiApplicationClientID in undocument config.
remove unused SET_CALENDAR_TYPE action
use helper for calendar enabled in bootstrap
reorder actions
reorder imports
change order of signin -> set type -> update profile
add logging for signout error
reword setting dialog desc to avoid redundancy
add jsdoc to microsoft button props
reorder calendar constants
move default state to reducer (not reused anywhere)
update comment about calendar-sync due to removal of getCalendarState
update comment for getCalendarIntegration
remove vague comment
alpha order reducer, return default state on reset
alpha order persistence registry
remove unnecessary getType from apis
update comments in microsoftCalendar
alpha order google-api exports, use api.get in loadGoogleAPI
set jsdoc for google signin props
alpha order googleapi methods
fix calendartab docs
* Moves fetching calendar from APP_WILL_MOUNT to SET_CONFIG.
The web part needs configuration in order to refresh tokens (Microsoft).
* Fixes storing token expire time and refreshing tokens in Microsoft impl.
* Address comments
updateProfile changed to getCurrentEmail
rename result to results
stop storing integration in redux, store if ready for use
use existing helpers to parse redirect url
* update jsdocs, get google app id from redux
* clear integration instead of actual sign out
2018-08-15 20:11:54 +00:00
|
|
|
.then(() => googleApi.signInIfNotSignedIn())
|
|
|
|
.then(() => dispatch({
|
|
|
|
type: SET_GOOGLE_API_STATE,
|
|
|
|
googleAPIState: GOOGLE_API_STATES.SIGNED_IN
|
|
|
|
}))
|
|
|
|
.then(() => googleApi.getCurrentUserProfile())
|
|
|
|
.then(profile => {
|
|
|
|
dispatch({
|
|
|
|
type: SET_GOOGLE_API_PROFILE,
|
|
|
|
profileEmail: profile.getEmail()
|
|
|
|
});
|
|
|
|
|
|
|
|
return profile.getEmail();
|
|
|
|
});
|
|
|
|
}
|
2018-08-17 19:34:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the calendar event and adds a location and text.
|
|
|
|
*
|
|
|
|
* @param {string} id - The event id to update.
|
|
|
|
* @param {string} calendarId - The calendar id to use.
|
|
|
|
* @param {string} location - The location to add to the event.
|
2019-03-19 15:42:25 +00:00
|
|
|
* @returns {function(Dispatch<any>): Promise<string | never>}
|
2018-08-17 19:34:41 +00:00
|
|
|
*/
|
|
|
|
export function updateCalendarEvent(
|
|
|
|
id: string, calendarId: string, location: string) {
|
2019-03-19 15:42:25 +00:00
|
|
|
return (dispatch: Dispatch<any>, getState: Function) =>
|
2018-09-07 22:48:58 +00:00
|
|
|
getShareInfoText(getState(), location)
|
|
|
|
.then(text =>
|
2018-08-17 19:34:41 +00:00
|
|
|
googleApi._updateCalendarEntry(id, calendarId, location, text));
|
|
|
|
}
|