Skip to content
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
4 changes: 4 additions & 0 deletions apps/webapp/src/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@
"cells.newItemMenuModal.headlineFile": "Create file",
"cells.newItemMenuModal.headlineFolder": "Create folder",
"cells.newItemMenuModal.label": "Name",
"cells.newItemMenuModal.typeLabel": "File type",
"cells.newItemMenuModal.typeDocument": "Document (.docx)",
"cells.newItemMenuModal.typeSpreadsheet": "Spreadsheet (.xlsx)",
"cells.newItemMenuModal.typePresentation": "Presentation (.pptx)",
"cells.newItemMenuModal.placeholderFile": "Enter file name",
"cells.newItemMenuModal.placeholderFolder": "Enter folder name",
"cells.newItemMenuModal.primaryAction": "Create",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*
*/

import {useState} from 'react';

import {QualifiedId} from '@wireapp/api-client/lib/user';

import {CellsNewNodeForm} from 'Components/Conversation/ConversationCells/common/CellsNewNodeForm/CellsNewNodeForm';
Expand All @@ -27,6 +29,7 @@ import {t} from 'Util/LocalizerUtil';

import {descriptionStyles} from './CellsNewItemModal.styles';

import {useCellsFilePreviewModal} from '../../../CellsTable/common/CellsFilePreviewModalContext/CellsFilePreviewModalContext';
import {CellsModal} from '../../../common/CellsModal/CellsModal';

