-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix unable to preview migrated files, fix error when switching workspaces * Fix missing events and tasks, remove email invitation calendar * Put back link-files
- Loading branch information
1 parent
aeacc54
commit 06f5327
Showing
15 changed files
with
214 additions
and
10 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
twake/frontend/src/app/atoms/icons-colored/assets/file-type-link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
twake/frontend/src/app/views/applications/drive/modals/create/create-link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Button } from 'app/atoms/button/button'; | ||
import { Input } from 'app/atoms/input/input-text'; | ||
import { Info } from 'app/atoms/text'; | ||
import { useDriveActions } from 'app/features/drive/hooks/use-drive-actions'; | ||
import { useState } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { CreateModalAtom } from '.'; | ||
import FileUploadService from 'features/files/services/file-upload-service'; | ||
|
||
export const CreateLink = () => { | ||
const [name, setName] = useState<string>(''); | ||
const [link, setLink] = useState<string>(''); | ||
const [loading] = useState<boolean>(false); | ||
const [state, setState] = useRecoilState(CreateModalAtom); | ||
const { create } = useDriveActions(); | ||
|
||
const createLink = async () => { | ||
let finalLink = link.trim(); | ||
if (!/^https?:\/\//i.test(finalLink)) finalLink = 'http://' + finalLink; | ||
const file = new File(['[InternetShortcut]\nURL=' + finalLink], name?.trim() + '.url', { | ||
type: 'text/uri-list', | ||
}); | ||
|
||
await FileUploadService.upload([file], { | ||
context: { | ||
parentId: state.parent_id, | ||
}, | ||
callback: (file, context) => { | ||
if (file) | ||
create( | ||
{ name, parent_id: context.parentId, size: file.upload_data?.size }, | ||
{ | ||
provider: 'internal', | ||
application_id: '', | ||
file_metadata: { | ||
name: file.metadata?.name, | ||
size: file.upload_data?.size, | ||
mime: file.metadata?.mime, | ||
thumbnails: file?.thumbnails, | ||
source: 'internal', | ||
external_id: file.id, | ||
}, | ||
}, | ||
); | ||
}, | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Info>Create a link</Info> | ||
|
||
<Input | ||
disabled={loading} | ||
placeholder="Link name" | ||
className="w-full mt-4" | ||
onChange={e => setName(e.target.value)} | ||
/> | ||
|
||
<Input | ||
disabled={loading} | ||
placeholder="https://example.com" | ||
className="w-full mt-4" | ||
onChange={e => setLink(e.target.value)} | ||
/> | ||
|
||
<Button | ||
disabled={!name || !link} | ||
loading={loading} | ||
className="mt-4 float-right" | ||
onClick={async () => { | ||
await createLink(); | ||
setState({ ...state, open: false }); | ||
}} | ||
> | ||
Create link | ||
</Button> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
twake/frontend/src/app/views/applications/viewer/link/display.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Button } from 'app/atoms/button/button'; | ||
import { useDrivePreviewDisplayData } from 'app/features/drive/hooks/use-drive-preview'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export default (props: { download: string; name: string }) => { | ||
const { size } = useDrivePreviewDisplayData(); | ||
const [error, setError] = useState(false); | ||
const [loading, setLoading] = useState(true); | ||
|
||
const openLink = async () => { | ||
if ((size || 10000000) < 10000) { | ||
setLoading(true); | ||
//Download file content and extract link from url props.download | ||
try { | ||
const response = await fetch(props.download); | ||
const blob = await response.blob(); | ||
const reader = new FileReader(); | ||
reader.readAsText(blob); | ||
reader.onloadend = () => { | ||
const result = reader.result as string; | ||
const link = result.match(/URL=(.*)/); | ||
if (link && link[1]) { | ||
if (!link[1].match(/^(http|https):\/\//)) throw new Error('Invalid link'); | ||
window.open(link[1], '_blank'); | ||
} else { | ||
setError(true); | ||
} | ||
setLoading(false); | ||
}; | ||
} catch (e) { | ||
setError(true); | ||
setLoading(false); | ||
} | ||
return; | ||
} | ||
setError(true); | ||
}; | ||
|
||
useEffect(() => { | ||
openLink(); | ||
}, []); | ||
|
||
if (loading) { | ||
return ( | ||
<div className="text-white m-auto w-full text-center h-full flex items-center"> | ||
<span className="block w-full text-center">Opening link...</span> | ||
</div> | ||
); | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<div className="text-white m-auto w-full text-center h-full flex items-center"> | ||
<span className="block w-full text-center"> | ||
We can't open '{props.name}' as a link. You can download it instead. | ||
</span> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="text-white m-auto w-full text-center h-full flex items-center"> | ||
<span className="block w-full text-center"> | ||
Link was open on another tab. | ||
<br /> | ||
<br /> | ||
<Button onClick={() => openLink()}>Open again</Button> | ||
</span> | ||
</div> | ||
); | ||
}; |