Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

hotfix: share toggle #178

Merged
merged 4 commits into from
Jan 8, 2022
Merged
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
10 changes: 5 additions & 5 deletions web/src/pages/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,16 @@ const View: React.FC<PageProps> = ({ match }) => {
onClick: () => onRowClick(row)
}),
render: (_: any, row: any) => {
let type
let type: any
if (row.sharing_options?.includes('*')) {
type = <GlobalOutlined />
} else if (row.sharing_options?.length) {
type = <TeamOutlined />
}

return <>
return <Button type="text" block style={{ textAlign: 'left', padding: 0 }}>
{row.link_id ? <BranchesOutlined /> : '' } {type} <Icon type={row.type} /> {row.name}
</>
</Button>
}
},
{
Expand Down Expand Up @@ -396,7 +396,7 @@ const View: React.FC<PageProps> = ({ match }) => {
</Layout.Content>
<Footer me={me} />
<ContextMenu />
<Modal title={<><Icon type={showDetails?.type} /> {showDetails?.name}</>}
<Modal title={<Typography.Text ellipsis><Icon type={showDetails?.type} /> {showDetails?.name}</Typography.Text>}
visible={Boolean(showDetails)}
onCancel={() => setShowDetails(undefined)}
okText="View"
Expand All @@ -405,7 +405,7 @@ const View: React.FC<PageProps> = ({ match }) => {
okButtonProps={{ shape: 'round' }}>
<Descriptions column={1}>
<Descriptions.Item label="Size">{showDetails?.size && prettyBytes(Number(showDetails?.size || 0))}</Descriptions.Item>
<Descriptions.Item label="Uploaded At">{moment(showDetails?.uploaded_at).local().format('llll')}</Descriptions.Item>
<Descriptions.Item label="Uploaded At">{moment(showDetails?.uploaded_at).local().format('lll')}</Descriptions.Item>
</Descriptions>
</Modal>
</Layout> : <>
Expand Down
1 change: 0 additions & 1 deletion web/src/pages/dashboard/components/AddFolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const AddFolder: React.FC<Props> = ({
setAddFolder(false)
setLoadingAddFolder(false)
} catch (error: any) {
console.error(error)
setLoadingAddFolder(false)
return notification.error({
message: 'Error',
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/dashboard/components/Messaging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ const Messaging: React.FC<Props> = ({ me, collapsed, parent, setCollapsed }) =>
title: user ? user.title || `${user.firstName || ''} ${user.lastName || ''}`.trim() : 'Unknown',
onTitleClick: () => user?.username ? window.open(`https://t.me/${user?.username}`, '_blank') : undefined,
titleColor: '#0088CC',
text: `${fileTitle.slice(0, 20)}${fileTitle.length > 20 ? '...' : ''}`,
message: `${fileTitle.slice(0, 20)}${fileTitle.length > 20 ? '...' : ''}`,
text: `${fileTitle.slice(0, 16)}${fileTitle.length > 16 ? '...' : ''}`,
message: `${fileTitle.slice(0, 16)}${fileTitle.length > 16 ? '...' : ''}`,
status: me?.user.tg_id == user?.id ? msg.id <= dialog?.dialog?.readOutboxMaxId ? 'read' : 'received' : undefined,
date: msg.date * 1000,
user,
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/dashboard/components/Rename.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, Form, Input, notification } from 'antd'
import { Modal, Form, Input, notification, Typography } from 'antd'
import { useForm } from 'antd/lib/form/Form'
import React, { useState, useEffect } from 'react'
import { req } from '../../../utils/Fetcher'
Expand Down Expand Up @@ -51,7 +51,7 @@ const Rename: React.FC<Props> = ({
return <Modal visible={fileRename}
onCancel={() => setFileRename(undefined)}
okText="Add"
title={`Rename ${fileRename?.name}`}
title={<Typography.Text ellipsis>Rename {fileRename?.name}</Typography.Text>}
onOk={() => formRename.submit()}
cancelButtonProps={{ shape: 'round' }}
okButtonProps={{ loading: loadingRename, shape: 'round' }}>
Expand Down
11 changes: 7 additions & 4 deletions web/src/pages/dashboard/components/Share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ const Share: React.FC<Props> = ({
setLoadingShare(true)
const { id, public: isPublic, sharing_options: sharingOpts, username } = formShare.getFieldsValue()

const sharing = sharingOpts?.length ? [
...new Set([...sharingOpts === undefined ? sharingOptions : sharingOpts, isPublic ? '*' : null]
.filter(sh => isPublic ? sh : sh !== '*').filter(Boolean)) as any
const sharing = (sharingOpts || sharingOptions)?.length || isPublic ? [
...new Set([
...sharingOpts === undefined ? sharingOptions : sharingOpts,
isPublic ? '*' : null
].filter(sh => isPublic ? sh : sh !== '*').filter(Boolean)) as any
] : []
console.log(isPublic, sharing, sharingOptions, sharingOpts)
setSharingOptions(sharing)

try {
Expand Down Expand Up @@ -111,7 +114,7 @@ const Share: React.FC<Props> = ({
return <Modal visible={selectShare?.row}
onCancel={() => setSelectShare(undefined)}
footer={null}
title={`${selectShare?.action === 'share' ? 'Share' : 'Send'} ${selectShare?.row.name}`}>
title={<Typography.Text ellipsis>{selectShare?.action === 'share' ? 'Share' : 'Send'} {selectShare?.row.name}</Typography.Text>}>
<Form form={formShare} layout="horizontal" onFinish={share}>
<Form.Item name="id" hidden>
<Input />
Expand Down
6 changes: 3 additions & 3 deletions web/src/pages/dashboard/components/TableFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TeamOutlined,
VideoCameraOutlined
} from '@ant-design/icons'
import { Descriptions, Menu, Modal, Table } from 'antd'
import { Descriptions, Menu, Modal, Table, Typography } from 'antd'
import { SorterResult } from 'antd/lib/table/interface'
import moment from 'moment'
import prettyBytes from 'pretty-bytes'
Expand Down Expand Up @@ -326,7 +326,7 @@ const TableFiles: React.FC<Props> = ({
} : undefined} />
</DndProvider>
<ContextMenu />
<Modal title={<><Icon type={showDetails?.type} /> {showDetails?.name}</>}
<Modal title={<Typography.Text ellipsis><Icon type={showDetails?.type} /> {showDetails?.name}</Typography.Text>}
visible={Boolean(showDetails)}
onCancel={() => setShowDetails(undefined)}
okText="View"
Expand All @@ -335,7 +335,7 @@ const TableFiles: React.FC<Props> = ({
okButtonProps={{ shape: 'round' }}>
<Descriptions column={1}>
<Descriptions.Item label="Size">{showDetails?.size && prettyBytes(Number(showDetails?.size || 0))}</Descriptions.Item>
<Descriptions.Item label="Uploaded At">{moment(showDetails?.uploaded_at).local().format('llll')}</Descriptions.Item>
<Descriptions.Item label="Uploaded At">{moment(showDetails?.uploaded_at).local().format('lll')}</Descriptions.Item>
<Descriptions.Item label="Uploaded By">
<a href={`https://t.me/${user?.user.username}`} target="_blank">@{user?.user.username}</a>
</Descriptions.Item>
Expand Down