From 93fa75df2ef8605257b5efb27d3ff0bfc93dda17 Mon Sep 17 00:00:00 2001 From: gingervitis Date: Sun, 17 Jan 2021 01:41:00 -0800 Subject: [PATCH] add delete variant button --- .../config/video-variants-table.tsx | 48 ++++++++++++++----- web/styles/config.scss | 13 ++++- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/web/pages/components/config/video-variants-table.tsx b/web/pages/components/config/video-variants-table.tsx index 22b9fd3f2..a368368d2 100644 --- a/web/pages/components/config/video-variants-table.tsx +++ b/web/pages/components/config/video-variants-table.tsx @@ -4,6 +4,7 @@ import React, { useContext, useState } from 'react'; import { Typography, Table, Modal, Button } from 'antd'; import { ColumnsType } from 'antd/lib/table'; +import { DeleteOutlined } from '@ant-design/icons'; import { ServerStatusContext } from '../../../utils/server-status-context'; import { UpdateArgs, VideoVariant } from '../../../types/config-section'; import VideoVariantForm from './video-variant-form'; @@ -85,7 +86,15 @@ export default function CurrentVariantsTable() { postData.splice(editId, 1, modalDataState); } postUpdateToAPI(postData); - } + }; + + const handleDeleteVariant = index => { + const postData = [ + ...videoQualityVariants, + ]; + postData.splice(index, 1); + postUpdateToAPI(postData) + }; const handleUpdateField = ({ fieldName, value }: UpdateArgs) => { setModalDataState({ @@ -124,18 +133,30 @@ export default function CurrentVariantsTable() { title: '', dataIndex: '', key: 'edit', - render: (data: VideoVariant) => ( - - ), - }, - ]; + render: (data: VideoVariant) => { + const index = data.key - 1; + return ( + + +