github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/redux/reducers/continuous/state.ts (about) 1 import type { Profile, Groups } from '@pyroscope/models/src'; 2 import type { Timeline } from '@webapp/models/timeline'; 3 import type { Annotation } from '@webapp/models/annotation'; 4 import type { App } from '@webapp/models/app'; 5 6 type NewAnnotationState = 7 | { 8 type: 'pristine'; 9 } 10 | { type: 'saving' }; 11 12 type SingleView = 13 | { type: 'pristine'; profile?: Profile } 14 | { type: 'loading'; profile?: Profile } 15 | { 16 type: 'loaded'; 17 timeline: Timeline; 18 profile: Profile; 19 annotations: Annotation[]; 20 } 21 | { 22 type: 'reloading'; 23 timeline: Timeline; 24 profile: Profile; 25 annotations: Annotation[]; 26 }; 27 28 type TagExplorerView = GroupByType & 29 GroupsLoadingType & 30 ActiveProfileType & { 31 annotations: Annotation[]; 32 }; 33 34 type GroupByType = { 35 groupByTag: string; 36 groupByTagValue: string; 37 }; 38 39 type GroupsLoadingType = 40 | { 41 groupsLoadingType: 'pristine'; 42 groups: Groups; 43 } 44 | { 45 groupsLoadingType: 'loading'; 46 groups: Groups; 47 } 48 | { 49 groupsLoadingType: 'loaded'; 50 groups: Groups; 51 } 52 | { 53 groupsLoadingType: 'reloading'; 54 groups: Groups; 55 }; 56 57 type ActiveProfileType = 58 | { 59 activeTagProfileLoadingType: 'pristine'; 60 } 61 | { 62 activeTagProfileLoadingType: 'loading'; 63 } 64 | { 65 activeTagProfileLoadingType: 'loaded'; 66 activeTagProfile: Profile; 67 } 68 | { 69 activeTagProfileLoadingType: 'reloading'; 70 activeTagProfile: Profile; 71 }; 72 73 type ComparisonView = { 74 left: 75 | { type: 'pristine'; profile?: Profile } 76 | { type: 'loading'; profile?: Profile } 77 | { type: 'loaded'; profile: Profile } 78 | { type: 'reloading'; profile: Profile }; 79 80 right: 81 | { type: 'pristine'; profile?: Profile } 82 | { type: 'loading'; profile?: Profile } 83 | { type: 'loaded'; profile: Profile } 84 | { type: 'reloading'; profile: Profile }; 85 86 comparisonMode: { 87 active: boolean; 88 period: { 89 label: string; 90 ms: number; 91 }; 92 }; 93 }; 94 95 type DiffView = 96 | { type: 'pristine'; profile?: Profile } 97 | { type: 'loading'; profile?: Profile } 98 | { type: 'loaded'; profile: Profile } 99 | { type: 'reloading'; profile: Profile }; 100 101 type TimelineState = 102 | { type: 'pristine'; timeline: Timeline } 103 | { type: 'loading'; timeline: Timeline } 104 | { type: 'reloading'; timeline: Timeline } 105 | { type: 'loaded'; timeline: Timeline; annotations: Annotation[] }; 106 107 type TagsData = 108 | { type: 'pristine' } 109 | { type: 'loading' } 110 | { type: 'failed' } 111 | { type: 'loaded'; values: string[] }; 112 113 // Tags really refer to each application 114 // Should we nest them to an application? 115 export type TagsState = 116 | { type: 'pristine'; tags: Record<string, TagsData> } 117 | { type: 'loading'; tags: Record<string, TagsData> } 118 | { 119 type: 'loaded'; 120 tags: Record<string, TagsData>; 121 from: number; 122 until: number; 123 } 124 | { type: 'failed'; tags: Record<string, TagsData> }; 125 126 // TODO 127 type appName = string; 128 type Tags = Record<appName, TagsState>; 129 130 export interface ContinuousState { 131 from: string; 132 until: string; 133 leftFrom: string; 134 leftUntil: string; 135 rightFrom: string; 136 rightUntil: string; 137 query: string; 138 leftQuery?: string; 139 rightQuery?: string; 140 maxNodes: string; 141 refreshToken?: string; 142 143 singleView: SingleView; 144 diffView: DiffView; 145 comparisonView: ComparisonView; 146 tagExplorerView: TagExplorerView; 147 newAnnotation: NewAnnotationState; 148 tags: Tags; 149 150 apps: 151 | { type: 'loaded'; data: App[] } 152 | { type: 'reloading'; data: App[] } 153 | { type: 'failed'; data: App[] }; 154 155 // Since both comparison and diff use the same timeline 156 // Makes sense storing them separately 157 leftTimeline: TimelineState; 158 rightTimeline: TimelineState; 159 }