Rename track.visible -> track.public
This commit is contained in:
parent
13b6dd8691
commit
840ecc6d6f
7 changed files with 24 additions and 20 deletions
|
@ -55,8 +55,12 @@ const schema = new mongoose.Schema(
|
||||||
// A user-provided description of the track. May contain markdown.
|
// A user-provided description of the track. May contain markdown.
|
||||||
description: String,
|
description: String,
|
||||||
|
|
||||||
// Whether this track is visible in the public track list or not.
|
// Whether this track is visible (anonymized) in the public track list or not.
|
||||||
visible: Boolean,
|
public: { type: Boolean, default: false },
|
||||||
|
|
||||||
|
// Whether this track should be exported to the public track database
|
||||||
|
// (after anonymization).
|
||||||
|
includeInPublicDatabase: { type: Boolean, default: false },
|
||||||
|
|
||||||
// The user agent string, or a part thereof, that was used to upload this
|
// The user agent string, or a part thereof, that was used to upload this
|
||||||
// track. Usually contains only the OBS version, other user agents are
|
// track. Usually contains only the OBS version, other user agents are
|
||||||
|
@ -142,7 +146,7 @@ class Track extends mongoose.Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
isVisibleTo(user) {
|
isVisibleTo(user) {
|
||||||
if (this.visible) {
|
if (this.public) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +254,7 @@ class Track extends mongoose.Model {
|
||||||
description: this.description,
|
description: this.description,
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
updatedAt: this.updatedAt,
|
updatedAt: this.updatedAt,
|
||||||
visible: this.visible,
|
public: this.public,
|
||||||
author: this.author.toProfileJSONFor(user),
|
author: this.author.toProfileJSONFor(user),
|
||||||
statistics: this.statistics,
|
statistics: this.statistics,
|
||||||
processingStatus: this.processingStatus,
|
processingStatus: this.processingStatus,
|
||||||
|
|
|
@ -11,7 +11,7 @@ router.get(
|
||||||
'/',
|
'/',
|
||||||
wrapRoute(async (req, res) => {
|
wrapRoute(async (req, res) => {
|
||||||
const trackCount = await Track.find().count();
|
const trackCount = await Track.find().count();
|
||||||
const publicTrackCount = await Track.find({ visible: true }).count();
|
const publicTrackCount = await Track.find({ public: true }).count();
|
||||||
const userCount = await User.find().count();
|
const userCount = await User.find().count();
|
||||||
|
|
||||||
const [{ trackLength, numEvents, trackDuration }] = await Track.aggregate([
|
const [{ trackLength, numEvents, trackDuration }] = await Track.aggregate([
|
||||||
|
|
|
@ -57,7 +57,7 @@ router.get(
|
||||||
'/',
|
'/',
|
||||||
auth.optional,
|
auth.optional,
|
||||||
wrapRoute(async (req, res) => {
|
wrapRoute(async (req, res) => {
|
||||||
const query = { visible: true };
|
const query = { public: true };
|
||||||
let limit = 20;
|
let limit = 20;
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
|
||||||
|
@ -183,12 +183,12 @@ router.post(
|
||||||
// TODO: Stream into temporary file, then move it later.
|
// TODO: Stream into temporary file, then move it later.
|
||||||
const { body, fileInfo } = await getMultipartOrJsonBody(req, (body) => body.track);
|
const { body, fileInfo } = await getMultipartOrJsonBody(req, (body) => body.track);
|
||||||
|
|
||||||
const { body: fileBody, visible, ...trackBody } = body
|
const { body: fileBody, public, ...trackBody } = body
|
||||||
|
|
||||||
const track = new Track({
|
const track = new Track({
|
||||||
...trackBody,
|
...trackBody,
|
||||||
author: req.user,
|
author: req.user,
|
||||||
visible: visible == null ? req.user.areTracksVisibleForAll : Boolean(trackBody.visible)
|
public: public == null ? req.user.areTracksVisibleForAll : Boolean(trackBody.public)
|
||||||
})
|
})
|
||||||
track.customizedTitle = track.title != null
|
track.customizedTitle = track.title != null
|
||||||
track.slugify();
|
track.slugify();
|
||||||
|
@ -249,10 +249,10 @@ router.put(
|
||||||
|
|
||||||
let process = false
|
let process = false
|
||||||
|
|
||||||
if (trackBody.visible != null) {
|
if (trackBody.public != null) {
|
||||||
const visible = Boolean(trackBody.visible);
|
const public = Boolean(trackBody.public);
|
||||||
process |= visible !== track.visible
|
process |= public !== track.public
|
||||||
track.visible = visible
|
track.public = public
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileBody) {
|
if (fileBody) {
|
||||||
|
|
|
@ -114,13 +114,13 @@ const TrackEditor = connect((state) => ({login: state.login}))(function TrackEdi
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
<label>Visibility</label>
|
<label>Visibility</label>
|
||||||
<Controller
|
<Controller
|
||||||
name="visible"
|
name="public"
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue={track?.visible}
|
defaultValue={track?.public}
|
||||||
render={(props) => (
|
render={(props) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
name="visible"
|
name="public"
|
||||||
label="Make track visible in public track list"
|
label="Make track public (in track list and details page)"
|
||||||
checked={props.value}
|
checked={props.value}
|
||||||
onChange={(_, {checked}) => props.onChange(checked)}
|
onChange={(_, {checked}) => props.onChange(checked)}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -11,10 +11,10 @@ function formatDuration(seconds) {
|
||||||
export default function TrackDetails({track, isAuthor}) {
|
export default function TrackDetails({track, isAuthor}) {
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
{track.visible != null && isAuthor && (
|
{track.public != null && isAuthor && (
|
||||||
<List.Item>
|
<List.Item>
|
||||||
<List.Header>Visibility</List.Header>
|
<List.Header>Visibility</List.Header>
|
||||||
{track.visible ? 'Public' : 'Private'}
|
{track.public ? 'Public' : 'Private'}
|
||||||
</List.Item>
|
</List.Item>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ export function TrackListItem({track, privateTracks = false}) {
|
||||||
</Item.Description>
|
</Item.Description>
|
||||||
{privateTracks && (
|
{privateTracks && (
|
||||||
<Item.Extra>
|
<Item.Extra>
|
||||||
{track.visible ? (
|
{track.public ? (
|
||||||
<>
|
<>
|
||||||
<Icon color="blue" name="eye" fitted /> Public
|
<Icon color="blue" name="eye" fitted /> Public
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -24,7 +24,7 @@ export type Track = {
|
||||||
title: string
|
title: string
|
||||||
description?: string
|
description?: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
visible?: boolean
|
public?: boolean
|
||||||
statistics?: TrackStatistics
|
statistics?: TrackStatistics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue