Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Added functionality to delete a DataSource from the Data Connections page #419

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import intl from 'react-intl-universal';
import { Icon } from '@fluentui/react';
import { ButtonType, Icon } from '@fluentui/react';
import { observer } from 'mobx-react-lite';
import dayjs from 'dayjs';
import type { FC } from 'react';
import styled from 'styled-components';
import { Caption1, Card, CardHeader, Text } from '@fluentui/react-components';
import { Button, Caption1, Card, CardHeader, Text,CardFooter } from '@fluentui/react-components';
// import { MoreHorizontal20Filled } from '@fluentui/react-icons';
import { IDBMeta } from '../../../utils/storage';
import { RathDemoVirtualExt } from '../demo';
import { IDataSourceType } from '../../../global';
import getFileIcon from './get-file-icon';

import React from 'react';
import {deleteStorageByIdInLocal} from '../../../utils/storage'
const Desc = styled.p`
font-size: 12px;
`;
Expand Down Expand Up @@ -54,6 +54,13 @@ const HistoryListItem: FC<IHistoryListItemProps> = ({ file, rowIndex, colIndex,
const ext = file.name.endsWith(RathDemoVirtualExt) ? RathDemoVirtualExt : /\.([^./]+)$/.exec(file.name)?.[1];
const isRathDemo = ext === RathDemoVirtualExt;
const name = isRathDemo ? file.name.replace(new RegExp(`\\.${RathDemoVirtualExt.replaceAll(/\./g, '\\.')}$`), '') : file.name;
const handleDelete=(e:React.MouseEvent)=>{
e?.stopPropagation()
deleteStorageByIdInLocal(file.id).then(() => {
handleRefresh?.();
});
}


return (
<Card
Expand All @@ -71,8 +78,10 @@ const HistoryListItem: FC<IHistoryListItemProps> = ({ file, rowIndex, colIndex,
}
// action={<Button appearance="transparent" icon={<MoreHorizontal20Filled />} aria-label="More options" />}
/>

<Desc>{`${intl.get('dataSource.upload.lastOpen')}: ${dayjs(file.editTime).toDate().toLocaleString()}`}</Desc>
<CardFooter>
<Button onClick={handleDelete}>{`Delete`}</Button>
</CardFooter>
</Card>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const HistoryList: FC<IHistoryListProps> = props => {
const handleDeleteHistory = useCallback(
(id: string) => {
deleteDataStorageById(id).then(() => {
fetchDataStorageList();
fetchDataStorageList(false);
});
},
[fetchDataStorageList]
Expand Down Expand Up @@ -192,15 +192,15 @@ const HistoryList: FC<IHistoryListProps> = props => {
<List role="grid" aria-colcount={colCount || 1} style={{ gridTemplateColumns: `repeat(${colCount || 1}, 1fr)` }}>
{group.list.map((file, i) => (
<HistoryListItem
appearance={appearance}
key={i}
file={file}
rowIndex={Math.floor(i / colCount) + 1}
colIndex={(i % colCount) + 1}
handleClick={handleLoadHistory}
handleClearClick={handleDeleteHistory}
handleRefresh={() => fetchDataStorageList(false)}
/>
appearance={appearance}
key={i}
file={file}
rowIndex={Math.floor(i / colCount) + 1}
colIndex={(i % colCount) + 1}
handleClick={handleLoadHistory}
handleClearClick={handleDeleteHistory}
handleRefresh={() => fetchDataStorageList(false)}
/>
))}
</List>
</Fragment>
Expand Down