Skip to content

Commit d5a3e03

Browse files
committed
feat(client):pending changes badge
1 parent 285c54d commit d5a3e03

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

Diff for: packages/amplication-client/src/Application/ApplicationLayout.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function ApplicationLayout({ match }: Props) {
5959
const [pendingChanges, setPendingChanges] = useState<PendingChangeItem[]>([]);
6060

6161
const [selectedFixedPanel, setSelectedFixedPanel] = useState<string>(
62-
EnumFixedPanelKeys.PendingChanges
62+
EnumFixedPanelKeys.None
6363
);
6464

6565
const handleMenuItemWithFixedPanelClicked = useCallback(
@@ -146,6 +146,9 @@ function ApplicationLayout({ match }: Props) {
146146
[pendingChanges, addEntity, addBlock, addChange, refetch]
147147
);
148148

149+
const pendingChangesBadge =
150+
(pendingChanges.length && pendingChanges.length.toString()) || null;
151+
149152
return (
150153
<PendingChangesContext.Provider value={pendingChangesContextValue}>
151154
<MainLayout className={CLASS_NAME}>
@@ -168,6 +171,7 @@ function ApplicationLayout({ match }: Props) {
168171
icon="pending_changes_outline"
169172
isOpen={selectedFixedPanel === EnumFixedPanelKeys.PendingChanges}
170173
panelKey={EnumFixedPanelKeys.PendingChanges}
174+
badgeValue={pendingChangesBadge}
171175
onClick={handleMenuItemWithFixedPanelClicked}
172176
>
173177
<PendingChangesBar applicationId={application} />

Diff for: packages/amplication-client/src/Layout/MenuItem.scss

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ $inverted-border-radius: 6px;
2929
width: 0;
3030
letter-spacing: normal;
3131
}
32+
&__badge {
33+
@include counterBadge;
34+
background-color: var(--negative-light);
35+
}
3236

3337
&:hover {
3438
background-color: transparent !important;

Diff for: packages/amplication-client/src/Layout/MenuItemWithFixedPanel.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type Props = {
1818
children?: ReactNode;
1919
/* the key of the panel to be returned to the menu component when this item is clicked*/
2020
panelKey: string;
21+
/* The value to show on a badge. When null or undefined the badge is hidden*/
22+
badgeValue?: string | null;
2123
onClick: (panelKey: string) => void;
2224
};
2325

@@ -30,6 +32,7 @@ const MenuItemWithFixedPanel = ({
3032
isOpen,
3133
children,
3234
panelKey,
35+
badgeValue,
3336
onClick,
3437
}: Props) => {
3538
const handleClick = useCallback(() => {
@@ -57,6 +60,9 @@ const MenuItemWithFixedPanel = ({
5760
}}
5861
/>
5962
</Button>
63+
{badgeValue && (
64+
<span className="amp-menu-item__badge">{badgeValue}</span>
65+
)}
6066
</Tooltip>
6167
</div>
6268
{isOpen && <MenuFixedPanel.Source>{children}</MenuFixedPanel.Source>}

Diff for: packages/amplication-client/src/VersionControl/PendingChangesBar.scss

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
border-top: $border-black10;
1212
margin: 0;
1313
}
14-
&__counter {
15-
@include counterBadge;
16-
}
1714

1815
.build-header {
1916
margin-top: var(--double-spacing);

Diff for: packages/amplication-client/src/style/css-variables.css

+2
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
--theme-turquoise: #41cadd;
99
--theme-green: #8dd9b9;
1010
--theme-blue: #20a4f3;
11+
12+
--negative-light: #f85b6e;
1113
}

Diff for: packages/amplication-client/src/style/mixin.scss

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ $bullet-size: 6px;
139139
top: -8px;
140140
left: calc(100% - 14px);
141141
height: 16px;
142+
min-width: 16px;
142143
background-color: var(--primary);
143144
color: var(--white);
144145
border-radius: 8px;

0 commit comments

Comments
 (0)