Skip to content

Commit 94ae32c

Browse files
tray update - windows 11 window management (#881)
* migrate from poc * ui fixes and fix swapping windows * clippy fix * update styles * clippy fixes * Update mod.rs
1 parent 5e73b68 commit 94ae32c

29 files changed

Lines changed: 771 additions & 234 deletions

File tree

new-ui/src/pages/compact/CompactPage/CompactPage.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
import clsx from 'clsx';
22
import './style.scss';
3+
import { useMutation } from '@tanstack/react-query';
34
import type { JSX, PropsWithChildren } from 'react';
5+
import { IconButton } from '../../../shared/components/IconButton/IconButton';
6+
import { IconButtonVariant } from '../../../shared/components/IconButton/types';
7+
import { api } from '../../../shared/rust-api/api';
48

59
interface Props extends PropsWithChildren {
610
containerProps?: JSX.IntrinsicElements['main'];
711
}
812

913
export const CompactPage = ({ children, containerProps }: Props) => {
14+
const { mutate: closeWindow, isPending } = useMutation({
15+
mutationFn: api.closeTrayWindow,
16+
});
17+
1018
return (
1119
<main {...containerProps} className={clsx('compact-page', containerProps?.className)}>
20+
<div className="close-window">
21+
<IconButton
22+
variant={IconButtonVariant.SmallSelected}
23+
icon="close"
24+
onClick={() => {
25+
if (!isPending) {
26+
closeWindow();
27+
}
28+
}}
29+
/>
30+
</div>
1231
{children}
1332
</main>
1433
);
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
.compact-page {
22
box-sizing: border-box;
3-
padding: 8px;
3+
padding: var(--spacing-md);
4+
position: relative;
5+
6+
> .close-window {
7+
position: absolute;
8+
right: var(--spacing-md);
9+
top: var(--spacing-md);
10+
}
411
}

new-ui/src/shared/components/Button/style.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
display: inline-block;
2525
min-width: 0;
2626
user-select: none;
27+
background-clip: padding-box;
2728

2829
> .btn-content {
2930
display: inline-grid;
@@ -60,6 +61,7 @@
6061
.text {
6162
font: var(--btn-font);
6263
color: inherit;
64+
user-select: none;
6365

6466
@include animate(color);
6567
}
@@ -84,7 +86,7 @@
8486

8587
&.size-primary {
8688
--btn-font: var(--t-button-label-primary);
87-
--btn-size: 40px;
89+
--btn-size: 36px;
8890

8991
border-radius: 8px;
9092
padding: var(--spacing-sm) var(--spacing-lg);

new-ui/src/shared/components/Divider/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.divider {
22
--divider-line-size: 1px;
3-
--divider-color: var(--bg-white-20);
3+
--divider-color: var(--bg-white-10);
44

55
user-select: none;
66

new-ui/src/shared/components/LocationCard/LocationCard.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ const LocationCardInner = ({ isOpen, onOpen, disableOpen }: InnerProps) => {
5757
data-network={location.network_id}
5858
data-id={location.id}
5959
>
60-
<div className="top-track">
60+
<div
61+
className={clsx('top-track', {
62+
interactive: !disableOpen,
63+
})}
64+
onClick={onOpen}
65+
>
6166
<div className="left">
6267
<LocationCardIcon />
6368
<div className="info">
@@ -82,7 +87,6 @@ const LocationCardInner = ({ isOpen, onOpen, disableOpen }: InnerProps) => {
8287
icon={IconKind.ArrowSmall}
8388
variant={isOpen ? IconButtonVariant.SmallSelected : IconButtonVariant.Small}
8489
iconRotation={isOpen ? Direction.DOWN : Direction.RIGHT}
85-
onClick={onOpen}
8690
/>
8791
)}
8892
</div>

new-ui/src/shared/components/LocationCard/components/MfaSelector/MfaSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export const MfaSelector = ({
2525
case 'email':
2626
return 'mail';
2727
case 'mobileapprove':
28-
return 'mobile-lock';
28+
return 'mobile';
2929
case 'oidc':
3030
return 'token';
3131
case 'totp':
32-
return 'mobile-lock';
32+
return 'lock-closed';
3333
case 'biometric':
3434
return 'biometric';
3535
}

new-ui/src/shared/components/LocationCard/components/MfaSelector/style.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
--border: var(--border-default);
44
--icon: var(--fg-white-80);
55
--color: var(--fg-white-80);
6+
--box-shadow: box-shadow: 0 4px 4px 0 rgb(0 0 0 / 0%);
67

78
display: grid;
89
grid-template-columns: 20px minmax(0, 1fr) 16px;
@@ -13,34 +14,37 @@
1314
user-select: none;
1415
align-items: center;
1516
box-sizing: border-box;
17+
box-shadow: var(--box-shadow);
1618
padding: 0 var(--spacing-md);
1719
min-height: 40px;
1820
border-radius: 8px;
1921
cursor: pointer;
2022
transition-duration: 250ms;
2123
transition-timing-function: cubic-bezier(0.1, 0.9, 0.2, 1);
22-
transition-property: border-color, background, color;
24+
transition-property: border-color, background, color, box-shadow;
25+
background-clip: padding-box;
2326

2427
&:hover {
2528
--bg: var(--bg-white-5);
2629
--color: var(--fg-white-100);
27-
--border: var(--border-default);
30+
--border: var(--border-action-disabled);
2831
--icon: var(--fg-white-100);
2932
}
3033

3134
&.selected {
32-
--bg: var(--bg-white-5);
35+
--bg: var(--bg-white-10);
3336
--color: var(--fg-white-100);
34-
--border: transparent;
37+
--border: var(--border-action-disabled);
3538
--icon: var(--fg-white-100);
39+
--box-shadow: box-shadow: 0 4px 4px 0 rgb(0 0 0 / 5%);
3640
}
3741

3842
> .middle {
3943
display: flex;
4044
flex-flow: row nowrap;
4145
align-items: center;
4246
justify-content: flex-start;
43-
column-gap: var(--spacing-xs);
47+
column-gap: var(--spacing-md);
4448
}
4549

4650
.default-badge {
@@ -71,6 +75,6 @@
7175

7276
.name {
7377
color: inherit;
74-
font: var(--t-body-xs);
78+
font: var(--t-body-sm-400);
7579
}
7680
}

new-ui/src/shared/components/LocationCard/context/context.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createContext, type ReactNode, useCallback, useContext, useState } from 'react';
2-
import type { InstanceInfo, LocationInfo } from '../../../rust-api/types';
2+
import type { InstanceInfo, LocationInfo, MfaMethodValue } from '../../../rust-api/types';
33
import { MfaMethod } from '../../../rust-api/types';
44
import { LocationCardViews, type LocationCardViewsValue } from './types';
55

@@ -10,6 +10,8 @@ interface LocationCardContextValue {
1010
previousView: LocationCardViewsValue | null;
1111
setView: (view: LocationCardViewsValue) => void;
1212
startMfa: () => void;
13+
localMfaMethod: MfaMethodValue;
14+
setLocalMfaMethod: (method: MfaMethodValue) => void;
1315
}
1416

1517
const LocationCardContext = createContext<LocationCardContextValue | null>(null);
@@ -37,6 +39,9 @@ export const LocationCardProvider = ({
3739
const [currentView, setCurrentView] = useState<LocationCardViewsValue>(
3840
location.active ? LocationCardViews.Connected : LocationCardViews.Default,
3941
);
42+
const [localMfaMethod, setLocalMfaMethod] = useState<MfaMethodValue>(
43+
location.mfa_method ?? MfaMethod.Totp,
44+
);
4045

4146
const setView = useCallback(
4247
(view: LocationCardViewsValue) => {
@@ -47,7 +52,7 @@ export const LocationCardProvider = ({
4752
);
4853

4954
const startMfa = useCallback(() => {
50-
switch (location.mfa_method) {
55+
switch (localMfaMethod) {
5156
case MfaMethod.Totp:
5257
setView(LocationCardViews.MfaTotp);
5358
break;
@@ -61,7 +66,7 @@ export const LocationCardProvider = ({
6166
setView(LocationCardViews.MfaMobile);
6267
break;
6368
}
64-
}, [location.mfa_method, setView]);
69+
}, [localMfaMethod, setView]);
6570

6671
return (
6772
<LocationCardContext.Provider
@@ -72,6 +77,8 @@ export const LocationCardProvider = ({
7277
location,
7378
instance,
7479
startMfa,
80+
localMfaMethod,
81+
setLocalMfaMethod,
7582
}}
7683
>
7784
{children}

new-ui/src/shared/components/LocationCard/style.scss

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.location-card {
2-
border-radius: 12px;
2+
border-radius: 16px;
33
box-sizing: border-box;
4-
padding: var(--spacing-md) var(--spacing-lg);
4+
padding: var(--spacing-lg);
55
background-color: var(--bg-dark-blue-40);
66

77
> .top-track {
@@ -11,6 +11,17 @@
1111
justify-content: flex-start;
1212
user-select: none;
1313

14+
&.interactive {
15+
cursor: pointer;
16+
17+
&:hover {
18+
> .right > .icon-button {
19+
--bg: var(--c-white-20);
20+
--icon: var(--c-white-100);
21+
}
22+
}
23+
}
24+
1425
> .left {
1526
display: flex;
1627
flex-flow: row;

new-ui/src/shared/components/LocationCard/views/DefaultView/DefaultView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export const DefaultView = () => {
3838
<Toggle
3939
disabled={location.active}
4040
active={location.route_all_traffic}
41-
label="All traffic is allowed"
41+
label={
42+
location.route_all_traffic
43+
? 'All traffic is allowed'
44+
: 'Predefined traffic only'
45+
}
4246
onClick={() => {
4347
updateRouting({
4448
connectionType: location.connection_type,

0 commit comments

Comments
 (0)