Skip to content

Commit 7580936

Browse files
Add created date to series selection dropdown (#1373)
This should help a little with choosing the right series when uploading a video or adding a series block. Improves #1098
2 parents 342bbc4 + c96309c commit 7580936

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

backend/src/api/model/search/series.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::HashMap;
22

3+
use chrono::{DateTime, Utc};
34
use juniper::GraphQLObject;
45
use meilisearch_sdk::search::MatchRange;
56

@@ -21,6 +22,7 @@ pub(crate) struct SearchSeries {
2122
host_realms: Vec<SearchRealm>,
2223
thumbnails: Vec<ThumbnailInfo>,
2324
matches: SearchSeriesMatches,
25+
created: Option<DateTime<Utc>>,
2426
}
2527

2628

@@ -52,6 +54,7 @@ impl SearchSeries {
5254
opencast_id: src.opencast_id,
5355
title: src.title,
5456
description: src.description,
57+
created: src.created,
5558
host_realms: src.host_realms.into_iter()
5659
.map(|r| SearchRealm::without_matches(r))
5760
.collect(),

frontend/src/schema.graphql

+1
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ type SearchSeries implements Node {
785785
hostRealms: [SearchRealm!]!
786786
thumbnails: [ThumbnailInfo!]!
787787
matches: SearchSeriesMatches!
788+
created: DateTime
788789
}
789790

790791
type SearchSeriesMatches {

frontend/src/ui/SearchableSelect.tsx

+25-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import {
1717
SearchableSelectSeriesQuery,
1818
} from "./__generated__/SearchableSelectSeriesQuery.graphql";
19+
import { LuCalendar } from "react-icons/lu";
1920

2021

2122
type DerivedProps<T> = Omit<Parameters<typeof AsyncSelect<T>>[0],
@@ -132,6 +133,7 @@ export type VideoListOption = {
132133
readonly opencastId: string;
133134
readonly title: string;
134135
readonly description?: string | null;
136+
readonly created?: string | null;
135137
};
136138

137139
export const VideoListSelector: React.FC<VideoListSelectorProps> = ({
@@ -149,6 +151,7 @@ export const VideoListSelector: React.FC<VideoListSelectorProps> = ({
149151
opencastId
150152
title
151153
description
154+
created
152155
}
153156
}
154157
}
@@ -206,7 +209,28 @@ export const VideoListSelector: React.FC<VideoListSelectorProps> = ({
206209

207210
const formatVideoListOption = (videoList: VideoListOption, _: TFunction) => (
208211
<div>
209-
<div>{videoList.title}</div>
212+
<div css={{ display: "flex", gap: 8 }}>
213+
{videoList.title}
214+
{videoList.created && <DateWithIcon dateString={videoList.created} />}
215+
</div>
210216
<SmallDescription css={{ margin: 0 }} lines={1} text={videoList.description} />
211217
</div>
212218
);
219+
220+
const DateWithIcon: React.FC<{ dateString: string }> = ({ dateString }) => {
221+
const { i18n } = useTranslation();
222+
const date = new Date(dateString);
223+
224+
return <div css={{
225+
display: "flex",
226+
gap: 4,
227+
fontSize: 10,
228+
color: COLORS.neutral60,
229+
alignItems: "center",
230+
}}>
231+
<LuCalendar />
232+
<time dateTime={date.toISOString()}>
233+
{date.toLocaleDateString(i18n.language)}
234+
</time>
235+
</div>;
236+
};

0 commit comments

Comments
 (0)