mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce competition for telemetry preference tab
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
b7fe3deaa1
commit
0dc45c7ce9
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { preferenceItemInjectionToken } from "../../preference-item-injection-token";
|
||||||
|
import { AutomaticErrorReporting } from "./automatic-error-reporting";
|
||||||
|
import sentryDataSourceNameInjectable from "../../../../../../common/vars/sentry-dsn-url.injectable";
|
||||||
|
|
||||||
|
const automaticErrorReportingPreferenceItemInjectable = getInjectable({
|
||||||
|
id: "automatic-error-reporting-preference-item",
|
||||||
|
|
||||||
|
instantiate: (di) => {
|
||||||
|
const sentryDnsUrl = di.inject(sentryDataSourceNameInjectable);
|
||||||
|
|
||||||
|
return {
|
||||||
|
kind: "item" as const,
|
||||||
|
id: "automatic-error-reporting",
|
||||||
|
parentId: "telemetry-page",
|
||||||
|
orderNumber: 20,
|
||||||
|
Component: AutomaticErrorReporting,
|
||||||
|
isShown: !!sentryDnsUrl,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: preferenceItemInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default automaticErrorReportingPreferenceItemInjectable;
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import React from "react";
|
||||||
|
import { SubTitle } from "../../../../../../renderer/components/layout/sub-title";
|
||||||
|
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||||
|
import type { UserStore } from "../../../../../../common/user-store";
|
||||||
|
import userStoreInjectable from "../../../../../../common/user-store/user-store.injectable";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
|
import { Checkbox } from "../../../../../../renderer/components/checkbox";
|
||||||
|
|
||||||
|
interface Dependencies {
|
||||||
|
userStore: UserStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NonInjectedAutomaticErrorReporting = observer(({ userStore }: Dependencies) => (
|
||||||
|
<div
|
||||||
|
id="sentry"
|
||||||
|
className="small"
|
||||||
|
data-testid="telemetry-preferences-for-automatic-error-reporting"
|
||||||
|
>
|
||||||
|
<SubTitle title="Automatic Error Reporting" />
|
||||||
|
<Checkbox
|
||||||
|
label="Allow automatic error reporting"
|
||||||
|
value={userStore.allowErrorReporting}
|
||||||
|
onChange={(value) => (userStore.allowErrorReporting = value)}
|
||||||
|
/>
|
||||||
|
<div className="hint">
|
||||||
|
<span>
|
||||||
|
Automatic error reports provide vital information about issues and
|
||||||
|
application crashes. It is highly recommended to keep this feature
|
||||||
|
enabled to ensure fast turnaround for issues you might encounter.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
|
||||||
|
export const AutomaticErrorReporting = withInjectables<Dependencies>(
|
||||||
|
NonInjectedAutomaticErrorReporting,
|
||||||
|
|
||||||
|
{
|
||||||
|
getProps: (di) => ({
|
||||||
|
userStore: di.inject(userStoreInjectable),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
);
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import React from "react";
|
||||||
|
import type { PreferenceItemComponent } from "../preference-item-injection-token";
|
||||||
|
|
||||||
|
export const TelemetryPage: PreferenceItemComponent = ({ children }) => (
|
||||||
|
<div>
|
||||||
|
<h2 data-testid="telemetry-header">Telemetry</h2>
|
||||||
|
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { preferenceItemInjectionToken } from "../preference-item-injection-token";
|
||||||
|
import { TelemetryPage } from "./telemetry-page";
|
||||||
|
|
||||||
|
const telemetryPreferencePageInjectable = getInjectable({
|
||||||
|
id: "telemetry-preference-page",
|
||||||
|
|
||||||
|
instantiate: () => ({
|
||||||
|
kind: "page" as const,
|
||||||
|
id: "telemetry-page",
|
||||||
|
parentId: "telemetry-tab",
|
||||||
|
orderNumber: 0,
|
||||||
|
Component: TelemetryPage,
|
||||||
|
}),
|
||||||
|
|
||||||
|
injectionToken: preferenceItemInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default telemetryPreferencePageInjectable;
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { preferenceItemInjectionToken } from "../preference-item-injection-token";
|
||||||
|
|
||||||
|
const telemetryPreferenceTabInjectable = getInjectable({
|
||||||
|
id: "telemetry-preference-tab",
|
||||||
|
|
||||||
|
instantiate: () => ({
|
||||||
|
kind: "tab" as const,
|
||||||
|
id: "telemetry-tab",
|
||||||
|
parentId: "preference-tabs" as const,
|
||||||
|
pathId: "telemetry",
|
||||||
|
testId: "terminal-preferences-page",
|
||||||
|
label: "Telemetry",
|
||||||
|
orderNumber: 20,
|
||||||
|
}),
|
||||||
|
|
||||||
|
injectionToken: preferenceItemInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default telemetryPreferenceTabInjectable;
|
||||||
Loading…
Reference in New Issue
Block a user