-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(brainManagement): fix shared brain access issue (#1641)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review fix/brain-management-shared-brain-access - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
- Loading branch information
Showing
10 changed files
with
97 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...nd/app/brains-management/[brainId]/components/BrainManagementTabs/components/NoAccess.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use client"; | ||
|
||
import { useTranslation } from "react-i18next"; | ||
|
||
export const NoAccess = (): JSX.Element => { | ||
const { t } = useTranslation(["translation", "config", "brain"]); | ||
|
||
return ( | ||
<div className="flex justify-center items-center mt-5"> | ||
<div className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative max-w-md"> | ||
<strong className="font-bold mr-1"> | ||
{t("ohno", { ns: "config" })} | ||
</strong> | ||
<span className="block sm:inline"> | ||
{t("roleRequired", { ns: "config" })} | ||
</span> | ||
<p>{t("requireAccess", { ns: "config" })}</p> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...app/brains-management/[brainId]/components/BrainManagementTabs/utils/isUserBrainEditor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { UUID } from "crypto"; | ||
|
||
import { MinimalBrainForUser } from "@/lib/context/BrainProvider/types"; | ||
|
||
type IsUserBrainOwnerProps = { | ||
userAccessibleBrains: MinimalBrainForUser[]; | ||
brainId?: UUID; | ||
}; | ||
export const isUserBrainOwner = ({ | ||
brainId, | ||
userAccessibleBrains, | ||
}: IsUserBrainOwnerProps): boolean => { | ||
const brain = userAccessibleBrains.find(({ id }) => id === brainId); | ||
if (brain === undefined) { | ||
return false; | ||
} | ||
|
||
return brain.role === "Owner"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters