-
Notifications
You must be signed in to change notification settings - Fork 470
Expand file tree
/
Copy pathapp.tsx
More file actions
97 lines (90 loc) · 3.63 KB
/
app.tsx
File metadata and controls
97 lines (90 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { createSelector } from 'reselect';
import { getDataSource, getSelectedTab } from './url-state';
import { getZipFileState } from './zipped-profiles';
import type {
AppState,
AppViewState,
UrlSetupPhase,
Selector,
CssPixels,
ThreadsKey,
ExperimentalFlags,
UploadedProfileInformation,
} from 'firefox-profiler/types';
import type { TabSlug } from 'firefox-profiler/app-logic/tabs-handling';
import type {
BrowserConnectionStatus,
BrowserConnection,
} from 'firefox-profiler/app-logic/browser-connection';
/**
* Simple selectors into the app state.
*/
export const getApp: Selector<AppState> = (state) => state.app;
export const getView: Selector<AppViewState> = (state) => getApp(state).view;
export const getUrlSetupPhase: Selector<UrlSetupPhase> = (state) =>
getApp(state).urlSetupPhase;
export const getHasZoomedViaMousewheel: Selector<boolean> = (state) => {
return getApp(state).hasZoomedViaMousewheel;
};
export const getIsSidebarOpen: Selector<boolean> = (state) =>
getApp(state).isSidebarOpenPerPanel[getSelectedTab(state)];
export const getLastVisibleThreadTabSlug: Selector<TabSlug> = (state) =>
getApp(state).lastVisibleThreadTabSlug;
export const getTrackThreadHeights: Selector<{
[key: ThreadsKey]: CssPixels;
}> = (state) => getApp(state).trackThreadHeights;
export const getIsNewlyPublished: Selector<boolean> = (state) =>
getApp(state).isNewlyPublished;
export const getExperimental: Selector<ExperimentalFlags> = (state) =>
getApp(state).experimental;
export const getBrowserConnectionStatus: Selector<BrowserConnectionStatus> = (
state
) => getApp(state).browserConnectionStatus;
export const getBrowserConnection: Selector<BrowserConnection | null> =
createSelector(getBrowserConnectionStatus, (status) =>
status.status === 'ESTABLISHED' ? status.browserConnection : null
);
export const getIsEventDelayTracksEnabled: Selector<boolean> = (state) =>
getExperimental(state).eventDelayTracks;
export const getIsExperimentalCPUGraphsEnabled: Selector<boolean> = (state) =>
getExperimental(state).cpuGraphs;
export const getIsExperimentalProcessCPUTracksEnabled: Selector<boolean> = (
state
) => getExperimental(state).processCPUTracks;
export const getIsDragAndDropDragging: Selector<boolean> = (state) =>
getApp(state).isDragAndDropDragging;
export const getIsDragAndDropOverlayRegistered: Selector<boolean> = (state) =>
getApp(state).isDragAndDropOverlayRegistered;
export const getCurrentProfileUploadedInformation: Selector<
UploadedProfileInformation | null
> = (state) => getApp(state).currentProfileUploadedInformation;
/**
* This selector lets us know if it is safe to load a new profile. If
* the app is already busy loading a profile, this selector returns
* false.
*
* Used by the drag and drop component in order to determine if it can
* load a dropped profile file.
*/
export const getIsNewProfileLoadAllowed: Selector<boolean> = createSelector(
getView,
getDataSource,
getZipFileState,
(view, dataSource, zipFileState) => {
const appPhase = view.phase;
const zipPhase = zipFileState.phase;
const isLoading =
(appPhase === 'INITIALIZING' && dataSource !== 'none') ||
zipPhase === 'PROCESS_PROFILE_FROM_ZIP_FILE';
return !isLoading;
}
);
/**
* Returns the indexes of categories that are opened in the sidebar,
* for every category
*/
export const getSidebarOpenCategories: Selector<Map<string, Set<number>>> =
createSelector(getApp, (app) => app.sidebarOpenCategories);