-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from alpaca-tc/render-method-ids
Render method ids
- Loading branch information
Showing
15 changed files
with
583 additions
and
146 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,40 @@ | ||
import { Module } from './module' | ||
|
||
type BaseDotMetadata = { | ||
id: string | ||
} | ||
|
||
type DotSourceMetadata = { | ||
type: 'source' | ||
sourceName: string | ||
} & BaseDotMetadata | ||
|
||
type DotDependencyMetadata = { | ||
type: 'dependency' | ||
sourceName: string | ||
methodIds: Array<{ | ||
name: string | ||
context: 'class' | 'instance' | ||
human: string | ||
}> | ||
} & BaseDotMetadata | ||
|
||
type DotModuleMetadata = { | ||
type: 'module' | ||
moduleName: string | ||
} & BaseDotMetadata | ||
|
||
export type DotMetadata = DotSourceMetadata | DotDependencyMetadata | DotModuleMetadata | ||
|
||
export type CombinedDefinition = { | ||
ids: number[] | ||
titles: string[] | ||
dot: string | ||
dotMetadata: DotMetadata[] | ||
sources: Array<{ sourceName: string; modules: Module[] }> | ||
} | ||
|
||
export type DotSource = { | ||
type: 'source' | ||
sourceName: string | ||
} |
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
77 changes: 77 additions & 0 deletions
77
frontend/pages/Home/components/DefinitionGraph/MetadataDialog.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,77 @@ | ||
import { ComponentProps, FC } from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { Link } from '@/components/Link' | ||
import { Base, DefinitionList, Heading, ModelessDialog, Stack } from '@/components/ui' | ||
import { path } from '@/constants/path' | ||
import { spacing } from '@/constants/theme' | ||
import { DotMetadata } from '@/models/combinedDefinition' | ||
|
||
type Props = { | ||
dotMetadata: DotMetadata | null | ||
isOpen: boolean | ||
onClose: () => void | ||
top: number | ||
left: number | ||
} | ||
|
||
export const MetadataDialog: FC<Props> = ({ dotMetadata, isOpen, onClose, top, left }) => { | ||
const items: ComponentProps<typeof DefinitionList>['items'] = [] | ||
|
||
switch (dotMetadata?.type) { | ||
case 'source': { | ||
items.push({ | ||
term: 'Source Name', | ||
description: <Link to={path.sources.show(dotMetadata.sourceName)}>{dotMetadata.sourceName}</Link>, | ||
}) | ||
break | ||
} | ||
case 'dependency': { | ||
items.push({ | ||
term: 'Dependency Name', | ||
description: <Link to={path.sources.show(dotMetadata.sourceName)}>{dotMetadata.sourceName}</Link>, | ||
}) | ||
items.push({ | ||
term: 'Method ID', | ||
description: dotMetadata.methodIds.map((methodId) => ( | ||
<p key={`${methodId.context}-${methodId.name}`}>{methodId.human}</p> | ||
)), | ||
}) | ||
break | ||
} | ||
case 'module': { | ||
items.push({ | ||
term: 'Module Name', | ||
description: <Link to={path.modules.show(dotMetadata.moduleName)}>{dotMetadata.moduleName}</Link>, | ||
}) | ||
break | ||
} | ||
} | ||
|
||
return ( | ||
<ModelessDialog | ||
isOpen={!!(isOpen && dotMetadata)} | ||
header={<ModelessHeading>Description</ModelessHeading>} | ||
onClickClose={onClose} | ||
onPressEscape={onClose} | ||
top={top} | ||
left={left} | ||
> | ||
<Wrapper> | ||
<Stack gap={0.5} as="section"> | ||
<DefinitionList items={items} /> | ||
</Stack> | ||
</Wrapper> | ||
</ModelessDialog> | ||
) | ||
} | ||
|
||
const ModelessHeading = styled(Heading)` | ||
font-size: 1em; | ||
margin: 0; | ||
font-weight: normal; | ||
` | ||
|
||
const Wrapper = styled.div` | ||
padding: ${spacing.XS}; | ||
` |
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
Oops, something went wrong.