Skip to content

Commit bade802

Browse files
committed
fix: update most UI types to account for readonly modifiers
1 parent dfd6068 commit bade802

File tree

28 files changed

+55
-53
lines changed

28 files changed

+55
-53
lines changed

site/src/components/ActiveUserChart/ActiveUserChart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ChartJS.register(
4242
const USER_LIMIT_DISPLAY_THRESHOLD = 60;
4343

4444
export interface ActiveUserChartProps {
45-
data: Array<{ date: string; amount: number }>;
45+
data: readonly ({ date: string; amount: number })[];
4646
interval: "day" | "week";
4747
userLimit: number | undefined;
4848
}

site/src/components/Timeline/Timeline.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TimelineDateRow } from "components/Timeline/TimelineDateRow";
44
type GetDateFn<TData> = (data: TData) => Date;
55

66
const groupByDate = <TData,>(
7-
items: TData[],
7+
items: readonly TData[],
88
getDate: GetDateFn<TData>,
99
): Record<string, TData[]> => {
1010
const itemsByDate: Record<string, TData[]> = {};
@@ -23,7 +23,7 @@ const groupByDate = <TData,>(
2323
};
2424

2525
export interface TimelineProps<TData> {
26-
items: TData[];
26+
items: readonly TData[];
2727
getDate: GetDateFn<TData>;
2828
row: (item: TData) => JSX.Element;
2929
}

site/src/contexts/ProxyContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface ProxyContextValue {
4141
// WorkspaceProxy[] is returned if the user is an admin. WorkspaceProxy extends Region with
4242
// more information about the proxy and the status. More information includes the error message if
4343
// the proxy is unhealthy.
44-
proxies?: Region[] | WorkspaceProxy[];
44+
proxies?: readonly Region[] | readonly WorkspaceProxy[];
4545
// isFetched is true when the 'proxies' api call is complete.
4646
isFetched: boolean;
4747
isLoading: boolean;
@@ -117,7 +117,7 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
117117
});
118118

119119
const { permissions } = useAuthenticated();
120-
const query = async (): Promise<Region[]> => {
120+
const query = async (): Promise<readonly Region[]> => {
121121
const endpoint = permissions.editWorkspaceProxies
122122
? getWorkspaceProxies
123123
: getWorkspaceProxyRegions;
@@ -218,7 +218,7 @@ export const useProxy = (): ProxyContextValue => {
218218
* If not, `primary` is always the best default.
219219
*/
220220
export const getPreferredProxy = (
221-
proxies: Region[],
221+
proxies: readonly Region[],
222222
selectedProxy?: Region,
223223
latencies?: Record<string, ProxyLatencyReport>,
224224
autoSelectBasedOnLatency = true,
@@ -245,7 +245,7 @@ export const getPreferredProxy = (
245245
};
246246

247247
const selectByLatency = (
248-
proxies: Region[],
248+
proxies: readonly Region[],
249249
latencies?: Record<string, ProxyLatencyReport>,
250250
): Region | undefined => {
251251
if (!latencies) {

site/src/contexts/useProxyLatency.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const proxyLatenciesReducer = (
3737
};
3838

3939
export const useProxyLatency = (
40-
proxies?: Region[],
40+
proxies?: readonly Region[],
4141
): {
4242
// Refetch can be called to refetch the proxy latencies.
4343
// Until the new values are loaded, the old values will still be used.
@@ -265,7 +265,7 @@ const updateStoredLatencies = (action: ProxyLatencyAction): void => {
265265
// garbageCollectStoredLatencies will remove any latencies that are older then 1 week or latencies of proxies
266266
// that no longer exist. This is intended to keep the size of local storage down.
267267
const garbageCollectStoredLatencies = (
268-
regions: Region[],
268+
regions: readonly Region[],
269269
maxStored: number,
270270
): void => {
271271
const latencies = loadStoredLatencies();
@@ -282,7 +282,7 @@ const garbageCollectStoredLatencies = (
282282

283283
const cleanupLatencies = (
284284
stored: Record<string, ProxyLatencyReport[]>,
285-
regions: Region[],
285+
regions: readonly Region[],
286286
now: Date,
287287
maxStored: number,
288288
): Record<string, ProxyLatencyReport[]> => {

site/src/modules/dashboard/LicenseBanner/LicenseBannerView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const styles = {
2727
} satisfies Record<string, Interpolation<Theme>>;
2828

2929
export interface LicenseBannerViewProps {
30-
errors: string[];
31-
warnings: string[];
30+
errors: readonly string[];
31+
warnings: readonly string[];
3232
}
3333

3434
export const LicenseBannerView: FC<LicenseBannerViewProps> = ({

site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { UserDropdownContent } from "./UserDropdownContent";
1515
export interface UserDropdownProps {
1616
user: TypesGen.User;
1717
buildInfo?: TypesGen.BuildInfoResponse;
18-
supportLinks?: TypesGen.LinkConfig[];
18+
supportLinks?: readonly TypesGen.LinkConfig[];
1919
onSignOut: () => void;
2020
children?: ReactNode;
2121
}

site/src/modules/dashboard/Navbar/UserDropdown/UserDropdownContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const styles = {
8383
export interface UserDropdownContentProps {
8484
user: TypesGen.User;
8585
buildInfo?: TypesGen.BuildInfoResponse;
86-
supportLinks?: TypesGen.LinkConfig[];
86+
supportLinks?: readonly TypesGen.LinkConfig[];
8787
onSignOut: () => void;
8888
}
8989

site/src/modules/resources/AgentLogs/AgentLogs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type AgentLogsProps = Omit<
2020
ComponentProps<typeof List>,
2121
"children" | "itemSize" | "itemCount"
2222
> & {
23-
logs: LineWithID[];
24-
sources: WorkspaceAgentLogSource[];
23+
logs: readonly LineWithID[];
24+
sources: readonly WorkspaceAgentLogSource[];
2525
};
2626

2727
export const AgentLogs = forwardRef<List, AgentLogsProps>(

site/src/modules/resources/PortForwardButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const getValidationSchema = (): Yup.AnyObjectSchema =>
116116
});
117117

118118
interface PortForwardPopoverViewProps extends PortForwardButtonProps {
119-
listeningPorts?: WorkspaceAgentListeningPort[];
119+
listeningPorts?: readonly WorkspaceAgentListeningPort[];
120120
portSharingExperimentEnabled: boolean;
121121
portSharingControlsEnabled: boolean;
122122
}

site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface VSCodeDesktopButtonProps {
1515
workspaceName: string;
1616
agentName?: string;
1717
folderPath?: string;
18-
displayApps: DisplayApp[];
18+
displayApps: readonly DisplayApp[];
1919
}
2020

2121
type VSCodeVariant = "vscode" | "vscode-insiders";

0 commit comments

Comments
 (0)