ikoncomponents 1.7.5 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,6 +13,7 @@ import Link from "next/link";
|
|
|
13
13
|
import { jwtDecode } from "jwt-decode";
|
|
14
14
|
import { Icon } from "../icon";
|
|
15
15
|
import { useRefresh } from "./RefreshContext";
|
|
16
|
+
import { ProviderWrapper } from "../provider-wrapper";
|
|
16
17
|
export const MainSidebar = ({ baseUrl, platformUrl, }) => {
|
|
17
18
|
const [user, setUser] = React.useState();
|
|
18
19
|
const [accounts, setAccounts] = React.useState([]);
|
|
@@ -96,24 +97,24 @@ export const MainSidebar = ({ baseUrl, platformUrl, }) => {
|
|
|
96
97
|
throw error;
|
|
97
98
|
}
|
|
98
99
|
};
|
|
99
|
-
return (_jsx(TooltipProvider, { delayDuration: 0, children: _jsxs("aside", { className: "fixed left-0 top-0 z-20 h-screen w-12 border-r border-border bg-sidebar text-sidebar-foreground flex flex-col items-center py-4 ", children: [_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "default", className: "mb-4 h-8 w-8 rounded-lg p-0", disabled: !selectedAccount, children: _jsx("span", { className: "text-base font-medium text-accent-foreground", children: selectedAccount
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
100
|
+
return (_jsx(ProviderWrapper, { baseUrl: "", platformUrl: "", children: _jsx(TooltipProvider, { delayDuration: 0, children: _jsxs("aside", { className: "fixed left-0 top-0 z-20 h-screen w-12 border-r border-border bg-sidebar text-sidebar-foreground flex flex-col items-center py-4 ", children: [_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "default", className: "mb-4 h-8 w-8 rounded-lg p-0", disabled: !selectedAccount, children: _jsx("span", { className: "text-base font-medium text-accent-foreground", children: selectedAccount
|
|
101
|
+
? getInitials(selectedAccount.accountName)
|
|
102
|
+
: "..." }) }) }), _jsxs(DropdownMenuContent, { className: "w-55", side: "right", sideOffset: 8, align: "start", children: [_jsx("div", { className: "px-2 py-1.5 text-xs font-semibold text-foreground", children: "Accounts" }), accounts.map((account) => (_jsxs(DropdownMenuItem, { className: "flex items-center justify-between cursor-pointer", onClick: async () => {
|
|
103
|
+
try {
|
|
104
|
+
setSelectedAccount(account);
|
|
105
|
+
console.log(account.accountId);
|
|
106
|
+
await switchAccount(account.accountId, baseUrl);
|
|
107
|
+
window.location.reload();
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.error("Switch account failed", error);
|
|
111
|
+
}
|
|
112
|
+
}, children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "h-6 w-6 rounded bg-primary/10 flex items-center justify-center", children: _jsx("span", { className: "text-xs font-medium text-primary", children: getInitials(account.accountName) }) }), _jsx("span", { className: "text-sm", children: account.accountName })] }), (selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountId) === account.accountId && (_jsx(Check, { className: "h-4 w-4 text-primary" }))] }, account.accountId)))] })] }), _jsx("nav", { className: "flex flex-col gap-1", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/home`, children: [_jsx(Home, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Home" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Home" })] }, "home") }), _jsx("nav", { className: "flex flex-col gap-1 flex-1", children: softwares.map((software) => {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
const hasIcon = Boolean(software.icon && software.icon.trim() !== "");
|
|
115
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: (_a = software.url) !== null && _a !== void 0 ? _a : "#", children: [hasIcon ? (_jsx(Icon, { name: toPascalCase((_b = software.icon) !== null && _b !== void 0 ? _b : ""), className: "h-8 w-8" })) : (_jsx(FolderCode, { className: "h-8 w-8" })), _jsx("span", { className: "sr-only", children: software.displayName })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: software.displayName })] }, software.displayName));
|
|
116
|
+
}) }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, className: "h-8 w-8", children: _jsx(Button, { variant: "ghost", className: "h-10 w-10", asChild: true, children: _jsxs(Link, { href: `${platformUrl}/settings`, children: [_jsx(Settings, { className: "h-8 w-8" }), _jsx("span", { className: "sr-only", children: "Settings" })] }) }) }), _jsx(TooltipContent, { side: "right", sideOffset: 5, children: "Settings" })] }, "settings"), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-10 w-10", children: _jsx(CircleUserRound, { className: "h-8 w-8" }) }) }), _jsxs(DropdownMenuContent, { className: "w-55 p-0", side: "right", sideOffset: 8, children: [_jsxs("div", { className: "flex items-start gap-3 p-4 bg-card", children: [_jsx(CircleUserRound, { className: "h-8 w-8" }), _jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [_jsx("p", { className: "text-sm font-bold text-foreground blue-dark:text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userName }), _jsx("p", { className: "text-xs text-muted-foreground truncate", children: user === null || user === void 0 ? void 0 : user.userEmail }), _jsx("p", { className: "text-sm text-muted-foreground font-semibold", children: selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.accountName })] })] }), _jsx(DropdownMenuSeparator, { className: "my-0" }), _jsxs(DropdownMenuItem, { onClick: async () => {
|
|
117
|
+
await clearAllCookieSession();
|
|
118
|
+
redirect(`${platformUrl}/login.html`);
|
|
119
|
+
}, className: "flex items-center gap-2 px-4 py-3 cursor-pointer focus:bg-destructive dark:focus:bg-destructive blue-dark:focus:bg-destructive", children: [_jsx(LogOut, { className: "h-4 w-4 text-foreground" }), _jsx("span", { children: "Log out" })] })] })] })] }) }) }));
|
|
119
120
|
};
|
|
@@ -32,17 +32,14 @@ export function CustomTabs({ children, tabArray, pathName, tabListClass = "", ta
|
|
|
32
32
|
onTabChange === null || onTabChange === void 0 ? void 0 : onTabChange(tabId);
|
|
33
33
|
};
|
|
34
34
|
const handleGroupedTabSelect = (tab) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
return [...updatedTabs, tab];
|
|
45
|
-
});
|
|
35
|
+
const replacedTab = visibleTabs[visibleTabs.length - 1];
|
|
36
|
+
const newVisibleTabs = [...visibleTabs.slice(0, -1), tab];
|
|
37
|
+
const newGroupedTabs = [
|
|
38
|
+
...groupedTabs.filter((t) => t.tabId !== tab.tabId),
|
|
39
|
+
...(replacedTab ? [replacedTab] : []),
|
|
40
|
+
];
|
|
41
|
+
setVisibleTabs(newVisibleTabs);
|
|
42
|
+
setGroupedTabs(newGroupedTabs);
|
|
46
43
|
handleTabChange(tab.tabId);
|
|
47
44
|
};
|
|
48
45
|
return (_jsxs(TabsComp, { value: activeTab, onValueChange: handleTabChange, className: "w-full h-full flex flex-col", children: [_jsxs("div", { className: `flex items-center justify-between ${tabListClass}`, children: [_jsx(TabsList, { className: `
|