Rename TeamSwitcher comp

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-26 14:55:19 +01:00
parent def17c6a1a
commit 04c2b73bce
5 changed files with 34 additions and 33 deletions

View File

@@ -30,7 +30,7 @@ import {
SidebarMenuItem,
} from "@/components/ui/sidebar";
import type { AppSidebarQuery as AppSidebarQueryType } from "./__generated__/AppSidebarQuery.graphql";
import { TeamSwitcher } from "@/components/TeamSwitcher";
import { OrganizationSwitcher } from "@/components/OrganizationSwitcher";
function getNavItems(organizationId?: string) {
// Always return the same structure, but with or without URLs depending on whether an organization is selected
@@ -91,7 +91,7 @@ const AppSidebarQuery = graphql`
query AppSidebarQuery {
viewer {
id
...TeamSwitcher_organizations
...OrganizationSwitcher_organizations
...NavUser_viewer
}
}
@@ -110,7 +110,7 @@ function AppSidebarContent({
return (
<Sidebar variant="inset" {...props}>
<SidebarHeader>
<TeamSwitcher organizations={data.viewer} />
<OrganizationSwitcher organizations={data.viewer} />
</SidebarHeader>
<SidebarContent>
<NavMain items={navItems.navMain} />

View File

@@ -21,13 +21,14 @@ import {
useSidebar,
} from "@/components/ui/sidebar";
import {
TeamSwitcher_organizations$key,
TeamSwitcher_organizations$data,
} from "./__generated__/TeamSwitcher_organizations.graphql";
OrganizationSwitcher_organizations$key,
OrganizationSwitcher_organizations$data,
} from "./__generated__/OrganizationSwitcher_organizations.graphql";
export const teamSwitcherFragment = graphql`
fragment TeamSwitcher_organizations on User {
organizations(first: 25) @connection(key: "TeamSwitcher_organizations") {
export const organizationSwitcherFragment = graphql`
fragment OrganizationSwitcher_organizations on User {
organizations(first: 25)
@connection(key: "OrganizationSwitcher_organizations") {
__id
edges {
node {
@@ -41,7 +42,7 @@ export const teamSwitcherFragment = graphql`
`;
type Organization =
TeamSwitcher_organizations$data["organizations"]["edges"][0]["node"];
OrganizationSwitcher_organizations$data["organizations"]["edges"][0]["node"];
const LogoComponent = ({
org,
@@ -56,13 +57,13 @@ const LogoComponent = ({
return null;
};
export function TeamSwitcher({
export function OrganizationSwitcher({
organizations,
}: {
organizations: TeamSwitcher_organizations$key;
organizations: OrganizationSwitcher_organizations$key;
}) {
const { isMobile } = useSidebar();
const data = useFragment(teamSwitcherFragment, organizations);
const data = useFragment(organizationSwitcherFragment, organizations);
const navigate = useNavigate();
const { organizationId } = useParams();
const [currentOrganization, setCurrentOrganization] =
@@ -73,7 +74,7 @@ export function TeamSwitcher({
useEffect(() => {
if (hasOrganizations) {
const org = data.organizations.edges.find(
(edge) => edge.node.id === organizationId,
(edge) => edge.node.id === organizationId
);
if (org) {
setCurrentOrganization(org.node);

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<a1cc304a7eb154a19a1ec9a68c2cda98>>
* @generated SignedSource<<d4b79299641fcf7b2547eec4064af57a>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -14,7 +14,7 @@ export type AppSidebarQuery$variables = Record<PropertyKey, never>;
export type AppSidebarQuery$data = {
readonly viewer: {
readonly id: string;
readonly " $fragmentSpreads": FragmentRefs<"NavUser_viewer" | "TeamSwitcher_organizations">;
readonly " $fragmentSpreads": FragmentRefs<"NavUser_viewer" | "OrganizationSwitcher_organizations">;
};
};
export type AppSidebarQuery = {
@@ -56,7 +56,7 @@ return {
{
"args": null,
"kind": "FragmentSpread",
"name": "TeamSwitcher_organizations"
"name": "OrganizationSwitcher_organizations"
},
{
"args": null,
@@ -189,7 +189,7 @@ return {
"args": (v1/*: any*/),
"filters": null,
"handle": "connection",
"key": "TeamSwitcher_organizations",
"key": "OrganizationSwitcher_organizations",
"kind": "LinkedHandle",
"name": "organizations"
},
@@ -213,16 +213,16 @@ return {
]
},
"params": {
"cacheID": "52b7d912665a4da10a79b82987a7e58a",
"cacheID": "d92e5e742128d82b461ab1b6d52cd2a6",
"id": null,
"metadata": {},
"name": "AppSidebarQuery",
"operationKind": "query",
"text": "query AppSidebarQuery {\n viewer {\n id\n ...TeamSwitcher_organizations\n ...NavUser_viewer\n }\n}\n\nfragment NavUser_viewer on User {\n id\n fullName\n email\n}\n\nfragment TeamSwitcher_organizations on User {\n organizations(first: 25) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n"
"text": "query AppSidebarQuery {\n viewer {\n id\n ...OrganizationSwitcher_organizations\n ...NavUser_viewer\n }\n}\n\nfragment NavUser_viewer on User {\n id\n fullName\n email\n}\n\nfragment OrganizationSwitcher_organizations on User {\n organizations(first: 25) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n"
}
};
})();
(node as any).hash = "d5e28d934b5913169dd822042f4eca07";
(node as any).hash = "ebe1f481a1454380e017fb976b8bb8a5";
export default node;

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<a4a57a018956ccc09931f2b2ce87c933>>
* @generated SignedSource<<e71f99685baea9efcb9f603d577f7412>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -10,7 +10,7 @@
import { ReaderFragment } from 'relay-runtime';
import { FragmentRefs } from "relay-runtime";
export type TeamSwitcher_organizations$data = {
export type OrganizationSwitcher_organizations$data = {
readonly organizations: {
readonly __id: string;
readonly edges: ReadonlyArray<{
@@ -21,11 +21,11 @@ export type TeamSwitcher_organizations$data = {
};
}>;
};
readonly " $fragmentType": "TeamSwitcher_organizations";
readonly " $fragmentType": "OrganizationSwitcher_organizations";
};
export type TeamSwitcher_organizations$key = {
readonly " $data"?: TeamSwitcher_organizations$data;
readonly " $fragmentSpreads": FragmentRefs<"TeamSwitcher_organizations">;
export type OrganizationSwitcher_organizations$key = {
readonly " $data"?: OrganizationSwitcher_organizations$data;
readonly " $fragmentSpreads": FragmentRefs<"OrganizationSwitcher_organizations">;
};
const node: ReaderFragment = {
@@ -43,14 +43,14 @@ const node: ReaderFragment = {
}
]
},
"name": "TeamSwitcher_organizations",
"name": "OrganizationSwitcher_organizations",
"selections": [
{
"alias": "organizations",
"args": null,
"concreteType": "OrganizationConnection",
"kind": "LinkedField",
"name": "__TeamSwitcher_organizations_connection",
"name": "__OrganizationSwitcher_organizations_connection",
"plural": false,
"selections": [
{
@@ -155,6 +155,6 @@ const node: ReaderFragment = {
"abstractKey": null
};
(node as any).hash = "22731866cafda226a19f8c64fda51ba5";
(node as any).hash = "8150704a009e88c096c6f6aa13cada52";
export default node;