Merge branch 'refs/heads/hotfix/v2.5.1' into bugfix/rtl-hotfixes

This commit is contained in:
Aleksandr Lushkin 2024-04-25 11:03:24 +02:00
commit c5e983646e
4 changed files with 51 additions and 5 deletions

View File

@ -319,6 +319,8 @@ class FileRow extends Component {
isPersonal,
isMediaActive,
downloadInCurrentTab,
isPlugin,
onPluginClick,
} = this.props;
const { showPasswordInput, password, passwordValid } = this.state;
@ -348,13 +350,13 @@ class FileRow extends Component {
>
<>
{item.fileId ? (
isMedia ? (
isMedia || (isPlugin && onPluginClick) ? (
<Link
className="upload-panel_file-row-link"
fontWeight="600"
color={item.error && "#A3A9AE"}
truncate
onClick={onMediaClick}
onClick={isMedia ? onMediaClick : onPluginClick}
>
{name}
{fileExtension}
@ -437,6 +439,7 @@ export default inject(
uploadDataStore,
mediaViewerDataStore,
settingsStore,
pluginStore,
},
{ item },
) => {
@ -460,6 +463,31 @@ export default inject(
if (!!ext) splitted.splice(-1);
}
const { fileItemsList } = pluginStore;
const { enablePlugins, currentDeviceType } = settingsStore;
let isPlugin = false;
let onPluginClick = null;
if (fileItemsList && enablePlugins) {
let currPluginItem = null;
fileItemsList.forEach((i) => {
if (i.key === item?.fileInfo?.fileExst) currPluginItem = i.value;
});
if (currPluginItem) {
const correctDevice = currPluginItem.devices
? currPluginItem.devices.includes(currentDeviceType)
: true;
if (correctDevice) {
isPlugin = true;
onPluginClick = () =>
currPluginItem.onClick({ ...item, ...item.fileInfo });
}
}
}
name = splitted.join(".");
const { personal, theme } = settingsStore;
@ -512,6 +540,9 @@ export default inject(
setCurrentItem,
clearUploadedFilesHistory,
isPlugin,
onPluginClick,
};
},
)(withTranslation("UploadPanel")(observer(FileRow)));

View File

@ -81,6 +81,8 @@ export interface PluginsProps {
) => Promise<unknown>;
addPlugin: (data: FormData) => Promise<void>;
updatePlugins: (fromList?: boolean) => Promise<void>;
currentColorScheme: TColorScheme;
theme: TTheme;

View File

@ -56,6 +56,8 @@ const PluginPage = ({
updatePlugin,
addPlugin,
updatePlugins,
theme,
isLoading,
isEmptyList,
@ -73,6 +75,10 @@ const PluginPage = ({
setDocumentTitle(t("Common:Plugins"));
}, [t]);
React.useEffect(() => {
updatePlugins(true);
}, [updatePlugins]);
return isLoading || (!isEmptyList && pluginList.length === 0) ? (
<StyledContainer>
<ListLoader withUpload={withUpload} />
@ -133,6 +139,7 @@ export default inject(
const {
pluginList,
updatePlugin,
updatePlugins,
setCurrentSettingsDialogPlugin,
setSettingsPluginDialogVisible,
@ -153,6 +160,7 @@ export default inject(
pluginList,
updatePlugin,
updatePlugins,
openSettingsDialog,

View File

@ -239,7 +239,7 @@ class PluginStore {
this.setIsInit(true);
};
updatePlugins = async () => {
updatePlugins = async (fromList?: boolean) => {
if (!this.userStore || !this.userStore.user) return;
const { isAdmin, isOwner } = this.userStore.user;
@ -254,7 +254,7 @@ class PluginStore {
);
this.setIsEmptyList(plugins.length === 0);
plugins.forEach((plugin) => this.initPlugin(plugin));
plugins.forEach((plugin) => this.initPlugin(plugin, undefined, fromList));
setTimeout(() => {
this.setIsLoading(false);
@ -298,7 +298,12 @@ class PluginStore {
}
};
initPlugin = (plugin: TAPIPlugin, callback?: (plugin: TPlugin) => void) => {
initPlugin = (
plugin: TAPIPlugin,
callback?: (plugin: TPlugin) => void,
fromList?: boolean,
) => {
if (!plugin.enabled && !fromList) return;
const onLoad = async () => {
const iWindow = this.pluginFrame?.contentWindow as IframeWindow;