/
protocol.ts
182 lines (158 loc) · 5.36 KB
/
protocol.ts
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import type { GraphRow, Remote } from '@gitkraken/gitkraken-components';
import type { DateStyle, GraphColumnConfig } from '../../../config';
import type { RepositoryVisibility } from '../../../git/gitProvider';
import type { GitGraphRowType } from '../../../git/models/graph';
import type { SearchQuery } from '../../../git/search';
import type { Subscription } from '../../../subscription';
import type { DateTimeFormat } from '../../../system/date';
import { IpcCommandType, IpcNotificationType } from '../../../webviews/protocol';
export interface State {
repositories?: GraphRepository[];
selectedRepository?: string;
selectedRepositoryVisibility?: RepositoryVisibility;
selectedRows?: { [id: string]: true };
subscription?: Subscription;
allowed: boolean;
avatars?: { [email: string]: string };
loading?: boolean;
rows?: GraphRow[];
paging?: GraphPaging;
config?: GraphComponentConfig;
nonce?: string;
previewBanner?: boolean;
trialBanner?: boolean;
// Props below are computed in the webview (not passed)
mixedColumnColors?: Record<string, string>;
searchResults?: DidSearchCommitsParams['results'];
}
export interface GraphPaging {
startingCursor?: string;
hasMore: boolean;
}
export interface GraphRepository {
formattedName: string;
id: string;
name: string;
path: string;
}
export interface GraphCommitIdentity {
name: string;
email: string | undefined;
date: number;
}
export interface GraphCommit {
sha: string;
author: GraphCommitIdentity;
message: string;
parents: string[];
committer: GraphCommitIdentity;
type: GitGraphRowType;
avatarUrl: string | undefined;
}
export type GraphRemote = Remote;
export type GraphTag = Record<string, any>;
export type GraphBranch = Record<string, any>;
export interface GraphComponentConfig {
avatars?: boolean;
columns?: Record<string, GraphColumnConfig>;
dateFormat: DateTimeFormat | string;
dateStyle: DateStyle;
enableMultiSelection?: boolean;
highlightRowsOnRefHover?: boolean;
shaLength?: number;
}
export interface UpdateStateCallback {
(state: State): void;
}
// Commands
export interface DismissBannerParams {
key: 'preview' | 'trial';
}
export const DismissBannerCommandType = new IpcCommandType<DismissBannerParams>('graph/dismissBanner');
export interface EnsureCommitParams {
id: string;
select?: boolean;
}
export const EnsureCommitCommandType = new IpcCommandType<EnsureCommitParams>('graph/ensureCommit');
export interface GetMissingAvatarsParams {
emails: { [email: string]: string };
}
export const GetMissingAvatarsCommandType = new IpcCommandType<GetMissingAvatarsParams>('graph/getMissingAvatars');
export interface GetMoreCommitsParams {
sha?: string;
}
export const GetMoreCommitsCommandType = new IpcCommandType<GetMoreCommitsParams>('graph/getMoreCommits');
export interface SearchCommitsParams {
search?: SearchQuery;
limit?: number;
more?: boolean;
}
export const SearchCommitsCommandType = new IpcCommandType<SearchCommitsParams>('graph/searchCommits');
export interface UpdateColumnParams {
name: string;
config: GraphColumnConfig;
}
export const UpdateColumnCommandType = new IpcCommandType<UpdateColumnParams>('graph/update/column');
export interface UpdateSelectedRepositoryParams {
path: string;
}
export const UpdateSelectedRepositoryCommandType = new IpcCommandType<UpdateSelectedRepositoryParams>(
'graph/update/repositorySelection',
);
export interface UpdateSelectionParams {
selection: { id: string; type: GitGraphRowType }[];
}
export const UpdateSelectionCommandType = new IpcCommandType<UpdateSelectionParams>('graph/update/selection');
// Notifications
export interface DidChangeParams {
state: State;
}
export const DidChangeNotificationType = new IpcNotificationType<DidChangeParams>('graph/didChange');
export interface DidChangeGraphConfigurationParams {
config: GraphComponentConfig;
}
export const DidChangeGraphConfigurationNotificationType = new IpcNotificationType<DidChangeGraphConfigurationParams>(
'graph/configuration/didChange',
);
export interface DidChangeSubscriptionParams {
subscription: Subscription;
allowed: boolean;
}
export const DidChangeSubscriptionNotificationType = new IpcNotificationType<DidChangeSubscriptionParams>(
'graph/subscription/didChange',
);
export interface DidChangeAvatarsParams {
avatars: { [email: string]: string };
}
export const DidChangeAvatarsNotificationType = new IpcNotificationType<DidChangeAvatarsParams>(
'graph/avatars/didChange',
);
export interface DidChangeCommitsParams {
rows: GraphRow[];
avatars: { [email: string]: string };
selectedRows?: { [id: string]: true };
paging?: GraphPaging;
}
export const DidChangeCommitsNotificationType = new IpcNotificationType<DidChangeCommitsParams>(
'graph/commits/didChange',
);
export interface DidChangeSelectionParams {
selection: { [id: string]: true };
}
export const DidChangeSelectionNotificationType = new IpcNotificationType<DidChangeSelectionParams>(
'graph/selection/didChange',
);
export interface DidEnsureCommitParams {
id?: string;
selected?: boolean;
}
export const DidEnsureCommitNotificationType = new IpcNotificationType<DidEnsureCommitParams>(
'graph/commits/didEnsureCommit',
);
export interface DidSearchCommitsParams {
results: { ids: { [sha: string]: number }; paging?: { hasMore: boolean } } | undefined;
selectedRows?: { [id: string]: true };
}
export const DidSearchCommitsNotificationType = new IpcNotificationType<DidSearchCommitsParams>(
'graph/commits/didSearch',
);