[MM-47801][MM-45980] Added support for security-scoped bookmarks to allow the MAS build to save files wherever needed (#2315)

* First pass

* [MM-47801] Added support for security-scoped bookmarks to allow the MAS build to save files wherever needed
This commit is contained in:
Devin Binnie
2022-10-25 08:02:00 -04:00
committed by GitHub
parent 0f51a628f0
commit 635a41f998
11 changed files with 139 additions and 34 deletions

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import React, {useEffect, useState} from 'react';
import {DownloadedItem} from 'types/downloads';
import {CheckCircleIcon, CloseCircleIcon} from '@mattermost/compass-icons/components';
@@ -19,6 +19,8 @@ const colorRed = '#D24B4E';
const isWin = window.process.platform === 'win32';
const Thumbnail = ({item}: OwnProps) => {
const [imageUrl, setImageUrl] = useState<string | undefined>();
const showBadge = (state: DownloadedItem['state']) => {
switch (state) {
case 'completed':
@@ -42,15 +44,27 @@ const Thumbnail = ({item}: OwnProps) => {
}
};
useEffect(() => {
const fetchThumbnail = async () => {
const imageUrl = await window.mas.getThumbnailLocation(item.location);
setImageUrl(imageUrl);
};
fetchThumbnail();
}, [item]);
const showImagePreview = isImageFile(item) && item.state === 'completed';
if (showImagePreview && !imageUrl) {
return null;
}
return (
<div className='DownloadsDropdown__Thumbnail__Container'>
{showImagePreview ?
{showImagePreview && imageUrl ?
<div
className='DownloadsDropdown__Thumbnail preview'
style={{
backgroundImage: `url("${isWin ? `file:///${item.location.replaceAll('\\', '/')}` : item.location}")`,
backgroundImage: `url("${isWin ? `file:///${imageUrl.replaceAll('\\', '/')}` : imageUrl}")`,
backgroundSize: 'cover',
}}
/> :