Merge branch 'hotfix/10.1.3'
This commit is contained in:
@@ -3,33 +3,30 @@ import { Button } from '@/components/Button';
|
|||||||
import { DecoratedInput } from '@/components/DecoratedInput';
|
import { DecoratedInput } from '@/components/DecoratedInput';
|
||||||
import { WebApplication } from '@/ui_models/application';
|
import { WebApplication } from '@/ui_models/application';
|
||||||
import { FunctionComponent } from 'preact';
|
import { FunctionComponent } from 'preact';
|
||||||
|
import { Title, PreferencesSegment } from '../components';
|
||||||
import {
|
import {
|
||||||
Title,
|
ConfirmCustomExtension,
|
||||||
PreferencesSegment,
|
ExtensionItem,
|
||||||
} from '../components';
|
ExtensionsLatestVersions,
|
||||||
import { ConfirmCustomExtension, ExtensionItem, ExtensionsLatestVersions } from './extensions-segments';
|
} from './extensions-segments';
|
||||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
const loadExtensions = (application: WebApplication) => application.getItems([
|
const loadExtensions = (application: WebApplication) =>
|
||||||
ContentType.ActionsExtension,
|
application.getItems(
|
||||||
ContentType.Component,
|
[ContentType.ActionsExtension, ContentType.Component, ContentType.Theme],
|
||||||
ContentType.Theme,
|
true
|
||||||
], true) as SNComponent[];
|
) as SNComponent[];
|
||||||
|
|
||||||
export const Extensions: FunctionComponent<{
|
export const Extensions: FunctionComponent<{
|
||||||
application: WebApplication
|
application: WebApplication;
|
||||||
extensionsLatestVersions: ExtensionsLatestVersions,
|
extensionsLatestVersions: ExtensionsLatestVersions;
|
||||||
className?: string,
|
className?: string;
|
||||||
}> = observer(
|
}> = observer(({ application, extensionsLatestVersions, className = '' }) => {
|
||||||
({
|
|
||||||
application,
|
|
||||||
extensionsLatestVersions,
|
|
||||||
className = ''
|
|
||||||
}) => {
|
|
||||||
|
|
||||||
const [customUrl, setCustomUrl] = useState('');
|
const [customUrl, setCustomUrl] = useState('');
|
||||||
const [confirmableExtension, setConfirmableExtension] = useState<SNComponent | undefined>(undefined);
|
const [confirmableExtension, setConfirmableExtension] = useState<
|
||||||
|
SNComponent | undefined
|
||||||
|
>(undefined);
|
||||||
const [extensions, setExtensions] = useState(loadExtensions(application));
|
const [extensions, setExtensions] = useState(loadExtensions(application));
|
||||||
|
|
||||||
const confirmableEnd = useRef<HTMLDivElement>(null);
|
const confirmableEnd = useRef<HTMLDivElement>(null);
|
||||||
@@ -41,13 +38,14 @@ export const Extensions: FunctionComponent<{
|
|||||||
}, [confirmableExtension, confirmableEnd]);
|
}, [confirmableExtension, confirmableEnd]);
|
||||||
|
|
||||||
const uninstallExtension = async (extension: SNComponent) => {
|
const uninstallExtension = async (extension: SNComponent) => {
|
||||||
application.alertService.confirm(
|
application.alertService
|
||||||
'Are you sure you want to uninstall this extension? Note that extensions managed by your subscription will automatically be re-installed on application restart.',
|
.confirm(
|
||||||
'Uninstall Extension?',
|
'Are you sure you want to uninstall this extension? Note that extensions managed by your subscription will automatically be re-installed on application restart.',
|
||||||
'Uninstall',
|
'Uninstall Extension?',
|
||||||
ButtonType.Danger,
|
'Uninstall',
|
||||||
'Cancel'
|
ButtonType.Danger,
|
||||||
)
|
'Cancel'
|
||||||
|
)
|
||||||
.then(async (shouldRemove: boolean) => {
|
.then(async (shouldRemove: boolean) => {
|
||||||
if (shouldRemove) {
|
if (shouldRemove) {
|
||||||
await application.deleteItem(extension);
|
await application.deleteItem(extension);
|
||||||
@@ -84,41 +82,46 @@ export const Extensions: FunctionComponent<{
|
|||||||
setExtensions(loadExtensions(application));
|
setExtensions(loadExtensions(application));
|
||||||
};
|
};
|
||||||
|
|
||||||
const visibleExtensions = extensions
|
const visibleExtensions = extensions.filter((extension) => {
|
||||||
.filter((extension) => {
|
return (
|
||||||
return extension.package_info != undefined && !['modal', 'rooms'].includes(extension.area);
|
extension.package_info != undefined &&
|
||||||
});
|
!['modal', 'rooms'].includes(extension.area)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
{visibleExtensions.length > 0 &&
|
{visibleExtensions.length > 0 && (
|
||||||
<div>
|
<div>
|
||||||
{
|
{visibleExtensions
|
||||||
visibleExtensions
|
.sort((e1, e2) =>
|
||||||
.sort((e1, e2) => e1.name.toLowerCase().localeCompare(e2.name.toLowerCase()))
|
e1.name?.toLowerCase().localeCompare(e2.name?.toLowerCase())
|
||||||
.map((extension, i) => (
|
)
|
||||||
<ExtensionItem
|
.map((extension, i) => (
|
||||||
key={extension.uuid}
|
<ExtensionItem
|
||||||
application={application}
|
key={extension.uuid}
|
||||||
extension={extension}
|
application={application}
|
||||||
latestVersion={extensionsLatestVersions.getVersion(extension)}
|
extension={extension}
|
||||||
first={i === 0}
|
latestVersion={extensionsLatestVersions.getVersion(extension)}
|
||||||
uninstall={uninstallExtension}
|
first={i === 0}
|
||||||
toggleActivate={toggleActivateExtension} />
|
uninstall={uninstallExtension}
|
||||||
))
|
toggleActivate={toggleActivateExtension}
|
||||||
}
|
/>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
}
|
)}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{!confirmableExtension &&
|
{!confirmableExtension && (
|
||||||
<PreferencesSegment>
|
<PreferencesSegment>
|
||||||
<Title>Install Custom Extension</Title>
|
<Title>Install Custom Extension</Title>
|
||||||
<div className="min-h-2" />
|
<div className="min-h-2" />
|
||||||
<DecoratedInput
|
<DecoratedInput
|
||||||
placeholder={'Enter Extension URL'}
|
placeholder={'Enter Extension URL'}
|
||||||
text={customUrl}
|
text={customUrl}
|
||||||
onChange={(value) => { setCustomUrl(value); }}
|
onChange={(value) => {
|
||||||
|
setCustomUrl(value);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="min-h-2" />
|
<div className="min-h-2" />
|
||||||
<Button
|
<Button
|
||||||
@@ -128,8 +131,8 @@ export const Extensions: FunctionComponent<{
|
|||||||
onClick={() => submitExtensionUrl(customUrl)}
|
onClick={() => submitExtensionUrl(customUrl)}
|
||||||
/>
|
/>
|
||||||
</PreferencesSegment>
|
</PreferencesSegment>
|
||||||
}
|
)}
|
||||||
{confirmableExtension &&
|
{confirmableExtension && (
|
||||||
<PreferencesSegment>
|
<PreferencesSegment>
|
||||||
<ConfirmCustomExtension
|
<ConfirmCustomExtension
|
||||||
component={confirmableExtension}
|
component={confirmableExtension}
|
||||||
@@ -137,7 +140,7 @@ export const Extensions: FunctionComponent<{
|
|||||||
/>
|
/>
|
||||||
<div ref={confirmableEnd} />
|
<div ref={confirmableEnd} />
|
||||||
</PreferencesSegment>
|
</PreferencesSegment>
|
||||||
}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user