Skip to content

Commit a1b01ad

Browse files
added coderabbit authentication
1 parent 8c75e4f commit a1b01ad

File tree

4 files changed

+41
-32
lines changed

4 files changed

+41
-32
lines changed

.betterer.results

+2-18
Original file line numberDiff line numberDiff line change
@@ -1579,24 +1579,8 @@ exports[`better eslint`] = {
15791579
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
15801580
],
15811581
"public/app/core/services/backend_srv.ts:5381": [
1582-
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
1583-
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
1584-
[0, 0, 0, "Do not use any type assertions.", "2"],
1585-
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
1586-
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
1587-
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
1588-
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
1589-
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
1590-
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
1591-
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
1592-
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
1593-
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
1594-
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
1595-
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
1596-
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
1597-
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
1598-
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
1599-
[0, 0, 0, "Unexpected any. Specify a different type.", "17"]
1582+
[0, 0, 0, "Do not use any type assertions.", "0"],
1583+
[0, 0, 0, "Do not use any type assertions.", "1"]
16001584
],
16011585
"public/app/core/services/context_srv.ts:5381": [
16021586
[0, 0, 0, "Do not use any type assertions.", "0"],

packages/grafana-ui/src/components/DateTimePickers/TimeRangePicker.tsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,25 @@ export function TimeRangePicker(props: TimeRangePickerProps) {
166166
/>
167167
)}
168168

169-
{/* <Tooltip content={ZoomOutTooltip} placement="bottom-start"> */}
170-
<ToolbarButton
171-
aria-label={t('time-picker.range-picker.zoom-out-button', 'Zoom out time range')}
172-
onClick={onZoom}
173-
icon="search-minus"
174-
variant={variant}
175-
/>
176-
{/* </Tooltip> */}
169+
<Tooltip content={ZoomOutTooltip} placement="bottom-start">
170+
<ToolbarButton
171+
aria-label={t('time-picker.range-picker.zoom-out-button', 'Zoom out time range')}
172+
onClick={onZoom}
173+
icon="search-minus"
174+
variant={variant}
175+
/>
176+
</Tooltip>
177177
</ButtonGroup>
178178
);
179179
}
180180

181181
TimeRangePicker.displayName = 'TimeRangePicker';
182182

183-
// const ZoomOutTooltip = () => (
184-
// <Trans i18nKey="time-picker.range-picker.zoom-out-tooltip">
185-
// Time range zoom out <br /> CTRL+Z
186-
// </Trans>
187-
// );
183+
const ZoomOutTooltip = () => (
184+
<Trans i18nKey="time-picker.range-picker.zoom-out-tooltip">
185+
Time range zoom out <br /> CTRL+Z
186+
</Trans>
187+
);
188188

189189
export const TimePickerTooltip = ({ timeRange, timeZone }: { timeRange: TimeRange; timeZone?: TimeZone }) => {
190190
const styles = useStyles2(getLabelStyles);

public/app/core/services/backend_srv.ts

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import { from, lastValueFrom, MonoTypeOperatorFunction, Observable, Subject, Subscription, throwError } from 'rxjs';
23
import { fromFetch } from 'rxjs/fetch';
34
import {
@@ -170,6 +171,18 @@ export class BackendSrv implements BackendService {
170171
return lastValueFrom(this.fetch(options));
171172
}
172173

174+
private getCodeRabbitOrg(): { id: string } | null {
175+
const selectedOrgStorage = sessionStorage.getItem('selected_org');
176+
177+
try {
178+
return selectedOrgStorage ? (JSON.parse(selectedOrgStorage) as { id: string }) : null;
179+
} catch (e) {
180+
console.error('Failed to parse selected_org', selectedOrgStorage, 'error:', e);
181+
sessionStorage.removeItem('selected_org');
182+
return null;
183+
}
184+
}
185+
173186
private parseRequestOptions(options: BackendSrvRequest): BackendSrvRequest {
174187
const orgId = this.dependencies.contextSrv.user?.orgId;
175188

@@ -182,10 +195,22 @@ export class BackendSrv implements BackendService {
182195
options.headers['X-Grafana-Org-Id'] = orgId;
183196
}
184197

198+
const codeRabbitOrg = this.getCodeRabbitOrg();
199+
if (codeRabbitOrg) {
200+
options.headers = options.headers ?? {};
201+
options.headers['x-coderabbit-organization'] = codeRabbitOrg.id;
202+
}
203+
185204
if (options.url.startsWith('/')) {
186205
options.url = options.url.substring(1);
187206
}
188207

208+
const codeRabbitToken = sessionStorage.getItem('accessToken');
209+
if (codeRabbitToken) {
210+
options.headers = options.headers ?? {};
211+
options.headers['x-coderabbit-token'] = `Bearer ${codeRabbitToken}`;
212+
}
213+
189214
if (options.headers?.Authorization) {
190215
options.headers['X-DS-Authorization'] = options.headers.Authorization;
191216
delete options.headers.Authorization;

public/microfrontends/fn_dashboard/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<script nonce="" src="../../../public/build/runtime~fn_dashboard.512db17f9b8f66891b2c.js" type="text/javascript"></script>
2121

22-
<script nonce="" src="../../../public/build/fn_dashboard.8335d1e4c1154649fa53.js" type="text/javascript"></script>
22+
<script nonce="" src="../../../public/build/fn_dashboard.bb3af0c3464201961162.js" type="text/javascript"></script>
2323

2424
</body>
2525
</html>

0 commit comments

Comments
 (0)