Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80eac73

Browse files
authored
chore: removeuseLocalStorage hook (#11712)
1 parentfa99f6a commit80eac73

File tree

17 files changed

+83
-92
lines changed

17 files changed

+83
-92
lines changed

‎coderd/externalauth/externalauth.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func (c *DeviceAuth) AuthorizeDevice(ctx context.Context) (*codersdk.ExternalAut
327327
casehttp.StatusTooManyRequests:
328328
returnnil,xerrors.New("rate limit hit, unable to authorize device. please try again later")
329329
default:
330-
returnnil,fmt.Errorf("status_code=%d: %w",resp.StatusCode,err)
330+
returnnil,xerrors.Errorf("status_code=%d: %w",resp.StatusCode,err)
331331
}
332332
}
333333
ifr.ErrorDescription!="" {

‎coderd/workspaceagents_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ func TestWorkspaceAgentExternalAuthListen(t *testing.T) {
16261626
cancel()
16271627
// We expect only 1
16281628
// In a failed test, you will likely see 9, as the last one
1629-
// getscancelled.
1629+
// getscanceled.
16301630
require.Equal(t,1,validateCalls,"validate calls duplicated on same token")
16311631
})
16321632
}

‎enterprise/coderd/proxyhealth/proxyhealth.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,17 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID
276276
caseerr==nil&&resp.StatusCode==http.StatusOK:
277277
err:=json.NewDecoder(resp.Body).Decode(&status.Report)
278278
iferr!=nil {
279-
isCoderErr:=fmt.Errorf("proxy url %q is not a coder proxy instance, verify the url is correct",reqURL)
279+
isCoderErr:=xerrors.Errorf("proxy url %q is not a coder proxy instance, verify the url is correct",reqURL)
280280
ifresp.Header.Get(codersdk.BuildVersionHeader)!="" {
281-
isCoderErr=fmt.Errorf("proxy url %q is a coder instance, but unable to decode the response payload. Could this be a primary coderd and not a proxy?",reqURL)
281+
isCoderErr=xerrors.Errorf("proxy url %q is a coder instance, but unable to decode the response payload. Could this be a primary coderd and not a proxy?",reqURL)
282282
}
283283

284284
// If the response is not json, then the user likely input a bad url that returns status code 200.
285285
// This is very common, since most webpages do return a 200. So let's improve the error message.
286286
ifnotJSONErr:=codersdk.ExpectJSONMime(resp);notJSONErr!=nil {
287287
err=errors.Join(
288288
isCoderErr,
289-
fmt.Errorf("attempted to query health at %q but got back the incorrect content type: %w",reqURL,notJSONErr),
289+
xerrors.Errorf("attempted to query health at %q but got back the incorrect content type: %w",reqURL,notJSONErr),
290290
)
291291

292292
status.Report.Errors= []string{
@@ -300,7 +300,7 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID
300300
status.Report.Errors= []string{
301301
errors.Join(
302302
isCoderErr,
303-
fmt.Errorf("received a status code 200, but failed to decode health report body: %w",err),
303+
xerrors.Errorf("received a status code 200, but failed to decode health report body: %w",err),
304304
).Error(),
305305
}
306306
status.Status=Unhealthy

‎enterprise/wsproxy/wsproxy.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func New(ctx context.Context, opts *Options) (*Server, error) {
159159
info,err:=client.SDKClient.BuildInfo(ctx)
160160
iferr!=nil {
161161
returnnil,fmt.Errorf("buildinfo: %w",errors.Join(
162-
fmt.Errorf("unable to fetch build info from primary coderd. Are you sure %q is a coderd instance?",opts.DashboardURL),
162+
xerrors.Errorf("unable to fetch build info from primary coderd. Are you sure %q is a coderd instance?",opts.DashboardURL),
163163
err,
164164
))
165165
}
-2.94 KB
Binary file not shown.

‎site/src/components/Abbr/Abbr.stories.tsx‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import{typePropsWithChildren}from"react";
21
importtype{Meta,StoryObj}from"@storybook/react";
32
import{Abbr}from"./Abbr";
43

5-
// Just here to make the abbreviated part more obvious in the component library
6-
constUnderline=({ children}:PropsWithChildren)=>(
7-
<spancss={{textDecoration:"underline dotted"}}>{children}</span>
8-
);
9-
104
constmeta:Meta<typeofAbbr>={
115
title:"components/Abbr",
126
component:Abbr,
@@ -34,9 +28,9 @@ export const InlinedShorthand: Story = {
3428
<pcss={{maxWidth:"40em"}}>
3529
The physical pain of getting bonked on the head with a cartoon mallet
3630
lasts precisely 593{" "}
37-
<Underline>
31+
<spancss={styles.underlined}>
3832
<Story/>
39-
</Underline>
33+
</span>
4034
. The emotional turmoil and complete embarrassment lasts forever.
4135
</p>
4236
),
@@ -51,9 +45,9 @@ export const Acronym: Story = {
5145
},
5246
decorators:[
5347
(Story)=>(
54-
<Underline>
48+
<spancss={styles.underlined}>
5549
<Story/>
56-
</Underline>
50+
</span>
5751
),
5852
],
5953
};
@@ -66,9 +60,16 @@ export const Initialism: Story = {
6660
},
6761
decorators:[
6862
(Story)=>(
69-
<Underline>
63+
<spancss={styles.underlined}>
7064
<Story/>
71-
</Underline>
65+
</span>
7266
),
7367
],
7468
};
69+
70+
conststyles={
71+
// Just here to make the abbreviated part more obvious in the component library
72+
underlined:{
73+
textDecoration:"underline dotted",
74+
},
75+
};

‎site/src/components/Dashboard/useUpdateCheck.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const createWrapper = (): FC<PropsWithChildren> => {
1414
};
1515

1616
beforeEach(()=>{
17-
window.localStorage.clear();
17+
localStorage.clear();
1818
});
1919

2020
it("is dismissed when does not have permission to see it",()=>{
@@ -57,7 +57,7 @@ it("is dismissed when it was dismissed previously", async () => {
5757
);
5858
}),
5959
);
60-
window.localStorage.setItem("dismissedVersion",MockUpdateCheck.version);
60+
localStorage.setItem("dismissedVersion",MockUpdateCheck.version);
6161
const{ result}=renderHook(()=>useUpdateCheck(true),{
6262
wrapper:createWrapper(),
6363
});

‎site/src/components/Resources/VSCodeDesktopButton/VSCodeDesktopButton.tsx‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import{FC,PropsWithChildren,useState,useRef}from"react";
2-
import{getApiKey}from"api/api";
3-
import{VSCodeIcon}from"components/Icons/VSCodeIcon";
4-
import{VSCodeInsidersIcon}from"components/Icons/VSCodeInsidersIcon";
5-
import{AgentButton}from"components/Resources/AgentButton";
61
importKeyboardArrowDownIconfrom"@mui/icons-material/KeyboardArrowDown";
72
importButtonGroupfrom"@mui/material/ButtonGroup";
8-
import{useLocalStorage}from"hooks";
93
importMenufrom"@mui/material/Menu";
104
importMenuItemfrom"@mui/material/MenuItem";
5+
import{typeFC,useState,useRef}from"react";
6+
import{getApiKey}from"api/api";
117
import{DisplayApp}from"api/typesGenerated";
8+
import{VSCodeIcon}from"components/Icons/VSCodeIcon";
9+
import{VSCodeInsidersIcon}from"components/Icons/VSCodeInsidersIcon";
10+
import{AgentButton}from"components/Resources/AgentButton";
1211
import{DisplayAppNameMap}from"../AppLink/AppLink";
1312

1413
exportinterfaceVSCodeDesktopButtonProps{
@@ -23,12 +22,9 @@ type VSCodeVariant = "vscode" | "vscode-insiders";
2322

2423
constVARIANT_KEY="vscode-variant";
2524

26-
exportconstVSCodeDesktopButton:FC<
27-
PropsWithChildren<VSCodeDesktopButtonProps>
28-
>=(props)=>{
25+
exportconstVSCodeDesktopButton:FC<VSCodeDesktopButtonProps>=(props)=>{
2926
const[isVariantMenuOpen,setIsVariantMenuOpen]=useState(false);
30-
constlocalStorage=useLocalStorage();
31-
constpreviousVariant=localStorage.getLocal(VARIANT_KEY);
27+
constpreviousVariant=localStorage.getItem(VARIANT_KEY);
3228
const[variant,setVariant]=useState<VSCodeVariant>(()=>{
3329
if(!previousVariant){
3430
return"vscode";
@@ -38,7 +34,7 @@ export const VSCodeDesktopButton: FC<
3834
constmenuAnchorRef=useRef<HTMLDivElement>(null);
3935

4036
constselectVariant=(variant:VSCodeVariant)=>{
41-
localStorage.saveLocal(VARIANT_KEY,variant);
37+
localStorage.setItem(VARIANT_KEY,variant);
4238
setVariant(variant);
4339
setIsVariantMenuOpen(false);
4440
};
@@ -109,12 +105,12 @@ export const VSCodeDesktopButton: FC<
109105
);
110106
};
111107

112-
constVSCodeButton=({
108+
constVSCodeButton:FC<VSCodeDesktopButtonProps>=({
113109
userName,
114110
workspaceName,
115111
agentName,
116112
folderPath,
117-
}:VSCodeDesktopButtonProps)=>{
113+
})=>{
118114
const[loading,setLoading]=useState(false);
119115

120116
return(
@@ -153,12 +149,12 @@ const VSCodeButton = ({
153149
);
154150
};
155151

156-
constVSCodeInsidersButton=({
152+
constVSCodeInsidersButton:FC<VSCodeDesktopButtonProps>=({
157153
userName,
158154
workspaceName,
159155
agentName,
160156
folderPath,
161-
}:VSCodeDesktopButtonProps)=>{
157+
})=>{
162158
const[loading,setLoading]=useState(false);
163159

164160
return(

‎site/src/contexts/ProxyContext.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { screen } from "@testing-library/react";
1919
import{server}from"testHelpers/server";
2020
import{rest}from"msw";
2121
import{Region}from"api/typesGenerated";
22-
import"testHelpers/localstorage";
22+
import"testHelpers/localStorage";
2323
importuserEventfrom"@testing-library/user-event";
2424

2525
// Mock useProxyLatency to use a hard-coded latency. 'jest.mock' must be called
@@ -187,7 +187,7 @@ interface ProxyContextSelectionTest {
187187

188188
describe("ProxyContextSelection",()=>{
189189
beforeEach(()=>{
190-
window.localStorage.clear();
190+
localStorage.clear();
191191
});
192192

193193
// A way to simulate a user clearing the proxy selection.

‎site/src/contexts/ProxyContext.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ const computeUsableURLS = (proxy?: Region): PreferredProxy => {
310310
// Local storage functions
311311

312312
exportconstclearUserSelectedProxy=():void=>{
313-
window.localStorage.removeItem("user-selected-proxy");
313+
localStorage.removeItem("user-selected-proxy");
314314
};
315315

316316
exportconstsaveUserSelectedProxy=(saved:Region):void=>{
317-
window.localStorage.setItem("user-selected-proxy",JSON.stringify(saved));
317+
localStorage.setItem("user-selected-proxy",JSON.stringify(saved));
318318
};
319319

320320
exportconstloadUserSelectedProxy=():Region|undefined=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp