Fix public links and menu dark mode

This commit is contained in:
Romaric Mourgues
2023-03-27 19:00:21 +02:00
parent 42420df02d
commit 1750c8f7f0
11 changed files with 24 additions and 28 deletions
@@ -319,7 +319,7 @@ export const checkAccess = async (
repository: Repository<DriveFile>, repository: Repository<DriveFile>,
context: CompanyExecutionContext & { public_token?: string; twake_tab_token?: string }, context: CompanyExecutionContext & { public_token?: string; twake_tab_token?: string },
): Promise<boolean> => { ): Promise<boolean> => {
if (context.user.server_request) { if (context.user?.server_request) {
return true; return true;
} }
@@ -266,7 +266,8 @@ export default class AutoComplete extends Component<Props, State> {
if (this.input && this.state.resultPosition === '' && this.state.currentList.length > 0) { if (this.input && this.state.resultPosition === '' && this.state.currentList.length > 0) {
const size = this.state.currentList.length * 32 + 5; const size = this.state.currentList.length * 32 + 5;
if ( if (
document.documentElement.clientHeight - (window as any).getBoundingClientRect(this.input).bottom < document.documentElement.clientHeight -
(window as any).getBoundingClientRect(this.input).bottom <
size || size ||
this.props.position === 'top' this.props.position === 'top'
) { ) {
@@ -366,7 +367,7 @@ export default class AutoComplete extends Component<Props, State> {
{!this.props.hideResult && this.state.currentList.length > 0 ? ( {!this.props.hideResult && this.state.currentList.length > 0 ? (
<div <div
className={ className={
'menu-list as_frame inline ' + 'menu-list as_frame bg-white text-black dark:bg-zinc-800 dark:text-white rounded-lg inline ' +
(this.state.focused && this.state.currentList.length ? 'fade_in ' : '') + (this.state.focused && this.state.currentList.length ? 'fade_in ' : '') +
this.state.resultPosition this.state.resultPosition
} }
@@ -17,7 +17,7 @@ import MenuManager from 'app/components/menus/menus-manager';
import { PendingFileRecoilType } from 'app/features/files/types/file'; import { PendingFileRecoilType } from 'app/features/files/types/file';
import { MessageFileType } from 'app/features/messages/types/message'; import { MessageFileType } from 'app/features/messages/types/message';
import { useFileViewerModal } from 'app/features/viewer/hooks/use-viewer'; import { useFileViewerModal } from 'app/features/viewer/hooks/use-viewer';
import { useEditors } from 'app/views/applications/viewer/other/editors-service'; import { useEditors } from 'app/views/client/viewer/other/editors-service';
type PropsType = { type PropsType = {
file: DataFileType; file: DataFileType;
@@ -40,7 +40,7 @@ export const FileActions = ({
const { cancelUpload, deleteOneFile, downloadOneFile, retryUpload } = useUpload(); const { cancelUpload, deleteOneFile, downloadOneFile, retryUpload } = useUpload();
const menuRef = useRef<HTMLElement>(); const menuRef = useRef<HTMLElement>();
const { open: openPreview } = useFileViewerModal(); const { open: openPreview } = useFileViewerModal();
const { candidates } = useEditors(file.name.split(".").pop() || "") const { candidates } = useEditors(file.name.split('.').pop() || '');
const onClickDownload = async () => { const onClickDownload = async () => {
file.company_id && file.company_id &&
@@ -53,7 +53,7 @@ export const FileActions = ({
const onClickOpen = async () => { const onClickOpen = async () => {
openPreview(messageFile); openPreview(messageFile);
} };
const buildMenu = (e: React.MouseEvent<HTMLElement, MouseEvent>) => { const buildMenu = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
e.stopPropagation(); e.stopPropagation();
@@ -66,7 +66,7 @@ export const FileActions = ({
}, },
]; ];
if(candidates.length > 0) { if (candidates.length > 0) {
const openerName = candidates[0].name || candidates[0].app?.identity.name; const openerName = candidates[0].name || candidates[0].app?.identity.name;
menu.push({ menu.push({
@@ -80,12 +80,9 @@ export const FileActions = ({
}); });
} }
MenuManager.openMenu( MenuManager.openMenu(menu, (window as any).getBoundingClientRect(menuRef.current), null, {
menu, margin: 0,
(window as any).getBoundingClientRect(menuRef.current), });
null,
{ margin: 0 },
);
}; };
const onClickCancel = (e: React.MouseEvent<HTMLElement, MouseEvent>) => { const onClickCancel = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
@@ -57,7 +57,7 @@ export default class MenuComponent extends React.Component {
<div <div
ref={node => (this.original_menu = node)} ref={node => (this.original_menu = node)}
className={ className={
'menu-list ' + (this.props.withFrame ? 'as_frame ' : '') + this.props.animationClass 'menu-list ' + (this.props.withFrame ? 'as_frame text-black bg-white dark:bg-zinc-800 dark:text-white rounded-lg ' : '') + this.props.animationClass
} }
> >
{(this.props.menu || []) {(this.props.menu || [])
@@ -26,9 +26,7 @@
} }
&.as_frame { &.as_frame {
border-radius: var(--border-radius-base);
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.05), 0 0 20px 0 rgba(0, 0, 0, 0.15); box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.05), 0 0 20px 0 rgba(0, 0, 0, 0.15);
background-color: var(--white);
width: 250px; width: 250px;
max-height: 80vh; max-height: 80vh;
overflow: auto; overflow: auto;
@@ -39,7 +37,6 @@
line-height: 32px; line-height: 32px;
font-size: 14px; font-size: 14px;
font-weight: bold; font-weight: bold;
color: var(--black);
margin: 0 8px; margin: 0 8px;
padding: 0 8px; padding: 0 8px;
} }
@@ -85,7 +82,6 @@
height: 32px; height: 32px;
line-height: 32px; line-height: 32px;
font-size: 14px; font-size: 14px;
color: var(--black);
margin: 0 8px; margin: 0 8px;
padding: 0 8px; padding: 0 8px;
border-radius: var(--border-radius-base); border-radius: var(--border-radius-base);
@@ -150,9 +150,12 @@ export const SuggestionList = <T,>(props: Props<T>): JSX.Element => {
return ( return (
<div className="suggestions" style={cssPosition}> <div className="suggestions" style={cssPosition}>
<div <div
className={classNames(['menu-list', 'as_frame', 'inline', 'top'], { className={classNames(
fade_in: isFocused && props.list?.length, ['menu-list', 'as_frame bg-white dark:bg-zinc-900 rounded-lg', 'inline', 'top'],
})} {
fade_in: isFocused && props.list?.length,
},
)}
> >
{props?.list && props.list.length > 0 ? ( {props?.list && props.list.length > 0 ? (
props.list.map((item, index) => { props.list.map((item, index) => {
@@ -85,7 +85,7 @@ export default memo(
//In case we are kicked out of the current folder, we need to reset the parent id //In case we are kicked out of the current folder, we need to reset the parent id
useEffect(() => { useEffect(() => {
if (!loading && !path?.length) setParentId('root'); if (!loading && !path?.length && !inPublicSharing) setParentId('root');
}, [path, loading, setParentId]); }, [path, loading, setParentId]);
useEffect(() => { useEffect(() => {
@@ -44,7 +44,7 @@ export const DocumentRow = ({
return ( return (
<div <div
className={ className={
'flex flex-row items-center border -mt-px px-4 py-3 cursor-pointer ' + 'flex flex-row items-center border border-zinc-200 dark:border-zinc-800 -mt-px px-4 py-3 cursor-pointer ' +
(checked (checked
? 'bg-blue-500 bg-opacity-10 hover:bg-opacity-25 ' ? 'bg-blue-500 bg-opacity-10 hover:bg-opacity-25 '
: 'hover:bg-zinc-500 hover:bg-opacity-10 ') + : 'hover:bg-zinc-500 hover:bg-opacity-10 ') +
@@ -21,7 +21,7 @@ export const FolderRow = ({
return ( return (
<div <div
className={ className={
'flex flex-row items-center border -mt-px px-4 py-3 cursor-pointer ' + 'flex flex-row items-center border border-zinc-200 dark:border-zinc-800 -mt-px px-4 py-3 cursor-pointer ' +
(className || '') + (className || '') +
(checked (checked
? 'bg-blue-500 bg-opacity-10 hover:bg-opacity-25 ' ? 'bg-blue-500 bg-opacity-10 hover:bg-opacity-25 '
@@ -10,7 +10,6 @@ export type EmbedContext = {
export default ({ export default ({
initialParentId, initialParentId,
context,
inPublicSharing, inPublicSharing,
}: { }: {
initialParentId?: string; initialParentId?: string;
@@ -18,7 +18,7 @@ export default ({ className }: { className?: string }): JSX.Element => {
{ {
type: 'react-element', type: 'react-element',
reactElement: ( reactElement: (
<div className="grid grid-cols-3"> <div className="grid grid-cols-3 -m-2">
{applications.map((app, index) => { {applications.map((app, index) => {
return ( return (
<a <a
@@ -26,9 +26,9 @@ export default ({ className }: { className?: string }): JSX.Element => {
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
href={app.url} href={app.url}
className="inline-block flex flex-col items-center justify-center cursor-pointer hover:bg-zinc-100 rounded-md p-2 pb-1" className="inline-block flex flex-col items-center justify-center cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-900 rounded-md p-2 pb-1"
> >
<img src={app.logo} className="w-14 h-14 mb-1" /> <img src={app.logo} className="w-10 h-10 mb-1" />
<Base>{app.name}</Base> <Base>{app.name}</Base>
</a> </a>
); );