Skip to content

Commit e476caf

Browse files
authored
Adds publish templates and copy from upload (#3428)
* Adds publish templates and copy from upload Introduces upload templates for channels, allowing users to save and apply pre-defined settings to new uploads. Adds a "Copy from Previous Upload" modal, enabling users to populate the publish form with metadata from their previously published content. Enhances upload search and template flows Improves publish template functionality Enhances the publish template feature by disabling the "Save Current as Template" option when no changes are detected in the publish form. Additionally, increases the number of recent uploads displayed in the copy from upload modal and updates the hint text to reflect this change. Also provides default values for template comparison. * address coderabbit reviews Fixes an issue where optimistic templates were not cleared when channel settings became available or changed. This ensures that the UI reflects the correct template status after settings are loaded or modified. Also corrects a typo in the scss, and improves the hint in the copy from upload modal, clarifying the behavior of short search terms. * Improves template preview and snackbar styling Enhances the template preview to accurately display price details based on the paywall configuration. It introduces a check to ensure price information is shown only when relevant to the selected paywall type. Additionally, updates the snackbar styling to improve button appearance and provide a more consistent user experience. Refactors: Uses shared deep clone utility Removes duplicate deep clone functions and uses the newly created shared utility. This ensures consistency and reduces code duplication. * Improves upload template and metadata handling - Sorts languages for comparison in the copy from upload modal to prevent false positives. - Replaces custom deep clone function with `cloneDeep` from `util/clone` for template duplication in the upload template modal, fixing potential issues with the previous implementation. - Improves snackbar button styles.
1 parent eec53f3 commit e476caf

File tree

23 files changed

+3954
-25
lines changed

23 files changed

+3954
-25
lines changed

flow-typed/Comment.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
declare type CommentBody = string;
22
declare type CommentId = string;
33

4+
declare type UploadTemplateData = {
5+
title?: string,
6+
description?: string,
7+
tags?: Array<{ name: string }>,
8+
thumbnail?: string,
9+
language?: string,
10+
languages?: Array<string>,
11+
licenseType?: string,
12+
licenseUrl?: string,
13+
otherLicenseDescription?: string,
14+
nsfw?: boolean,
15+
paywall?: string,
16+
fee?: { amount: number, currency: string },
17+
fiatPurchaseFee?: Price,
18+
fiatPurchaseEnabled?: boolean,
19+
fiatRentalFee?: Price,
20+
fiatRentalExpiration?: Duration,
21+
fiatRentalEnabled?: boolean,
22+
visibility?: string,
23+
memberRestrictionOn?: boolean,
24+
memberRestrictionTierIds?: Array<number>,
25+
};
26+
27+
declare type UploadTemplate = {
28+
id: string,
29+
name: string,
30+
createdAt: number,
31+
lastUsedAt?: number,
32+
isPinned?: boolean,
33+
data: UploadTemplateData,
34+
};
35+
436
declare type Comment = {|
537
comment: CommentBody,
638
comment_id: CommentId, // sha256 digest
@@ -81,6 +113,7 @@ declare type PerChannelSettings = {
81113
livestream_chat_members_only?: boolean,
82114
comments_members_only?: boolean,
83115
homepage_settings?: any,
116+
upload_templates?: Array<UploadTemplate>,
84117
channel_sections?: Sections,
85118
};
86119

@@ -355,6 +388,8 @@ declare type SettingsResponse = {
355388
filters_enabled?: boolean,
356389
livestream_chat_members_only?: boolean,
357390
comments_members_only?: boolean,
391+
homepage_settings?: any,
392+
upload_templates?: Array<UploadTemplate>,
358393
};
359394

360395
declare type UpdateSettingsParams = {
@@ -371,6 +406,8 @@ declare type UpdateSettingsParams = {
371406
time_since_first_comment?: number,
372407
livestream_chat_members_only?: boolean,
373408
comments_members_only?: boolean,
409+
homepage_settings?: any,
410+
upload_templates?: Array<UploadTemplate>,
374411
};
375412

376413
declare type BlockWordParams = {

ui/component/publish/shared/publishFormErrors/view.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { BITRATE } from 'constants/publish';
88

99
type Props = {
1010
waitForFile: boolean,
11+
missingRequiredFile?: boolean,
1112
// --- redux ---
1213
title: ?string,
1314
name: ?string,
@@ -41,6 +42,7 @@ function PublishFormErrors(props: Props) {
4142
releaseTimeError,
4243
memberRestrictionStatus,
4344
waitForFile,
45+
missingRequiredFile,
4446
fileBitrate,
4547
fileSizeTooBig,
4648
prevFileSizeTooBig,
@@ -60,6 +62,7 @@ function PublishFormErrors(props: Props) {
6062
return (
6163
<div className="error__text">
6264
{waitForFile && <div>{__('Choose a replay file, or select None')}</div>}
65+
{missingRequiredFile && <div>{__('Choose a file to upload')}</div>}
6366
{missingTiers && <div>{__(HELP.NO_TIERS_SELECTED)}</div>}
6467
{fileSizeTooBig && !(isStillEditing && prevFileSizeTooBig) && <div>{UPLOAD_SIZE_MESSAGE}</div>}
6568
{fileBitrate > BITRATE.MAX && (
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { connect } from 'react-redux';
2+
import { selectActiveChannelClaim, selectActiveChannelId } from 'redux/selectors/app';
3+
import { selectMyChannelClaims } from 'redux/selectors/claims';
4+
import { selectPublishFormValues } from 'redux/selectors/publish';
5+
import { selectSettingsByChannelId } from 'redux/selectors/comments';
6+
import { doUpdatePublishForm } from 'redux/actions/publish';
7+
import { doFetchCreatorSettings, doUpdateCreatorSettings } from 'redux/actions/comments';
8+
import { doOpenModal } from 'redux/actions/app';
9+
import { doToast } from 'redux/actions/notifications';
10+
import PublishTemplateButton from './view';
11+
12+
const select = (state) => {
13+
const publishFormValues = selectPublishFormValues(state);
14+
const activeChannelId = selectActiveChannelId(state);
15+
const currentPublishChannelId = publishFormValues.channelId || activeChannelId;
16+
17+
return {
18+
defaultChannelId: currentPublishChannelId,
19+
myChannelClaims: selectMyChannelClaims(state) || [],
20+
settingsByChannelId: selectSettingsByChannelId(state),
21+
activeChannelClaim: selectActiveChannelClaim(state),
22+
publishFormValues,
23+
};
24+
};
25+
26+
const perform = {
27+
openModal: doOpenModal,
28+
updatePublishForm: doUpdatePublishForm,
29+
fetchCreatorSettings: doFetchCreatorSettings,
30+
doUpdateCreatorSettings,
31+
doToast,
32+
};
33+
34+
export default connect(select, perform)(PublishTemplateButton);

0 commit comments

Comments
 (0)