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

Commit80cbffe

Browse files
authored
chore: removeorganizationIds fromAuthProvider (#13917)
1 parentf21f2dc commit80cbffe

File tree

6 files changed

+10
-39
lines changed

6 files changed

+10
-39
lines changed

‎site/src/contexts/auth/AuthProvider.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export type AuthContextValue = {
3030
isUpdatingProfile:boolean;
3131
user:User|undefined;
3232
permissions:Permissions|undefined;
33-
organizationIds:readonlystring[]|undefined;
3433
signInError:unknown;
3534
updateProfileError:unknown;
3635
signOut:()=>void;
@@ -119,7 +118,6 @@ export const AuthProvider: FC<PropsWithChildren> = ({ children }) => {
119118
permissions:permissionsQuery.dataasPermissions|undefined,
120119
signInError:loginMutation.error,
121120
updateProfileError:updateProfileMutation.error,
122-
organizationIds:userQuery.data?.organization_ids,
123121
}}
124122
>
125123
{children}

‎site/src/contexts/auth/RequireAuth.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ describe("useAuthenticated", () => {
9595
wrapper:createAuthWrapper({
9696
user:MockUser,
9797
permissions:MockPermissions,
98-
organizationIds:[],
9998
}),
10099
});
101100
}).not.toThrow();

‎site/src/contexts/auth/RequireAuth.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type RequireKeys<T, R extends keyof T> = Omit<T, R> & {
7474
// values are not undefined when authenticated
7575
typeAuthenticatedAuthContextValue=RequireKeys<
7676
AuthContextValue,
77-
"user"|"permissions"|"organizationIds"
77+
"user"|"permissions"
7878
>;
7979

8080
exportconstuseAuthenticated=():AuthenticatedAuthContextValue=>{
@@ -88,9 +88,5 @@ export const useAuthenticated = (): AuthenticatedAuthContextValue => {
8888
thrownewError("Permissions are not available.");
8989
}
9090

91-
if(!auth.organizationIds){
92-
thrownewError("Organization ID is not available.");
93-
}
94-
9591
returnauthasAuthenticatedAuthContextValue;
9692
};

‎site/src/modules/dashboard/DashboardProvider.tsx

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import{
2-
createContext,
3-
typeFC,
4-
typePropsWithChildren,
5-
useState,
6-
}from"react";
1+
import{createContext,typeFC,typePropsWithChildren}from"react";
72
import{useQuery}from"react-query";
83
import{appearance}from"api/queries/appearance";
94
import{entitlements}from"api/queries/entitlements";
@@ -15,12 +10,14 @@ import type {
1510
}from"api/typesGenerated";
1611
import{Loader}from"components/Loader/Loader";
1712
import{useAuthenticated}from"contexts/auth/RequireAuth";
18-
import{useEffectEvent}from"hooks/hookPolyfills";
1913
import{useEmbeddedMetadata}from"hooks/useEmbeddedMetadata";
2014

2115
exportinterfaceDashboardValue{
16+
/**
17+
*@deprecated Do not add new usage of this value. It is being removed as part
18+
* of the multi-org work.
19+
*/
2220
organizationId:string;
23-
setOrganizationId:(id:string)=>void;
2421
entitlements:Entitlements;
2522
experiments:Experiments;
2623
appearance:AppearanceConfig;
@@ -32,40 +29,22 @@ export const DashboardContext = createContext<DashboardValue | undefined>(
3229

3330
exportconstDashboardProvider:FC<PropsWithChildren>=({ children})=>{
3431
const{ metadata}=useEmbeddedMetadata();
35-
const{ user, organizationIds}=useAuthenticated();
32+
const{ user}=useAuthenticated();
3633
constentitlementsQuery=useQuery(entitlements(metadata.entitlements));
3734
constexperimentsQuery=useQuery(experiments(metadata.experiments));
3835
constappearanceQuery=useQuery(appearance(metadata.appearance));
3936

4037
constisLoading=
4138
!entitlementsQuery.data||!appearanceQuery.data||!experimentsQuery.data;
4239

43-
constlastUsedOrganizationId=localStorage.getItem(
44-
`user:${user.id}.lastUsedOrganizationId`,
45-
);
46-
const[activeOrganizationId,setActiveOrganizationId]=useState(()=>
47-
lastUsedOrganizationId&&organizationIds.includes(lastUsedOrganizationId)
48-
?lastUsedOrganizationId
49-
:organizationIds[0],
50-
);
51-
52-
constsetOrganizationId=useEffectEvent((id:string)=>{
53-
if(!organizationIds.includes(id)){
54-
thrownewReferenceError("Invalid organization ID");
55-
}
56-
localStorage.setItem(`user:${user.id}.lastUsedOrganizationId`,id);
57-
setActiveOrganizationId(id);
58-
});
59-
6040
if(isLoading){
6141
return<Loaderfullscreen/>;
6242
}
6343

6444
return(
6545
<DashboardContext.Provider
6646
value={{
67-
organizationId:activeOrganizationId,
68-
setOrganizationId:setOrganizationId,
47+
organizationId:user.organization_ids[0]??"default",
6948
entitlements:entitlementsQuery.data,
7049
experiments:experimentsQuery.data,
7150
appearance:appearanceQuery.data,

‎site/src/pages/ManagementSettingsPage/ManagementSettingsLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const useOrganizationSettings = (): OrganizationSettingsContextValue => {
3535

3636
exportconstManagementSettingsLayout:FC=()=>{
3737
constlocation=useLocation();
38-
const{ permissions, organizationIds}=useAuthenticated();
38+
const{ permissions}=useAuthenticated();
3939
const{ experiments}=useDashboard();
4040
const{ organization}=useParams()as{organization:string};
4141
constdeploymentConfigQuery=useQuery(deploymentConfig());
@@ -61,7 +61,7 @@ export const ManagementSettingsLayout: FC = () => {
6161
currentOrganizationId:!inOrganizationSettings
6262
?undefined
6363
:!organization
64-
?organizationIds[0]
64+
?organizationsQuery.data[0]?.id
6565
:organizationsQuery.data.find(
6666
(org)=>org.name===organization,
6767
)?.id,

‎site/src/testHelpers/storybook.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const withDashboardProvider = (
2727
<DashboardContext.Provider
2828
value={{
2929
organizationId:"",
30-
setOrganizationId:()=>{},
3130
entitlements,
3231
experiments,
3332
appearance:MockAppearanceConfig,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp