Skip to content

Commit

Permalink
Austenem/CAT-1180 Restrict lists to HuBMAP users (#3698)
Browse files Browse the repository at this point in the history
* update boolean

* update changelog

* switch other lists entry points
  • Loading branch information
austenem authored Feb 24, 2025
1 parent 16b3dba commit 73dbd0a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-restrict-lists-to-hubmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Restrict "My Lists" feature to HuBMAP users only.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ function WorkspaceSVGIcon({ color = 'primary', ...props }: SvgIconProps) {

function SaveEditEntityButton({ uuid }: Pick<Entity, 'uuid'>) {
const { savedEntities } = useSavedLists();
const { isAuthenticated } = useAppContext();
const { isHubmapUser } = useAppContext();

if (!isAuthenticated) {
if (!isHubmapUser) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ function EditSavedEntityButton({ uuid }: Pick<Entity, 'uuid'>) {

export default function SummarySaveEntityButton({ uuid }: Pick<Entity, 'uuid'>) {
const { savedEntities } = useSavedLists();
const { isAuthenticated } = useAppContext();
const { isHubmapUser } = useAppContext();

if (!isAuthenticated) {
if (!isHubmapUser) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ function SearchPagesPrompt({ capitalize }: { capitalize?: boolean }) {
}

function LoginPrompt({ endingText }: { endingText: string }) {
const { isAuthenticated } = useAppContext();
const { isHubmapUser } = useAppContext();

if (isAuthenticated) {
if (isHubmapUser) {
return null;
}

Expand All @@ -61,11 +61,11 @@ function SavedListMessage() {
}

function SavedListsMessage() {
const { isAuthenticated } = useAppContext();
const { isHubmapUser } = useAppContext();

return (
<>
<LoginPrompt endingText=" or " /> <SearchPagesPrompt capitalize={isAuthenticated} /> to explore data to save
<LoginPrompt endingText=" or " /> <SearchPagesPrompt capitalize={isHubmapUser} /> to explore data to save
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function SaveEntitiesButton({
uuids: Set<string>;
fromSelectableTable?: boolean;
}) {
const { isAuthenticated } = useAppContext();
const { isHubmapUser } = useAppContext();
const { savedEntities, handleSaveEntities } = useSavedLists();
const {
entity: { entity_type: page_entity_type },
Expand All @@ -70,7 +70,7 @@ export default function SaveEntitiesButton({
});
});

if (!isAuthenticated) {
if (!isHubmapUser) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const handleTrack = () => {
};

function LocalStorageDescription() {
const { isAuthenticated } = useAppContext();
const { isHubmapUser } = useAppContext();

if (isAuthenticated) {
if (isHubmapUser) {
return <Description>Lists saved here are stored to your profile and are accessible across devices.</Description>;
}

Expand Down
4 changes: 2 additions & 2 deletions context/app/static/js/components/savedLists/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function useUkvHeaders(): HeadersInit {
}

function useHasUkvAccess() {
const { isAuthenticated } = useAppContext();
return Boolean(isAuthenticated);
const { isHubmapUser } = useAppContext();
return Boolean(isHubmapUser);
}

function useBuildUkvSWRKey(): {
Expand Down
4 changes: 2 additions & 2 deletions context/app/static/js/pages/SavedLists/SavedLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useAppContext } from 'js/components/Contexts';
import SavedListsContent from 'js/components/savedLists/SavedListsContent';

function SavedLists() {
const { isAuthenticated } = useAppContext();
const { isHubmapUser } = useAppContext();

return (
<Stack spacing={1} marginBottom={10}>
Expand All @@ -16,7 +16,7 @@ function SavedLists() {
</Typography>
<Stack spacing={3}>
<SavedListsDescription />
{isAuthenticated && <SavedListsContent />}
{isHubmapUser && <SavedListsContent />}
</Stack>
</Stack>
);
Expand Down

0 comments on commit 73dbd0a

Please sign in to comment.