Skip to content

Commit

Permalink
Add hyperlink titles in article text cell so that link content can be…
Browse files Browse the repository at this point in the history
… seen in table
  • Loading branch information
MrOrz committed Feb 28, 2023
1 parent 1e2eb08 commit 4f6dbff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/components/cells.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ fragment ArticleCellFields on Article {
articleType
attachmentUrl
text
hyperlinks {
title
}
}
5 changes: 5 additions & 0 deletions src/components/cells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { styled } from '@mui/material/styles';
import Link from '@mui/material/Link';
import Typography from '@mui/material/Typography';
import { ArticleCellFieldsFragment } from '../types';
import { rejectsNull } from '../lib/util';

export const TextCell = styled('div')({
width: '100%',
Expand Down Expand Up @@ -56,6 +57,10 @@ export function ArticleCell({ article }: ArticleCellProps) {
title={article.text || ''}
>
{article.text || ''}
{(article.hyperlinks || []).length > 0 &&
(article.hyperlinks || [])
.filter(rejectsNull)
.map(({ title }) => title)}
</Typography>
);
}
Expand Down
9 changes: 6 additions & 3 deletions src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ export type ValidationResult = {
readonly success: Scalars['Boolean'];
};

export type ArticleCellFieldsFragment = { readonly __typename?: 'Article', readonly id: string, readonly articleType: ArticleTypeEnum, readonly attachmentUrl?: string | null, readonly text?: string | null };
export type ArticleCellFieldsFragment = { readonly __typename?: 'Article', readonly id: string, readonly articleType: ArticleTypeEnum, readonly attachmentUrl?: string | null, readonly text?: string | null, readonly hyperlinks?: ReadonlyArray<{ readonly __typename?: 'Hyperlink', readonly title?: string | null } | null> | null };

export type LoadApiStatsQueryVariables = Exact<{
isRepliedOnly: Scalars['Boolean'];
Expand Down Expand Up @@ -1232,7 +1232,7 @@ export type LoadAnalyticsQueryVariables = Exact<{
}>;


export type LoadAnalyticsQuery = { readonly __typename?: 'Query', readonly ListArticles?: { readonly __typename?: 'ArticleConnection', readonly edges: ReadonlyArray<{ readonly __typename?: 'ArticleConnectionEdge', readonly cursor: string, readonly node: { readonly __typename?: 'Article', readonly id: string, readonly createdAt?: string | null, readonly articleType: ArticleTypeEnum, readonly attachmentUrl?: string | null, readonly text?: string | null, readonly stats?: ReadonlyArray<{ readonly __typename?: 'Analytics', readonly date: string, readonly lineUser?: number | null, readonly lineVisit?: number | null, readonly webUser?: number | null, readonly webVisit?: number | null, readonly liff: ReadonlyArray<{ readonly __typename?: 'AnalyticsLiffEntry', readonly source: string, readonly user: number, readonly visit: number }> } | null> | null } }> } | null };
export type LoadAnalyticsQuery = { readonly __typename?: 'Query', readonly ListArticles?: { readonly __typename?: 'ArticleConnection', readonly edges: ReadonlyArray<{ readonly __typename?: 'ArticleConnectionEdge', readonly cursor: string, readonly node: { readonly __typename?: 'Article', readonly id: string, readonly createdAt?: string | null, readonly articleType: ArticleTypeEnum, readonly attachmentUrl?: string | null, readonly text?: string | null, readonly stats?: ReadonlyArray<{ readonly __typename?: 'Analytics', readonly date: string, readonly lineUser?: number | null, readonly lineVisit?: number | null, readonly webUser?: number | null, readonly webVisit?: number | null, readonly liff: ReadonlyArray<{ readonly __typename?: 'AnalyticsLiffEntry', readonly source: string, readonly user: number, readonly visit: number }> } | null> | null, readonly hyperlinks?: ReadonlyArray<{ readonly __typename?: 'Hyperlink', readonly title?: string | null } | null> | null } }> } | null };

export type BigNumOfRepliedQueryVariables = Exact<{
startTime?: InputMaybe<Scalars['String']>;
Expand Down Expand Up @@ -1295,7 +1295,7 @@ export type ReplyRequestListInReplyRequestTableQueryVariables = Exact<{
}>;


export type ReplyRequestListInReplyRequestTableQuery = { readonly __typename?: 'Query', readonly ListReplyRequests?: { readonly __typename?: 'ListReplyRequestConnection', readonly edges: ReadonlyArray<{ readonly __typename?: 'ListReplyRequestConnectionEdge', readonly cursor: string, readonly node: { readonly __typename?: 'ReplyRequest', readonly id: string, readonly reason?: string | null, readonly updatedAt?: string | null, readonly user?: { readonly __typename?: 'User', readonly id: string, readonly name?: string | null } | null, readonly article: { readonly __typename?: 'Article', readonly id: string, readonly articleType: ArticleTypeEnum, readonly attachmentUrl?: string | null, readonly text?: string | null } } }> } | null };
export type ReplyRequestListInReplyRequestTableQuery = { readonly __typename?: 'Query', readonly ListReplyRequests?: { readonly __typename?: 'ListReplyRequestConnection', readonly edges: ReadonlyArray<{ readonly __typename?: 'ListReplyRequestConnectionEdge', readonly cursor: string, readonly node: { readonly __typename?: 'ReplyRequest', readonly id: string, readonly reason?: string | null, readonly updatedAt?: string | null, readonly user?: { readonly __typename?: 'User', readonly id: string, readonly name?: string | null } | null, readonly article: { readonly __typename?: 'Article', readonly id: string, readonly articleType: ArticleTypeEnum, readonly attachmentUrl?: string | null, readonly text?: string | null, readonly hyperlinks?: ReadonlyArray<{ readonly __typename?: 'Hyperlink', readonly title?: string | null } | null> | null } } }> } | null };

export type ReplyListStatInReplyTableQueryVariables = Exact<{
createdAt?: InputMaybe<TimeRangeInput>;
Expand All @@ -1321,6 +1321,9 @@ export const ArticleCellFieldsFragmentDoc = gql`
articleType
attachmentUrl
text
hyperlinks {
title
}
}
`;
export const LoadApiStatsDocument = gql`
Expand Down

0 comments on commit 4f6dbff

Please sign in to comment.