interface CellsNewItemModalProps {
Expand All @@ -49,22 +52,32 @@ export const CellsNewItemModal = ({
currentPath,
}: CellsNewItemModalProps) => {
const isFolder = type === 'folder';
const {handleOpenFile} = useCellsFilePreviewModal();

const fileTypeOptions = [
{value: 'docx', label: t('cells.newItemMenuModal.typeDocument')},
{value: 'xlsx', label: t('cells.newItemMenuModal.typeSpreadsheet')},
{value: 'pptx', label: t('cells.newItemMenuModal.typePresentation')},
];
const [selectedFileType, setSelectedFileType] = useState(fileTypeOptions[0]);

const {name, error, isSubmitting, handleSubmit, handleChange} = useCellsNewItemForm({
type,
cellsRepository,
conversationQualifiedId,
onSuccess,
currentPath,
fileExtension: type === 'file' ? selectedFileType.value : undefined,
onCreatedFile: type === 'file' ? file => handleOpenFile(file, true) : undefined,
});

return (
<CellsModal isOpen={isOpen} onClose={onClose} size="large">
<CellsModal.Header>
{t(isFolder ? 'cells.newItemMenuModal.headlineFolder' : 'cells.newItemMenuModal.headlineFile')}
{t(!isFolder ? 'cells.newItemMenuModal.headlineFolder' : 'cells.newItemMenuModal.headlineFile')}
</CellsModal.Header>
<p css={descriptionStyles}>
{t(isFolder ? 'cells.newItemMenuModal.descriptionFolder' : 'cells.newItemMenuModal.descriptionFile')}
{t(!isFolder ? 'cells.newItemMenuModal.descriptionFolder' : 'cells.newItemMenuModal.descriptionFile')}
</p>
<CellsNewNodeForm
type={type}
Expand All @@ -73,6 +86,9 @@ export const CellsNewItemModal = ({
onChange={handleChange}
error={error}
isOpen={isOpen}
fileTypeOptions={type === 'file' ? fileTypeOptions : undefined}
selectedFileType={type === 'file' ? selectedFileType : undefined}
onFileTypeChange={type === 'file' ? setSelectedFileType : undefined}
/>
<CellsModal.Actions>
<CellsModal.SecondaryButton onClick={onClose}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export const CellsNewMenu = ({cellsRepository, conversationQualifiedId, onRefres
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item onClick={() => openModal(CellNodeType.FILE)}>
{t('cells.newItemMenu.file')}
</DropdownMenu.Item>
<DropdownMenu.Item onClick={() => openModal(CellNodeType.FOLDER)}>
{t('cells.newItemMenu.folder')}
</DropdownMenu.Item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {QualifiedId} from '@wireapp/api-client/lib/user/';
import {CellsRepository} from 'Repositories/cells/CellsRepository';
import {CellNode} from 'src/script/types/cellNode';

import {CellsFilePreviewModal} from './CellsFilePreviewModal/CellsFilePreviewModal';
import {
headerCellStyles,
tableActionsCellStyles,
Expand All @@ -33,7 +32,6 @@ import {
wrapperStyles,
} from './CellsTable.styles';
import {getCellsTableColumns} from './CellsTableColumns/CellsTableColumns';
import {CellsFilePreviewModalProvider} from './common/CellsFilePreviewModalContext/CellsFilePreviewModalContext';

interface CellsTableProps {
nodes: Array<CellNode>;
Expand Down Expand Up @@ -64,51 +62,48 @@ export const CellsTable = ({
const rows = table.getRowModel().rows;

return (
<CellsFilePreviewModalProvider>
<div css={wrapperStyles}>
<table css={tableStyles}>
<thead>
{table.getHeaderGroups().map(headerGroup => (
<tr key={headerGroup.id}>
{headerGroup.headers.map(header => {
return (
<th
key={header.id}
css={headerCellStyles}
style={{
width: header.id == 'name' ? undefined : header.getSize(),
}}
>
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
</th>
);
})}
<div css={wrapperStyles}>
<table css={tableStyles}>
<thead>
{table.getHeaderGroups().map(headerGroup => (
<tr key={headerGroup.id}>
{headerGroup.headers.map(header => {
return (
<th
key={header.id}
css={headerCellStyles}
style={{
width: header.id == 'name' ? undefined : header.getSize(),
}}
>
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
</th>
);
})}
</tr>
))}
</thead>
{rows.length > 0 && (
<tbody>
{rows.map(row => (
<tr key={row.id} css={tableCellRow}>
{row.getVisibleCells().map(cell => (
<td
key={cell.id}
css={cell.column.id === 'id' ? tableActionsCellStyles : tableCellStyles}
data-cell={cell.column.id === 'id' ? undefined : cell.column.columnDef.header}
style={{
width: cell.column.id == 'name' ? undefined : cell.column.getSize(),
}}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
</tr>
))}
</thead>
{rows.length > 0 && (
<tbody>
{rows.map(row => (
<tr key={row.id} css={tableCellRow}>
{row.getVisibleCells().map(cell => (
<td
key={cell.id}
css={cell.column.id === 'id' ? tableActionsCellStyles : tableCellStyles}
data-cell={cell.column.id === 'id' ? undefined : cell.column.columnDef.header}
style={{
width: cell.column.id == 'name' ? undefined : cell.column.getSize(),
}}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
</tr>
))}
</tbody>
)}
</table>
<CellsFilePreviewModal />
</div>
</CellsFilePreviewModalProvider>
</tbody>
)}
</table>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import {CellsHeader} from './CellsHeader/CellsHeader';
import {CellsLoader} from './CellsLoader/CellsLoader';
import {CellsPagination} from './CellsPagination/CellsPagination';
import {CellsStateInfo} from './CellsStateInfo/CellsStateInfo';
import {CellsFilePreviewModal} from './CellsTable/CellsFilePreviewModal/CellsFilePreviewModal';
import {CellsTable} from './CellsTable/CellsTable';
import {CellsFilePreviewModalProvider} from './CellsTable/common/CellsFilePreviewModalContext/CellsFilePreviewModalContext';
import {isInRecycleBin} from './common/recycleBin/recycleBin';
import {useCellsStore} from './common/useCellsStore/useCellsStore';
import {wrapperStyles} from './ConversationCells.styles';
Expand Down Expand Up @@ -122,36 +124,39 @@ export const ConversationCells = memo(
const isEmptyRecycleBin = isInRecycleBin() && emptyView && !isLoading;

return (
<div css={wrapperStyles}>
<CellsHeader
onRefresh={handleRefresh}
conversationQualifiedId={conversationQualifiedId}
conversationName={name}
cellsRepository={cellsRepository}
searchValue={searchValue}
onSearchChange={handleSearch}
onSearchClear={handleClearSearch}
/>
{isTableVisible && (
<CellsTable
nodes={isLoading ? [] : nodes}
cellsRepository={cellsRepository}
<CellsFilePreviewModalProvider>
<div css={wrapperStyles}>
<CellsHeader
onRefresh={handleRefresh}
conversationQualifiedId={conversationQualifiedId}
conversationName={name}
onRefresh={handleRefresh}
cellsRepository={cellsRepository}
searchValue={searchValue}
onSearchChange={handleSearch}
onSearchClear={handleClearSearch}
/>
)}
{isCellsStatePending && !isRefreshing && (
<CellsStateInfo heading={t('cells.pending.heading')} description={t('cells.pending.description')} />
)}
{isNoNodesVisible && (
<CellsStateInfo heading={t('cells.noNodes.heading')} description={t('cells.noNodes.description')} />
)}
{isEmptyRecycleBin && <CellsStateInfo description={t('cells.emptyRecycleBin.description')} />}
{(isLoadingVisible || isRefreshing) && <CellsLoader />}
{isError && <CellsStateInfo heading={t('cells.error.heading')} description={t('cells.error.description')} />}
{isPaginationVisible && <CellsPagination {...getPaginationProps()} goToPage={goToPage} />}
</div>
{isTableVisible && (
<CellsTable
nodes={isLoading ? [] : nodes}
cellsRepository={cellsRepository}
conversationQualifiedId={conversationQualifiedId}
conversationName={name}
onRefresh={handleRefresh}
/>
)}
{isCellsStatePending && !isRefreshing && (
<CellsStateInfo heading={t('cells.pending.heading')} description={t('cells.pending.description')} />
)}
{isNoNodesVisible && (
<CellsStateInfo heading={t('cells.noNodes.heading')} description={t('cells.noNodes.description')} />
)}
{isEmptyRecycleBin && <CellsStateInfo description={t('cells.emptyRecycleBin.description')} />}
{(isLoadingVisible || isRefreshing) && <CellsLoader />}
{isError && <CellsStateInfo heading={t('cells.error.heading')} description={t('cells.error.description')} />}
{isPaginationVisible && <CellsPagination {...getPaginationProps()} goToPage={goToPage} />}
<CellsFilePreviewModal />
</div>
</CellsFilePreviewModalProvider>
);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ export const inputWrapperStyles: CSSObject = {
padding: '16px',
gap: '8px',
};

export const selectWrapperStyles: CSSObject = {
width: '100%',
};

export const selectStyles: CSSObject = {
width: '100%',
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

import {ChangeEvent, FormEvent} from 'react';

import {ErrorMessage, Input, Label} from '@wireapp/react-ui-kit';
import {ErrorMessage, Input, Label, Select} from '@wireapp/react-ui-kit';

import {CellNode} from 'src/script/types/cellNode';
import {t} from 'Util/LocalizerUtil';

import {inputWrapperStyles} from './CellsNewNodeForm.styles';
import {inputWrapperStyles, selectStyles, selectWrapperStyles} from './CellsNewNodeForm.styles';

import {useInputAutoFocus} from '../useInputAutoFocus/useInputAutoFocus';

Expand All @@ -35,14 +35,47 @@ interface CellsNewNodeFormProps {
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
error: string | null;
isOpen: boolean;
fileTypeOptions?: Array<{value: string; label: string}>;
selectedFileType?: {value: string; label: string};
onFileTypeChange?: (option: {value: string; label: string}) => void;
}

export const CellsNewNodeForm = ({type, onSubmit, inputValue, onChange, error, isOpen}: CellsNewNodeFormProps) => {
export const CellsNewNodeForm = ({
type,
onSubmit,
inputValue,
onChange,
error,
isOpen,
fileTypeOptions,
selectedFileType,
onFileTypeChange,
}: CellsNewNodeFormProps) => {
const {inputRef} = useInputAutoFocus({enabled: isOpen});

return (
<form onSubmit={onSubmit}>
<div css={inputWrapperStyles}>
{type === 'file' && fileTypeOptions && selectedFileType && onFileTypeChange && (
<>
<Label htmlFor="cells-new-item-type">{t('cells.newItemMenuModal.typeLabel')}</Label>
<div css={selectWrapperStyles}>
<Select
id="cells-new-item-type"
dataUieName="cells-new-item-type"
options={fileTypeOptions}
value={selectedFileType}
selectContainerCSS={selectStyles}
selectControlCSS={selectStyles}
onChange={option => {
if (option) {
onFileTypeChange(option as {value: string; label: string});
}
}}
/>
</div>
</>
)}
<Label htmlFor="cells-new-item-name">{t('cells.newItemMenuModal.label')}</Label>
<Input
id="cells-new-item-name"
Expand Down
Loading
Loading