Skip to content

Commit

Permalink
Dependencies no longer dissapear when a user clicks the link to anoth…
Browse files Browse the repository at this point in the history
…er artifact
  • Loading branch information
BriannaVH committed Jul 6, 2023
1 parent f0d3765 commit d189391
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/src/components/DependencyCards.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Anchor,
ActionIcon,
Center,
createStyles,
Expand All @@ -11,6 +10,7 @@ import {
getBreakpointValue,
rem
} from '@mantine/core';
import Link from 'next/link';
import React from 'react';
import { SquareArrowRight } from 'tabler-icons-react';

Expand Down Expand Up @@ -68,13 +68,13 @@ function Dependencies(props: { relatedArtifact: fhir4.RelatedArtifact }) {
</div>
</Grid.Col>
{dependencyInfo.type && (
<Anchor href={`/${dependencyInfo.link}`}>
<Link href={`/${dependencyInfo.link}`}>
<Tooltip label={'Open Dependency Resource'} openDelay={1000}>
<ActionIcon radius="md" size="md" variant="subtle" color="gray">
{<SquareArrowRight size="24" />}
</ActionIcon>
</Tooltip>
</Anchor>
</Link>
)}
</Grid>
</Paper>
Expand Down
12 changes: 8 additions & 4 deletions app/src/pages/[resourceType]/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Dependency from '@/components/DependencyCards';
export default function ResourceIDPage({ jsonData }: InferGetServerSidePropsType<typeof getServerSideProps>) {
const resourceType = jsonData.resourceType;

const [activeTab, setActiveTab] = useState<string | null>('json');
const [height, setWindowHeight] = useState(0);

const decodedCql = useMemo(() => {
Expand Down Expand Up @@ -48,7 +49,6 @@ export default function ResourceIDPage({ jsonData }: InferGetServerSidePropsType
};
handleResize();
window.addEventListener('resize', handleResize);
return window.removeEventListener('resize', handleResize);
}, []);

const {
Expand Down Expand Up @@ -81,6 +81,10 @@ export default function ResourceIDPage({ jsonData }: InferGetServerSidePropsType
}
);

useEffect(() => {
setActiveTab('json');
}, [jsonData.id]);

const draftMutation = trpc.draft.createDraft.useMutation({
onSuccess: data => {
notifications.show({
Expand Down Expand Up @@ -133,7 +137,7 @@ export default function ResourceIDPage({ jsonData }: InferGetServerSidePropsType
</Group>
</div>
<Divider my="sm" pb={6} />
<Tabs variant="outline" defaultValue="json">
<Tabs variant="outline" value={activeTab} onTabChange={setActiveTab}>
<Tabs.List>
<Tabs.Tab value="json">JSON</Tabs.Tab>
{decodedElm != null && <Tabs.Tab value="elm">ELM</Tabs.Tab>}
Expand Down Expand Up @@ -182,11 +186,11 @@ export default function ResourceIDPage({ jsonData }: InferGetServerSidePropsType
<Tabs.Panel value="dependencies">
<Space h="md" />
<Text c="dimmed">
Number of Dependencies:<b> {dataRequirements?.relatedArtifact.length} </b>
Number of Dependencies:<b> {dataRequirements.relatedArtifact.length} </b>
</Text>
<Space h="md" />
<ScrollArea.Autosize mah={height * 0.8} type="hover">
{dataRequirements?.relatedArtifact.map((relatedArtifact, index) => (
{dataRequirements.relatedArtifact.map((relatedArtifact, index) => (
<Dependency key={index} relatedArtifact={relatedArtifact} />
))}
</ScrollArea.Autosize>
Expand Down

0 comments on commit d189391

Please sign in to comment.