Skip to content

Commit

Permalink
optimize the code
Browse files Browse the repository at this point in the history
Signed-off-by: yubonluo <yubonluo@amazon.com>
  • Loading branch information
yubonluo committed Oct 22, 2024
1 parent 6c6bc27 commit 05893cf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions public/components/overview/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ export const Home = () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [showGetStarted, setShowGetStarted] = useState<boolean | null>(null); // Initial null state

const isCurrentWorkspaceOwner = coreRefs.workspaces?.currentWorkspace$.getValue()?.owner;
const isDashboardAdmin =
coreRefs.application?.capabilities?.dashboards?.isDashboardAdmin !== false;
// When workspace enabled, only workspace owner/OSD admin can update observability:defaultDashboard.
const canUpdateUiSetting = useMemo(() => {
if (coreRefs.application?.capabilities?.workspaces?.enabled) {
const isCurrentWorkspaceOwner = coreRefs.workspaces?.currentWorkspace$.getValue()?.owner;
const isDashboardAdmin =
coreRefs.application?.capabilities?.dashboards?.isDashboardAdmin !== false;
const capabilities = coreRefs.application?.capabilities;
if (capabilities?.workspaces?.enabled) {
return isCurrentWorkspaceOwner || isDashboardAdmin;
} else {
return true;
}
}, [coreRefs.workspaces, coreRefs.application?.capabilities]);
return true;
}, [isCurrentWorkspaceOwner, isDashboardAdmin]);

ObsDashboardStateManager.showFlyout$.next(() => () => setIsFlyoutVisible(true));

Expand Down

0 comments on commit 05893cf

Please sign in to comment.