From d0eb1446f3a79b778c45b9bd679f74e4d87aa9cb Mon Sep 17 00:00:00 2001 From: gingervitis Date: Sat, 22 May 2021 23:27:51 -0700 Subject: [PATCH] fixes for various admin issues (#181) * up max char count for variant name to fix https://github.com/owncast/owncast/issues/1037 * max widthing the line chart canvas size so it scales with the page. fixes - https://github.com/owncast/owncast/issues/842 - https://github.com/owncast/owncast/issues/1024 * A fix to make Storage Endpoint URL validation have better feedback. - give the field a type of "url" - give the field a pattern to check - have native browser handle the validation - if the field is invalid, use :invalid selector to turn the text red on blur. fixes: https://github.com/owncast/owncast/issues/1000 * a fix for https://github.com/owncast/owncast/issues/874 * - fixes for https://github.com/owncast/owncast/issues/972 Add optional prop to text field to trim() whitespaces from field. Apply logic to mostly url fields. - move textfield blur if invalid turn red to globaal * - a fix for bug: https://github.com/owncast/owncast/issues/998 don't return null if platform name not found because its custom. - clean up react key problem on socialhandles table * fix react key issue on Actions table * fix for https://github.com/owncast/owncast/issues/1008 to display 'other' field when editing an item not in predefined social list * clean up other potential react key warnings * Prettified Code! Co-authored-by: gingervitis --- web/components/config/edit-social-links.tsx | 30 ++++++++++++--- .../config/form-textfield-with-submit.tsx | 3 +- web/components/config/form-textfield.tsx | 13 +++++-- .../config/video-codec-selector.tsx | 4 +- web/components/config/video-variant-form.tsx | 2 +- web/pages/actions.tsx | 37 +++++++++++++------ web/pages/config-video.tsx | 2 +- web/pages/hardware-info.tsx | 6 +-- web/pages/help.tsx | 8 ++-- web/pages/upgrade.tsx | 10 ++++- web/pages/webhooks.tsx | 23 ++++++++---- web/styles/config-video-variants.scss | 5 +++ web/styles/globals.scss | 14 +++++++ web/utils/config-constants.tsx | 15 +++++++- web/utils/urls.ts | 3 ++ 15 files changed, 132 insertions(+), 43 deletions(-) diff --git a/web/components/config/edit-social-links.tsx b/web/components/config/edit-social-links.tsx index 0b7d4ebbb..d51b43463 100644 --- a/web/components/config/edit-social-links.tsx +++ b/web/components/config/edit-social-links.tsx @@ -13,7 +13,7 @@ import { OTHER_SOCIAL_HANDLE_OPTION, } from '../../utils/config-constants'; import { SocialHandle, UpdateArgs } from '../../types/config-section'; -import isValidUrl from '../../utils/urls'; +import isValidUrl, { DEFAULT_TEXTFIELD_URL_PATTERN } from '../../utils/urls'; import TextField from './form-textfield'; import { createInputStatus, STATUS_ERROR, STATUS_SUCCESS } from '../../utils/input-statuses'; import FormStatusIndicator from './form-status-indicator'; @@ -62,6 +62,10 @@ export default function EditSocialLinks() { } }; + const isPredefinedSocial = (platform: string) => { + return availableIconsList.find(item => item.key === platform) || false; + }; + const selectedOther = modalDataState.platform !== '' && !availableIconsList.find(item => item.key === modalDataState.platform); @@ -172,9 +176,18 @@ export default function EditSocialLinks() { key: 'combo', render: (data, record) => { const { platform, url } = record; - const platformInfo = availableIconsList.find(item => item.key === platform); + const platformInfo = isPredefinedSocial(platform); + + // custom platform case if (!platformInfo) { - return platform; + return ( +
+

+ {platform} + {url} +

+
+ ); } const { icon, platform: platformName } = platformInfo; const iconUrl = NEXT_PUBLIC_API_HOST + `${icon.slice(1)}`; @@ -201,9 +214,13 @@ export default function EditSocialLinks() {