feat: move extensions from prefs menu's left pane to General->Advanced section (#718)
This commit is contained in:
44
app/assets/javascripts/components/shared/AccordionItem.tsx
Normal file
44
app/assets/javascripts/components/shared/AccordionItem.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { FunctionalComponent } from 'preact';
|
||||||
|
import { useRef, useState } from 'preact/hooks';
|
||||||
|
import ArrowDown from '../../../svg/arrow-down.svg';
|
||||||
|
import { Title } from '@/preferences/components';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
title: string | JSX.Element;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const AccordionItem: FunctionalComponent<Props> = ({
|
||||||
|
title,
|
||||||
|
className = '',
|
||||||
|
children
|
||||||
|
}) => {
|
||||||
|
const elementRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={className}>
|
||||||
|
<div
|
||||||
|
className={'relative flex cursor-pointer hover:underline'}
|
||||||
|
onClick={() => {
|
||||||
|
setIsExpanded(!isExpanded);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Title>{title}</Title>
|
||||||
|
<ArrowDown
|
||||||
|
className={'sn-accordion-arrow-icon absolute right-0'}
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
data-is-expanded={isExpanded}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={'accordion-contents-container cursor-auto'}
|
||||||
|
data-is-expanded={isExpanded}
|
||||||
|
ref={elementRef}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -11,7 +11,6 @@ const PREFERENCE_IDS = [
|
|||||||
'account',
|
'account',
|
||||||
'appearance',
|
'appearance',
|
||||||
'security',
|
'security',
|
||||||
'extensions',
|
|
||||||
'listed',
|
'listed',
|
||||||
'shortcuts',
|
'shortcuts',
|
||||||
'accessibility',
|
'accessibility',
|
||||||
@@ -38,7 +37,6 @@ const PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
|
|||||||
{ id: 'general', label: 'General', icon: 'settings' },
|
{ id: 'general', label: 'General', icon: 'settings' },
|
||||||
// { id: 'appearance', label: 'Appearance', icon: 'themes' },
|
// { id: 'appearance', label: 'Appearance', icon: 'themes' },
|
||||||
{ id: 'security', label: 'Security', icon: 'security' },
|
{ id: 'security', label: 'Security', icon: 'security' },
|
||||||
{ id: 'extensions', label: 'Extensions', icon: 'tune' },
|
|
||||||
{ id: 'listed', label: 'Listed', icon: 'listed' },
|
{ id: 'listed', label: 'Listed', icon: 'listed' },
|
||||||
// { id: 'shortcuts', label: 'Shortcuts', icon: 'keyboard' },
|
// { id: 'shortcuts', label: 'Shortcuts', icon: 'keyboard' },
|
||||||
// { id: 'accessibility', label: 'Accessibility', icon: 'accessibility' },
|
// { id: 'accessibility', label: 'Accessibility', icon: 'accessibility' },
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import { WebApplication } from '@/ui_models/application';
|
|||||||
import { MfaProps } from './panes/two-factor-auth/MfaProps';
|
import { MfaProps } from './panes/two-factor-auth/MfaProps';
|
||||||
import { AppState } from '@/ui_models/app_state';
|
import { AppState } from '@/ui_models/app_state';
|
||||||
import { useEffect, useMemo } from 'preact/hooks';
|
import { useEffect, useMemo } from 'preact/hooks';
|
||||||
import { Extensions } from './panes/Extensions';
|
|
||||||
import { ExtensionPane } from './panes/ExtensionPane';
|
import { ExtensionPane } from './panes/ExtensionPane';
|
||||||
|
|
||||||
interface PreferencesProps extends MfaProps {
|
interface PreferencesProps extends MfaProps {
|
||||||
@@ -38,7 +37,11 @@ const PaneSelector: FunctionComponent<
|
|||||||
switch (menu.selectedPaneId) {
|
switch (menu.selectedPaneId) {
|
||||||
case 'general':
|
case 'general':
|
||||||
return (
|
return (
|
||||||
<General appState={appState} application={application} />
|
<General
|
||||||
|
appState={appState}
|
||||||
|
application={application}
|
||||||
|
extensionsLatestVersions={menu.extensionsLatestVersions}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
case 'account':
|
case 'account':
|
||||||
return (
|
return (
|
||||||
@@ -58,8 +61,6 @@ const PaneSelector: FunctionComponent<
|
|||||||
application={application}
|
application={application}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case 'extensions':
|
|
||||||
return <Extensions application={application} extensionsLatestVersions={menu.extensionsLatestVersions} />;
|
|
||||||
case 'listed':
|
case 'listed':
|
||||||
return <Listed application={application} />;
|
return <Listed application={application} />;
|
||||||
case 'shortcuts':
|
case 'shortcuts':
|
||||||
@@ -81,7 +82,13 @@ const PaneSelector: FunctionComponent<
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return <General appState={appState} application={application} />;
|
return (
|
||||||
|
<General
|
||||||
|
appState={appState}
|
||||||
|
application={application}
|
||||||
|
extensionsLatestVersions={menu.extensionsLatestVersions}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import { FunctionComponent } from 'preact';
|
import { FunctionComponent } from 'preact';
|
||||||
|
|
||||||
export const PreferencesSegment: FunctionComponent = ({ children }) => (
|
type Props = {
|
||||||
<div className="flex flex-col">{children}</div>
|
classes?: string;
|
||||||
|
}
|
||||||
|
export const PreferencesSegment: FunctionComponent<Props> = ({
|
||||||
|
children,
|
||||||
|
classes = ''
|
||||||
|
}) => (
|
||||||
|
<div className={`flex flex-col ${classes}`}>{children}</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export const AccountPreferences = observer(
|
|||||||
<Authentication application={application} appState={appState} />
|
<Authentication application={application} appState={appState} />
|
||||||
{appState.enableUnfinishedFeatures && <SubscriptionWrapper application={application} />}
|
{appState.enableUnfinishedFeatures && <SubscriptionWrapper application={application} />}
|
||||||
<SignOutWrapper application={application} appState={appState} />
|
<SignOutWrapper application={application} appState={appState} />
|
||||||
<Advanced application={application} appState={appState} />
|
|
||||||
</PreferencesPane>
|
</PreferencesPane>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -36,7 +35,6 @@ export const AccountPreferences = observer(
|
|||||||
<Sync application={application} />
|
<Sync application={application} />
|
||||||
{appState.enableUnfinishedFeatures && <SubscriptionWrapper application={application} />}
|
{appState.enableUnfinishedFeatures && <SubscriptionWrapper application={application} />}
|
||||||
<SignOutWrapper application={application} appState={appState} />
|
<SignOutWrapper application={application} appState={appState} />
|
||||||
<Advanced application={application} appState={appState} />
|
|
||||||
</PreferencesPane>
|
</PreferencesPane>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import { WebApplication } from '@/ui_models/application';
|
|||||||
import { FunctionComponent } from 'preact';
|
import { FunctionComponent } from 'preact';
|
||||||
import {
|
import {
|
||||||
Title,
|
Title,
|
||||||
PreferencesGroup,
|
|
||||||
PreferencesPane,
|
|
||||||
PreferencesSegment,
|
PreferencesSegment,
|
||||||
} from '../components';
|
} from '../components';
|
||||||
import { ConfirmCustomExtension, ExtensionItem, ExtensionsLatestVersions } from './extensions-segments';
|
import { ConfirmCustomExtension, ExtensionItem, ExtensionsLatestVersions } from './extensions-segments';
|
||||||
@@ -70,55 +68,54 @@ export const Extensions: FunctionComponent<{
|
|||||||
.filter(extension => !['modal', 'rooms'].includes(extension.area));
|
.filter(extension => !['modal', 'rooms'].includes(extension.area));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PreferencesPane>
|
<div>
|
||||||
{visibleExtensions.length > 0 &&
|
{visibleExtensions.length > 0 &&
|
||||||
<PreferencesGroup>
|
<div>
|
||||||
{
|
{
|
||||||
visibleExtensions
|
visibleExtensions
|
||||||
.sort((e1, e2) => e1.name.toLowerCase().localeCompare(e2.name.toLowerCase()))
|
.sort((e1, e2) => e1.name.toLowerCase().localeCompare(e2.name.toLowerCase()))
|
||||||
.map((extension, i) => (
|
.map((extension, i) => (
|
||||||
<ExtensionItem
|
<ExtensionItem
|
||||||
application={application}
|
application={application}
|
||||||
extension={extension}
|
extension={extension}
|
||||||
latestVersion={extensionsLatestVersions.getVersion(extension)}
|
latestVersion={extensionsLatestVersions.getVersion(extension)}
|
||||||
first={i === 0}
|
first={i === 0}
|
||||||
uninstall={uninstallExtension}
|
uninstall={uninstallExtension}
|
||||||
toggleActivate={toggleActivateExtension} />
|
toggleActivate={toggleActivateExtension} />
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</PreferencesGroup>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<PreferencesGroup>
|
<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
|
||||||
className="min-w-20"
|
className="min-w-20"
|
||||||
type="normal"
|
type="normal"
|
||||||
label="Install"
|
label="Install"
|
||||||
onClick={() => submitExtensionUrl(customUrl)}
|
onClick={() => submitExtensionUrl(customUrl)}
|
||||||
/>
|
/>
|
||||||
|
</PreferencesSegment>
|
||||||
</PreferencesSegment>
|
|
||||||
}
|
}
|
||||||
{confirmableExtension &&
|
{confirmableExtension &&
|
||||||
<PreferencesSegment>
|
<PreferencesSegment>
|
||||||
<ConfirmCustomExtension
|
<ConfirmCustomExtension
|
||||||
component={confirmableExtension}
|
component={confirmableExtension}
|
||||||
callback={handleConfirmExtensionSubmit}
|
callback={handleConfirmExtensionSubmit}
|
||||||
/>
|
/>
|
||||||
<div ref={confirmableEnd} />
|
<div ref={confirmableEnd} />
|
||||||
</PreferencesSegment>
|
</PreferencesSegment>
|
||||||
}
|
}
|
||||||
</PreferencesGroup>
|
</div>
|
||||||
</PreferencesPane>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,16 +3,27 @@ import { AppState } from '@/ui_models/app_state';
|
|||||||
import { FunctionComponent } from 'preact';
|
import { FunctionComponent } from 'preact';
|
||||||
import { PreferencesPane } from '../components';
|
import { PreferencesPane } from '../components';
|
||||||
import { ErrorReporting, Tools, Defaults } from './general-segments';
|
import { ErrorReporting, Tools, Defaults } from './general-segments';
|
||||||
|
import { ExtensionsLatestVersions } from '@/preferences/panes/extensions-segments';
|
||||||
|
import { Advanced } from '@/preferences/panes/account';
|
||||||
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
interface GeneralProps {
|
interface GeneralProps {
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
application: WebApplication;
|
application: WebApplication;
|
||||||
|
extensionsLatestVersions: ExtensionsLatestVersions,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const General: FunctionComponent<GeneralProps> = (props) => (
|
export const General: FunctionComponent<GeneralProps> = observer(
|
||||||
<PreferencesPane>
|
({
|
||||||
<Tools application={props.application} />
|
appState,
|
||||||
<Defaults application={props.application} />
|
application,
|
||||||
<ErrorReporting appState={props.appState} />
|
extensionsLatestVersions
|
||||||
</PreferencesPane>
|
}) => (
|
||||||
|
<PreferencesPane>
|
||||||
|
<Tools application={application} />
|
||||||
|
<Defaults application={application} />
|
||||||
|
<ErrorReporting appState={appState} />
|
||||||
|
<Advanced application={application} appState={appState} extensionsLatestVersions={extensionsLatestVersions} />
|
||||||
|
</PreferencesPane>
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,23 +4,33 @@ import { OfflineSubscription } from '@/preferences/panes/account/offlineSubscrip
|
|||||||
import { WebApplication } from '@/ui_models/application';
|
import { WebApplication } from '@/ui_models/application';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { AppState } from '@/ui_models/app_state';
|
import { AppState } from '@/ui_models/app_state';
|
||||||
|
import { Extensions } from '@/preferences/panes/Extensions';
|
||||||
|
import { ExtensionsLatestVersions } from '@/preferences/panes/extensions-segments';
|
||||||
|
import { HorizontalSeparator } from '@/components/shared/HorizontalSeparator';
|
||||||
|
import { AccordionItem } from '@/components/shared/AccordionItem';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
application: WebApplication;
|
application: WebApplication;
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
|
extensionsLatestVersions: ExtensionsLatestVersions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Advanced: FunctionalComponent<IProps> = observer(({ application, appState }) => {
|
export const Advanced: FunctionalComponent<IProps> = observer(
|
||||||
return (
|
({ application, appState, extensionsLatestVersions }) => {
|
||||||
<PreferencesGroup>
|
return (
|
||||||
<PreferencesSegment>
|
<PreferencesGroup>
|
||||||
<div className='flex flex-row items-center'>
|
<PreferencesSegment>
|
||||||
<div className='flex-grow flex flex-col'>
|
<AccordionItem title={'Advanced Settings'}>
|
||||||
<Title>Advanced Settings</Title>
|
<div className='flex flex-row items-center'>
|
||||||
<OfflineSubscription application={application} appState={appState} />
|
<div className='flex-grow flex flex-col'>
|
||||||
</div>
|
<OfflineSubscription application={application} appState={appState} />
|
||||||
</div>
|
<HorizontalSeparator classes="mt-8 mb-8" />
|
||||||
</PreferencesSegment>
|
<Extensions application={application} extensionsLatestVersions={extensionsLatestVersions} />
|
||||||
</PreferencesGroup>
|
</div>
|
||||||
);
|
</div>
|
||||||
});
|
</AccordionItem>
|
||||||
|
</PreferencesSegment>
|
||||||
|
</PreferencesGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> =
|
|||||||
const isToggleable = [ComponentArea.EditorStack, ComponentArea.TagsList].includes(extension.area);
|
const isToggleable = [ComponentArea.EditorStack, ComponentArea.TagsList].includes(extension.area);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PreferencesSegment>
|
<PreferencesSegment classes={'mb-5'}>
|
||||||
{first && <>
|
{first && <>
|
||||||
<Title>Extensions</Title>
|
<Title>Extensions</Title>
|
||||||
<div className="w-full min-h-3" />
|
<div className="w-full min-h-3" />
|
||||||
|
|||||||
@@ -100,6 +100,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sn-accordion-arrow-icon {
|
||||||
|
&[data-is-expanded='true'] {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.accordion-contents-container {
|
||||||
|
transition: all 0.23s ease-out;
|
||||||
|
transform-origin: top;
|
||||||
|
transform: scaleY(0);
|
||||||
|
height: 0;
|
||||||
|
|
||||||
|
&[data-is-expanded='true'] {
|
||||||
|
height: auto;
|
||||||
|
transform-origin: top;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Lesser specificity will give priority to reach's styles */
|
/** Lesser specificity will give priority to reach's styles */
|
||||||
[data-reach-custom-checkbox-container].sn-switch {
|
[data-reach-custom-checkbox-container].sn-switch {
|
||||||
@extend .duration-150;
|
@extend .duration-150;
|
||||||
@@ -273,6 +291,9 @@
|
|||||||
.mb-5 {
|
.mb-5 {
|
||||||
margin-bottom: 1.25rem;
|
margin-bottom: 1.25rem;
|
||||||
}
|
}
|
||||||
|
.mb-8 {
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
.max-w-89 {
|
.max-w-89 {
|
||||||
max-width: 22.25rem;
|
max-width: 22.25rem;
|
||||||
@@ -525,6 +546,10 @@
|
|||||||
left: -14rem;
|
left: -14rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.right-0 {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.-right-2 {
|
.-right-2 {
|
||||||
right: -0.5rem;
|
right: -0.5rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,9 @@ $screen-md-max: ($screen-lg-min - 1) !default;
|
|||||||
.mt-5 {
|
.mt-5 {
|
||||||
margin-top: 1.015625rem;
|
margin-top: 1.015625rem;
|
||||||
}
|
}
|
||||||
|
.mt-8 {
|
||||||
|
margin-top: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
.p-0 {
|
.p-0 {
|
||||||
padding: 0rem;
|
padding: 0rem;
|
||||||
|
|||||||
3
app/assets/svg/arrow-down.svg
Normal file
3
app/assets/svg/arrow-down.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M6.4167 6.90759L10.2417 10.7326L14.0667 6.90759L15.2417 8.09093L10.2417 13.0909L5.2417 8.09093L6.4167 6.90759Z" fill="#181818"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 222 B |
Reference in New Issue
Block a user