Skip to content

Commit

Permalink
core connected
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Nov 25, 2024
1 parent 2783167 commit a8ac82c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion web/src/core/usecases/fileExplorer/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const main = createSelector(
viewMode,
shareView
) => {
if (directoryPath === null) {
if (directoryPath === undefined) {
return {
isCurrentWorkingDirectoryLoaded: false as const,
isNavigationOngoing,
Expand Down
34 changes: 20 additions & 14 deletions web/src/ui/pages/myFiles/Explorer/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
import type { Item } from "../shared/types";
import { ViewMode } from "../shared/types";
import { isDirectory } from "../shared/tools";
import { ShareDialog } from "../ShareFile/ShareDialog";
import { ShareDialog, ShareDialogProps } from "../ShareFile/ShareDialog";
import { ShareView } from "core/usecases/fileExplorer";

export type ExplorerProps = {
Expand All @@ -71,7 +71,9 @@ export type ExplorerProps = {
onRefresh: () => void;
onDeleteItem: (params: { item: Item }) => void;
onDeleteItems: (params: { items: Item[] }) => void;
onShareFile: (params: { fileBasename: string }) => void;
onShareFileOpen: (params: { fileBasename: string }) => void;
onShareFileClose: () => void;
requestSignedUrl: (params: { expirationTime: number }) => void;
onCreateDirectory: (params: { basename: string }) => void;
onCopyPath: (params: { path: string }) => void;
scrollableDivRef: RefObject<any>;
Expand Down Expand Up @@ -102,8 +104,10 @@ export const Explorer = memo((props: ExplorerProps) => {
pathMinDepth,
onViewModeChange,
viewMode,
onShareFile,
shareState
onShareFileOpen,
onShareFileClose,
shareState,
requestSignedUrl
} = props;

const [items] = useMemo(
Expand Down Expand Up @@ -315,17 +319,19 @@ export const Explorer = memo((props: ExplorerProps) => {
const onUploadModalClose = useConstCallback(() => setIsUploadModalOpen(false));
const onDragOver = useConstCallback(() => setIsUploadModalOpen(true));

const [isShareModalOpen, setIsShareModalOpen] = useState<boolean>(false);

const onShareDialogOpen = useConstCallback(
async ({ fileBasename }: Param0<ItemsProps["onShare"]>) => {
setIsShareModalOpen(true);
onShareFile({ fileBasename });
onShareFileOpen({ fileBasename });
}
);

const onShareDialogClose = useConstCallback(() => setIsShareModalOpen(false));
const onShareDialogClose = useConstCallback(() => onShareFileClose());

const onRequestSignedUrl = useConstCallback(
async ({ expirationTime }: Param0<ShareDialogProps["onRequestUrl"]>) => {
requestSignedUrl({ expirationTime });
}
);
return (
<>
<div
Expand Down Expand Up @@ -492,12 +498,12 @@ export const Explorer = memo((props: ExplorerProps) => {
}
/>

{/* <ShareDialog
<ShareDialog
onClose={onShareDialogClose}
isOpen={isShareModalOpen}
file={}
validityDurationSecond={shareState?.}
/> */}
isOpen={shareState !== undefined}
onRequestUrl={onRequestSignedUrl}
{...shareState}
/>

<ExplorerUploadModal
isOpen={isUploadModalOpen}
Expand Down
3 changes: 1 addition & 2 deletions web/src/ui/pages/myFiles/Explorer/ExplorerButtonBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ export const ExplorerButtonBar = memo((props: Props) => {
return false;
case "new":
case "create directory":
//return isFileOpen;
return false;
case "delete":
case "share":
return selectedItemKind === "none";
return selectedItemKind !== "file";
case "copy path":
return selectedItemKind !== "file";
}
Expand Down
4 changes: 3 additions & 1 deletion web/src/ui/pages/myFiles/MyFiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ export default function MyFiles(props: Props) {
onOpenFile={onOpenFile}
viewMode={viewMode}
onViewModeChange={fileExplorer.changeViewMode}
onShareFile={fileExplorer.openShare}
onShareFileOpen={fileExplorer.openShare}
onShareFileClose={fileExplorer.closeShare}
requestSignedUrl={fileExplorer.requestShareSignedUrl}
shareState={shareView}
/>
</div>
Expand Down
8 changes: 4 additions & 4 deletions web/src/ui/pages/myFiles/ShareFile/ShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type ShareDialogProps = ShareDialogProps.Close | ShareDialogProps.Open;
export namespace ShareDialogProps {
type Common = {
onClose: () => void;
onRequestUrl: (params: { expirationTime: number }) => void;
};

export type Close = Common & {
Expand All @@ -38,7 +39,6 @@ export namespace ShareDialogProps {
isRequestingUrl: boolean;
validityDurationSecondOptions: number[];
validityDurationSecond: number;
onRequestUrl: (params: { expirationTime: number }) => void;
};

export type PublicFileProps = {
Expand Down Expand Up @@ -84,11 +84,11 @@ export const ShareDialog = memo((props: ShareDialogProps) => {
);
});

const ShareDialogBody = memo((props: ShareDialogProps.BodyProps) => {
const ShareDialogBody = memo((props: ShareDialogProps.Open) => {
const { t } = useTranslation({ ShareDialog });
const { classes } = useStyles();

const { isPublic, url } = props;
const { isPublic, url, onRequestUrl } = props;

const [valueExpirationTime, setValueExpirationTime] = useState<number | undefined>(
isPrivateFileProps(props) ? props.validityDurationSecond : undefined
Expand Down Expand Up @@ -117,7 +117,7 @@ const ShareDialogBody = memo((props: ShareDialogProps.BodyProps) => {
startIcon={getIconUrlByName("Language")}
variant="ternary"
onClick={() =>
props.onRequestUrl({
onRequestUrl({
expirationTime: valueExpirationTime
})
}
Expand Down

0 comments on commit a8ac82c

Please sign in to comment.