diff --git a/web/components/config/edit-string-array.tsx b/web/components/config/edit-string-array.tsx
new file mode 100644
index 000000000..873ad59bf
--- /dev/null
+++ b/web/components/config/edit-string-array.tsx
@@ -0,0 +1,86 @@
+/* eslint-disable react/no-array-index-key */
+import React, { useState } from 'react';
+import { Typography, Tag } from 'antd';
+
+import TextField from './form-textfield';
+import { UpdateArgs } from '../../types/config-section';
+import { StatusState } from '../../utils/input-statuses';
+
+const { Title } = Typography;
+
+export const TAG_COLOR = '#5a67d8';
+
+interface EditStringArrayProps {
+ title: string;
+ description?: string;
+ placeholder: string;
+ maxLength?: number;
+ values: string[];
+ submitStatus?: StatusState;
+ handleDeleteIndex: (index: number) => void;
+ handleCreateString: (arg: string) => void;
+}
+
+export default function EditValueArray(props: EditStringArrayProps) {
+ const [newStringInput, setNewStringInput] = useState('');
+ const {
+ title,
+ description,
+ placeholder,
+ maxLength,
+ values,
+ handleDeleteIndex,
+ handleCreateString,
+ submitStatus,
+ } = props;
+
+ const handleInputChange = ({ value }: UpdateArgs) => {
+ setNewStringInput(value);
+ };
+
+ const handleSubmitNewString = () => {
+ const newString = newStringInput.trim();
+ handleCreateString(newString);
+ setNewStringInput('');
+ };
+
+ return (
+
+
+ {title}
+
+
{description}
+
+
+ {values.map((tag, index) => {
+ const handleClose = () => {
+ handleDeleteIndex(index);
+ };
+ return (
+
+ {tag}
+
+ );
+ })}
+
+
+
+
+
+
+ );
+}
+
+EditValueArray.defaultProps = {
+ maxLength: 50,
+ description: null,
+ submitStatus: null,
+};
diff --git a/web/components/config/edit-tags.tsx b/web/components/config/edit-tags.tsx
index 27441945c..5a1ea6c93 100644
--- a/web/components/config/edit-tags.tsx
+++ b/web/components/config/edit-tags.tsx
@@ -18,11 +18,10 @@ import {
STATUS_SUCCESS,
STATUS_WARNING,
} from '../../utils/input-statuses';
+import { TAG_COLOR } from './edit-string-array';
const { Title } = Typography;
-const TAG_COLOR = '#5a67d8';
-
export default function EditInstanceTags() {
const [newTagInput, setNewTagInput] = useState('');
const [submitStatus, setSubmitStatus] = useState(null);
@@ -110,7 +109,7 @@ export default function EditInstanceTags() {
This is a great way to categorize your Owncast server on the Directory!
-
+
{tags.map((tag, index) => {
const handleClose = () => {
handleDeleteTag(index);
@@ -123,7 +122,7 @@ export default function EditInstanceTags() {
})}
-
+
{
+ setFieldInConfigState({
+ fieldName: 'forbiddenUsernames',
+ value: formDataValues.forbiddenUsernames,
+ });
+ setForbidenUsernameSaveState(STATUS_SUCCESS);
+ setTimeout(resetForbiddenUsernameState, RESET_TIMEOUT);
+ },
+ onError: (message: string) => {
+ setForbidenUsernameSaveState(createInputStatus(STATUS_ERROR, message));
+ setTimeout(resetForbiddenUsernameState, RESET_TIMEOUT);
+ },
+ });
+ }
+
+ function handleDeleteUsername(index: number) {
+ formDataValues.forbiddenUsernames.splice(index, 1);
+ saveForbiddenUsernames();
+ }
+
+ function handleCreateUsername(tag: string) {
+ formDataValues.forbiddenUsernames.push(tag);
+ handleFieldChange({
+ fieldName: 'forbiddenUsernames',
+ value: formDataValues.forbiddenUsernames,
+ });
+ saveForbiddenUsernames();
}
useEffect(() => {
@@ -59,13 +98,6 @@ export default function ConfigChat() {
checked={formDataValues.chatDisabled}
onChange={handleChatDisableChange}
/>
-
+
+
+
);
diff --git a/web/styles/config-tags.scss b/web/styles/config-edit-string-tags.scss
similarity index 82%
rename from web/styles/config-tags.scss
rename to web/styles/config-edit-string-tags.scss
index 462cd350d..2a8f96724 100644
--- a/web/styles/config-tags.scss
+++ b/web/styles/config-edit-string-tags.scss
@@ -1,18 +1,18 @@
// config tags block
-.tag-current-tags {
+.edit-current-strings {
.ant-tag {
- margin: .1rem;
- font-size: .85rem;
+ margin: 0.1rem;
+ font-size: 0.85rem;
border-radius: 10em;
- padding: .25em 1em;
+ padding: 0.25em 1em;
&:hover {
opacity: 1;
}
.ant-tag-close-icon {
transform: translateY(-1px);
- margin-left: .3rem;
+ margin-left: 0.3rem;
padding: 2px;
border-radius: 5rem;
color: var(--black);
@@ -30,7 +30,7 @@
}
}
-.add-new-tag-section {
+.add-new-string-section {
display: flex;
flex-direction: row;
justify-content: flex-start;
diff --git a/web/utils/config-constants.tsx b/web/utils/config-constants.tsx
index bd6699905..e2739fa6c 100644
--- a/web/utils/config-constants.tsx
+++ b/web/utils/config-constants.tsx
@@ -185,9 +185,9 @@ export const FIELD_PROPS_DISABLE_CHAT = {
export const TEXTFIELD_PROPS_CHAT_FORBIDDEN_USERNAMES = {
apiPath: API_CHAT_FORBIDDEN_USERNAMES,
- placeholder: 'admin,god,owncast,stewiegriffin',
+ placeholder: 'username',
label: 'Forbidden usernames',
- tip: 'A comma separated list of chat usernames you disallow.',
+ tip: 'A list of words in chat usernames you disallow.',
};
export const VIDEO_VARIANT_SETTING_DEFAULTS = {