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

Configured collections list and barchart (PP-1535, PP-1536 & PP-1537) #124

Merged
merged 7 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/businessRules/roleBasedAccess.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useAppAdmin, useAppFeatureFlags } from "../context/appContext";

// Not all methods taking this type will use the specified properties.
// The type is here to ensure that the call site provides the right
// properties, in case the rules change in the future.
type HasLibraryKeyProps = {
library: string; // library "key" or "short name"
[key: string]: unknown;
};

// If the `reportsOnlyForSysadmins` feature flag is set, only system admins
// may request inventory reports.
export const useMayRequestInventoryReports = (
_: HasLibraryKeyProps
): boolean => {
const admin = useAppAdmin();
const onlyForSysAdmins = useAppFeatureFlags().reportsOnlyForSysadmins;
return !onlyForSysAdmins || admin.isSystemAdmin();
};

// Only system admins may view the collection statistics barchart.
export const useMayViewCollectionBarChart = (
_: HasLibraryKeyProps
): boolean => {
const admin = useAppAdmin();
return admin.isSystemAdmin();
};
Loading