Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more group permissions #1453

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open

Conversation

Meierschlumpf
Copy link
Member

@Meierschlumpf Meierschlumpf commented Nov 8, 2024


Homarr

Thank you for your contribution. Please ensure that your pull request meets the following pull request:

  • Builds without warnings or errors (pnpm buid, autofix with pnpm format:fix)
  • Pull request targets dev branch
  • Commits follow the conventional commits guideline
  • No shorthand variable names are used (eg. x, y, i or any abbrevation)

Closes #1240

localhost_3000_manage_users_groups_wtomcd4dfozg907osmn6vbnp_permissions

@Meierschlumpf Meierschlumpf added the enhancement New feature or request label Nov 8, 2024
@Meierschlumpf Meierschlumpf self-assigned this Nov 8, 2024
@Meierschlumpf Meierschlumpf changed the title More group permissions feat: add more group permissions Nov 8, 2024
Copy link

deepsource-io bot commented Nov 8, 2024

Here's the code health analysis summary for commits 2306ecd..b714a4d. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

github-actions bot commented Nov 8, 2024

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 22.04% 6406 / 29065
🔵 Statements 22.04% 6406 / 29065
🔵 Functions 23.95% 246 / 1027
🔵 Branches 60.43% 776 / 1284
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/nextjs/src/app/[locale]/manage/layout.tsx 0% 0% 0% 0% 1-180
apps/nextjs/src/app/[locale]/manage/page.tsx 0% 0% 0% 0% 1-107
apps/nextjs/src/app/[locale]/manage/apps/page.tsx 0% 0% 0% 0% 1-128
apps/nextjs/src/app/[locale]/manage/apps/edit/[id]/page.tsx 0% 0% 0% 0% 1-35
apps/nextjs/src/app/[locale]/manage/apps/new/page.tsx 0% 0% 0% 0% 1-30
apps/nextjs/src/app/[locale]/manage/integrations/page.tsx 0% 0% 0% 0% 1-226
apps/nextjs/src/app/[locale]/manage/integrations/edit/[id]/page.tsx 0% 0% 0% 0% 1-42
apps/nextjs/src/app/[locale]/manage/medias/page.tsx 0% 0% 0% 0% 1-132
apps/nextjs/src/app/[locale]/manage/search-engines/page.tsx 0% 0% 0% 0% 1-157
apps/nextjs/src/app/[locale]/manage/search-engines/edit/[id]/page.tsx 0% 0% 0% 0% 1-35
apps/nextjs/src/app/[locale]/manage/search-engines/new/page.tsx 0% 0% 0% 0% 1-29
apps/nextjs/src/app/[locale]/manage/tools/logs/page.tsx 0% 0% 0% 0% 1-42
apps/nextjs/src/app/[locale]/manage/users/[userId]/layout.tsx 0% 0% 0% 0% 1-76
apps/nextjs/src/app/[locale]/manage/users/[userId]/general/page.tsx 0% 0% 0% 0% 1-119
apps/nextjs/src/app/[locale]/manage/users/[userId]/security/page.tsx 0% 0% 0% 0% 1-42
apps/nextjs/src/errors/trpc-catch-error.ts 0% 0% 0% 0% 1-20
packages/api/src/router/app.ts 88.53% 91.66% 100% 88.53% 45-49, 73-82, 119-121
packages/api/src/router/log.ts 0% 0% 0% 0% 1-22
packages/api/src/router/app/app-access-control.ts 10.52% 100% 0% 10.52% 10-11, 14-18, 21-50
packages/api/src/router/medias/media-router.ts 0% 0% 0% 0% 1-91
packages/api/src/router/search-engine/search-engine-router.ts 0% 0% 0% 0% 1-110
packages/definitions/src/permissions.ts 100% 100% 100% 100%
packages/spotlight/src/components/spotlight.tsx 0% 0% 0% 0% 1-144
packages/spotlight/src/lib/mode.ts 0% 0% 0% 0%
packages/spotlight/src/modes/index.tsx 0% 0% 0% 0% 1-85
packages/spotlight/src/modes/app-integration-board/index.tsx 0% 0% 0% 0% 1-22
packages/spotlight/src/modes/command/index.tsx 0% 0% 0% 0% 1-173
packages/spotlight/src/modes/page/pages-search-group.tsx 0% 0% 0% 0% 1-170
Generated in workflow #3646 for commit b714a4d by the Vitest Coverage Report Action

@Meierschlumpf Meierschlumpf marked this pull request as ready for review November 9, 2024 10:25
@Meierschlumpf Meierschlumpf requested a review from a team as a code owner November 9, 2024 10:25
@Meierschlumpf Meierschlumpf marked this pull request as draft November 10, 2024 09:33
@Meierschlumpf Meierschlumpf marked this pull request as ready for review November 10, 2024 09:47
@@ -95,27 +98,32 @@ export default async function ManageLayout({ children }: PropsWithChildren) {
{
label: t("items.tools.label"),
icon: IconTool,
hidden: !session?.user.permissions.includes("admin"),
// As permissions always include there children permissions, we can check for the lowest permission
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand what you mean but "low" is in my opinion a poor word choice to describe it (eg. what is high?)

};

export const catchTrpcUnauthorized = (err: unknown) => {
if (err instanceof TRPCError && err.code === "UNAUTHORIZED") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log this? I'd say say as "info"

Comment on lines +40 to +46
if (item.kind === "app") {
const parsedOptions = SuperJSON.parse<WidgetComponentProps<"app">["options"]>(item.options);
return [parsedOptions.appId];
} else if (item.kind === "bookmarks") {
const parsedOptions = SuperJSON.parse<WidgetComponentProps<"bookmarks">["options"]>(item.options);
return parsedOptions.items;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike non-generic special cases.
For the app it's fine but is there maybe a better option / more generic way for the bookmark? (eg. by checking type of options?)

return parsedOptions.items;
}

throw new Error("Invalid item kind");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not descriptive enough. It says what is wrong but not what happened.
Suggestion: Failed to get app ids from board. Invalid item kind: 'test'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add more group permissions
2 participants