Skip to content

Commit

Permalink
feat(filemanager): Show folder in file list
Browse files Browse the repository at this point in the history
  • Loading branch information
Anu-Ujin Bat-Ulzii authored and Anu-Ujin Bat-Ulzii committed Mar 20, 2023
1 parent 7b0dcf6 commit e4c28bf
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 33 deletions.
Expand Up @@ -146,12 +146,7 @@ function FileManager({
}
content={
<DataWithLoader
data={
<FileList
queryParams={queryParams}
// currentFolderId={currentFolder._id}
/>
}
data={<FileList queryParams={queryParams} />}
loading={false}
count={100}
emptyContent={
Expand Down
@@ -1,16 +1,12 @@
import { IFile, IFolder } from '../../types';

import DataWithLoader from '@erxes/ui/src/components/DataWithLoader';
import { EMPTY_CONTENT_FILES } from '../../constants';
import EmptyContent from '@erxes/ui/src/components/empty/EmptyContent';
import EmptyState from '@erxes/ui/src/components/EmptyState';
import FileRow from './FileRow';
import FormControl from '@erxes/ui/src/components/form/Control';
import { ItemName } from '../../styles';
import React from 'react';
import { RowArticle } from './styles';
import SortHandler from '@erxes/ui/src/components/SortHandler';
import Spinner from '@erxes/ui/src/components/Spinner';
import Table from '@erxes/ui/src/components/table';
import { __ } from '@erxes/ui/src/utils';
import withTableWrapper from '@erxes/ui/src/components/table/withTableWrapper';
Expand Down Expand Up @@ -74,14 +70,14 @@ class FileList extends React.Component<Props> {
</thead>
<tbody id="fileManagerfiles">
<>
{/* {folders.map((folder: IFolder) => (
{folders.map((folder: IFolder) => (
<FileRow
key={folder._id}
item={folder}
queryParams={queryParams}
isFolder={true}
/>
))} */}
))}
{files.map(file => (
<FileRow
key={file._id}
Expand Down
29 changes: 21 additions & 8 deletions packages/plugin-filemanager-ui/src/components/file/FileRow.tsx
Expand Up @@ -9,13 +9,12 @@ import React from 'react';
import Tip from '@erxes/ui/src/components/Tip';
import { __ } from 'coreui/utils';
import dayjs from 'dayjs';
import { readFile } from '@erxes/ui/src/utils';
import { renderFileIcon } from '../../utils';

type Props = {
item: any;
queryParams: any;
remove: (fileId: string) => void;
remove?: (fileId: string) => void;
isFolder?: boolean;
isChecked?: boolean;
toggleBulk?: (target: any, toAdd: boolean) => void;
Expand All @@ -42,7 +41,9 @@ const FileRow = ({
};

const onRemove = () => {
remove(item._id);
if (remove) {
remove(item._id);
}
};

const renderEditAction = () => {
Expand Down Expand Up @@ -74,8 +75,18 @@ const FileRow = ({
</td>
<td style={{ paddingLeft: '0' }}>
<ItemName>
<a href={`/filemanager/details/${item._id}`}>
{renderFileIcon(item.type === 'dynamic' ? 'aaa.dynamic' : name)}
<a
href={
isFolder
? `/filemanager/folder/details/${item._id}`
: `/filemanager/details/${item._id}`
}
>
{isFolder ? (
<img src="/images/folder.png" alt="folder" />
) : (
renderFileIcon(item.type === 'dynamic' ? 'aaa.dynamic' : name)
)}
{isFolder || item.contentType ? item.name : name}
</a>
</ItemName>
Expand All @@ -85,9 +96,11 @@ const FileRow = ({
<td>
<ActionButtons>
{/* {item.contentType && renderEditAction()} */}
<Tip text={__('Delete')} placement="bottom">
<Button btnStyle="link" onClick={onRemove} icon="cancel-1" />
</Tip>
{remove && (
<Tip text={__('Delete')} placement="bottom">
<Button btnStyle="link" onClick={onRemove} icon="cancel-1" />
</Tip>
)}
</ActionButtons>
</td>
</tr>
Expand Down
Expand Up @@ -37,7 +37,7 @@ const FolderFormContainer = (props: FinalProps) => {
mutation={mutations.filemanagerFolderSave}
variables={values}
callback={callback}
refetchQueries={getRefetchQueries()}
refetchQueries={getRefetchQueries(values.parentId)}
isSubmitted={isSubmitted}
type="submit"
successMessage={`You successfully ${
Expand All @@ -55,10 +55,13 @@ const FolderFormContainer = (props: FinalProps) => {
return <FolderForm {...updatedProps} />;
};

const getRefetchQueries = () => {
const getRefetchQueries = (parentId?: string) => {
return [
{
query: gql(queries.filemanagerFolders)
query: gql(queries.filemanagerFolders),
variables: {
parentId: parentId ? parentId : ''
}
}
];
};
Expand Down
Expand Up @@ -30,13 +30,7 @@ type FinalProps = {
RemoveFilemanagerFolderMutationResponse;

const FolderListContainer = (props: FinalProps) => {
const {
removeMutation,
filemanagerFolders,
history,
parentFolderId,
filemanagerFoldersQuery
} = props;
const { removeMutation, filemanagerFolders, filemanagerFoldersQuery } = props;

const getDifference = (array1, array2) => {
return array1.filter(object1 =>
Expand All @@ -52,8 +46,6 @@ const FolderListContainer = (props: FinalProps) => {
})
.then(() => {
Alert.success('You successfully deleted a folder.');

history.push('/filemanager');
})
.catch(error => {
Alert.error(error.message);
Expand All @@ -76,7 +68,6 @@ const FolderListContainer = (props: FinalProps) => {

const updatedProps = {
...props,
childrens: [],
filemanagerFolders,
remove
};
Expand Down

0 comments on commit e4c28bf

Please sign in to comment.