Skip to content

Commit

Permalink
Merge branch 'release/3.8.26' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed Oct 13, 2021
2 parents e856ce7 + 99b84e3 commit b22c7e6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
12 changes: 11 additions & 1 deletion app/assets/javascripts/preferences/PreferencesMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,22 @@ const PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
{ id: 'help-feedback', label: 'Help & feedback', icon: 'help' },
];

const READY_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
{ id: 'general', label: 'General', icon: 'settings' },
{ id: 'account', label: 'Account', icon: 'user' },
{ id: 'security', label: 'Security', icon: 'security' },
{ id: 'listed', label: 'Listed', icon: 'listed' },
{ id: 'help-feedback', label: 'Help & feedback', icon: 'help' },
];

export class PreferencesMenu {
private _selectedPane: PreferenceId = 'general';
private _menu: PreferencesMenuItem[];

constructor(
private readonly _menu: PreferencesMenuItem[] = PREFERENCES_MENU_ITEMS
private readonly _enableUnfinishedFeatures: boolean,
) {
this._menu = this._enableUnfinishedFeatures ? PREFERENCES_MENU_ITEMS : READY_PREFERENCES_MENU_ITEMS;
makeAutoObservable<PreferencesMenu, '_selectedPane' | '_twoFactorAuth'>(
this,
{
Expand Down
4 changes: 3 additions & 1 deletion app/assets/javascripts/preferences/PreferencesView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ const PreferencesCanvas: FunctionComponent<

export const PreferencesView: FunctionComponent<PreferencesProps> = observer(
(props) => {
const menu = useMemo(() => new PreferencesMenu(), []);
const menu = useMemo(() => new PreferencesMenu(props.appState.enableUnfinishedFeatures), [
props.appState.enableUnfinishedFeatures
]);

useEffect(() => {
menu.selectPane(props.appState.preferences.currentPane);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const AccountPreferences = observer(
return (
<PreferencesPane>
<Authentication application={application} appState={appState} />
<SubscriptionWrapper application={application} />
{appState.enableUnfinishedFeatures && <SubscriptionWrapper application={application} />}
<SignOutWrapper application={application} appState={appState} />
</PreferencesPane>
);
Expand All @@ -32,6 +32,7 @@ export const AccountPreferences = observer(
<PreferencesPane>
<Credentials application={application} />
<Sync application={application} />
{appState.enableUnfinishedFeatures && <SubscriptionWrapper application={application} />}
<SignOutWrapper application={application} appState={appState} />
</PreferencesPane>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Subscription: FunctionComponent<Props> = observer(({
application,
subscriptionState,
}: Props) => {
const [loading, setLoading] = useState(true);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(false);

const { userSubscription } = subscriptionState;
Expand Down Expand Up @@ -59,8 +59,10 @@ export const Subscription: FunctionComponent<Props> = observer(({
}, [getSubscription, getSubscriptions]);

useEffect(() => {
getSubscriptionInfo();
}, [getSubscriptionInfo]);
if (application.hasAccount()) {
getSubscriptionInfo();
}
}, [application, getSubscriptionInfo]);

const now = new Date().getTime();

Expand All @@ -71,7 +73,7 @@ export const Subscription: FunctionComponent<Props> = observer(({
<div className="flex-grow flex flex-col">
<Title>Subscription</Title>
{error ? (
<NoSubscription application={application} />
<Text>No subscription information available.</Text>
) : loading ? (
<Text>Loading subscription information...</Text>
) : userSubscription && userSubscription.endsAt > now ? (
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/views/footer/footer-view.pug
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
)
.sk-app-bar-item.ml-0-important(
ng-click='ctrl.clickPreferences()'
ng-if='ctrl.appState.enableUnfinishedFeatures'
)
.w-8.h-full.flex.items-center.justify-center.cursor-pointer
.h-5
Expand Down

0 comments on commit b22c7e6

Please sign in to comment.