- Notifications
You must be signed in to change notification settings - Fork1.1k
fix(site): add defensive access to entitlement features#21381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Changes fromall commits
790fc251e7b83ad63489345a8253ac76fc45e0c9f49d48dac030bf66ad4ea7dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { MockLicenseResponse } from "testHelpers/entities"; | ||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
| import LicensesSettingsPage from "./LicensesSettingsPage"; | ||
| const meta: Meta<typeof LicensesSettingsPage> = { | ||
| title: "pages/DeploymentSettingsPage/LicensesSettingsPage", | ||
| component: LicensesSettingsPage, | ||
| parameters: { | ||
| queries: [ | ||
| { key: ["licenses"], data: MockLicenseResponse }, | ||
| { key: ["insights", "userStatusCounts"], data: { active: [] } }, | ||
| ], | ||
| }, | ||
| }; | ||
| export default meta; | ||
| type Story = StoryObj<typeof LicensesSettingsPage>; | ||
| export const WithoutUserLimitFeature: Story = { | ||
| parameters: { | ||
| queries: [ | ||
| { key: ["entitlements"], data: { features: {} } }, | ||
| { key: ["licenses"], data: MockLicenseResponse }, | ||
| { key: ["insights", "userStatusCounts"], data: { active: [] } }, | ||
| ], | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -77,8 +77,8 @@ const LicensesSettingsPage: FC = () => { | |||||||||||||||||
| showConfetti={confettiOn} | |||||||||||||||||
| isLoading={isLoading} | |||||||||||||||||
| isRefreshing={refreshEntitlementsMutation.isPending} | |||||||||||||||||
| userLimitActual={entitlementsQuery.data?.features.user_limit?.actual} | |||||||||||||||||
| userLimitLimit={entitlementsQuery.data?.features.user_limit?.limit} | |||||||||||||||||
Comment on lines +80 to +81 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
This issue is that if this is enabled it might require a humongous amount of changes MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. TIL! I understand that it is something we definitely don't want to enable without wider refactor 😅 ? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. So I do not have a working "compilerOptions": {"noUncheckedIndexedAccess":true } How many failures are there when compiling? This is def beyond the scope of this PR though 😓 MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I involved Claude & mux in this exercise. Here are the results: Total: 257 errors, 89 files
I asked to create a draft for better picture (clauding now), but we would need more eyes on this anyway 😅 MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Here is the first draft:#21383 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Hahahaha I love how the way it solves this is by asserting (and thus breaking at run time anyway). 145 lines is not bad though, I'm guessing in some cases we can assert and in others we just "handle" the undefined | |||||||||||||||||
| licenses={licenses} | |||||||||||||||||
| isRemovingLicense={isRemovingLicense} | |||||||||||||||||
| removeLicense={(licenseId: number) => removeLicenseApi(licenseId)} | |||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,14 +2,12 @@ import { useTheme } from "@emotion/react"; | ||
| import LinearProgress from "@mui/material/LinearProgress"; | ||
| import Link from "@mui/material/Link"; | ||
| import { getErrorDetail, getErrorMessage } from "api/errors"; | ||
| import { | ||
| insightsTemplate, | ||
| insightsUserActivity, | ||
| insightsUserLatency, | ||
| } from "api/queries/insights"; | ||
| import type { | ||
| Template, | ||
| TemplateAppUsage, | ||
| TemplateInsightsResponse, | ||
| @@ -39,7 +37,6 @@ import { | ||
| TooltipContent, | ||
| TooltipTrigger, | ||
| } from "components/Tooltip/Tooltip"; | ||
| import { | ||
| CircleCheck as CircleCheckIcon, | ||
| CircleXIcon, | ||
| @@ -100,11 +97,6 @@ export default function TemplateInsightsPage() { | ||
| const userLatency = useQuery(insightsUserLatency(commonFilters)); | ||
| const userActivity = useQuery(insightsUserActivity(commonFilters)); | ||
| return ( | ||
| <> | ||
| <title>{getTemplatePageTitle("Insights", template)}</title> | ||
| @@ -123,7 +115,6 @@ export default function TemplateInsightsPage() { | ||
| userLatency={userLatency} | ||
| userActivity={userActivity} | ||
| interval={interval} | ||
| /> | ||
| </> | ||
| ); | ||
| @@ -215,7 +206,6 @@ interface TemplateInsightsPageViewProps { | ||
| data: UserActivityInsightsResponse | undefined; | ||
| error: unknown; | ||
| }; | ||
| controls: ReactNode; | ||
| interval: InsightsInterval; | ||
| } | ||
| @@ -224,7 +214,6 @@ export const TemplateInsightsPageView: FC<TemplateInsightsPageViewProps> = ({ | ||
| templateInsights, | ||
| userLatency, | ||
| userActivity, | ||
| controls, | ||
| interval, | ||
| }) => { | ||
| @@ -251,11 +240,6 @@ export const TemplateInsightsPageView: FC<TemplateInsightsPageViewProps> = ({ | ||
| <ActiveUsersPanel | ||
| css={{ gridColumn: "span 2" }} | ||
| interval={interval} | ||
Comment on lines -254 to -258 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Was this just passed tonothing? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Passed andunused 👍 | ||
| data={templateInsights.data?.interval_reports} | ||
| error={templateInsights.error} | ||
| /> | ||
| @@ -283,14 +267,12 @@ interface ActiveUsersPanelProps extends PanelProps { | ||
| data: TemplateInsightsResponse["interval_reports"] | undefined; | ||
| error: unknown; | ||
| interval: InsightsInterval; | ||
| } | ||
| const ActiveUsersPanel: FC<ActiveUsersPanelProps> = ({ | ||
| data, | ||
| error, | ||
| interval, | ||
| ...panelProps | ||
| }) => { | ||
| return ( | ||
Uh oh!
There was an error while loading.Please reload this page.