-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: [UIE-8228] - Database Resize: disable same size plan (#11481)
* change: [UIE-8228] - Database Resize: disable same size plan * Added changeset: Database Resize: Disable plans when the usable storage equals the used storage of the database cluster
- Loading branch information
1 parent
e97ff2f
commit 5a20623
Showing
4 changed files
with
131 additions
and
143 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11481-changed-1736250933443.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Changed | ||
--- | ||
|
||
Database Resize: Disable plans when the usable storage equals the used storage of the database cluster ([#11481](https://github.com/linode/manager/pull/11481)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ges/manager/src/features/Databases/DatabaseDetail/DatabaseResize/DatabaseResize.utils.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { convertMegabytesTo } from 'src/utilities/unitConversions'; | ||
|
||
import type { PlanSelectionWithDatabaseType } from 'src/features/components/PlansPanel/types'; | ||
|
||
/** | ||
* Filters a list of plans based on the current plan's disk size or the current used disk size. | ||
* | ||
* @param {string | undefined} currentPlanID - The ID of the current plan. | ||
* @param {null | number} currentUsedDiskSize - The current used disk size. | ||
* @param {PlanSelectionWithDatabaseType[]} types - The list of available plans to filter. | ||
* @param {boolean} [isNewDatabase] - Optional flag indicating whether the database is new. If true, the filtering logic based on disk usage is applied. | ||
* | ||
* @returns {PlanSelectionWithDatabaseType[]} A filtered list of plans based on the conditions: | ||
* - If `isNewDatabase` is false and `currentPlanID` is provided, plans with disk sizes smaller or equal to the current plan are included. | ||
* - If `isNewDatabase` is true, plans are filtered based on their disk size compared to the current used disk size. | ||
*/ | ||
export const isSmallerOrEqualCurrentPlan = ( | ||
currentPlanID: string | undefined, | ||
currentUsedDiskSize: null | number, | ||
types: PlanSelectionWithDatabaseType[], | ||
isNewDatabase?: boolean | ||
) => { | ||
const currentType = types.find((thisType) => thisType.id === currentPlanID); | ||
|
||
return !isNewDatabase && currentType | ||
? types?.filter((type) => | ||
type.class === 'dedicated' | ||
? type.disk < currentType?.disk | ||
: type.disk <= currentType?.disk | ||
) | ||
: types?.filter( | ||
(type) => | ||
currentUsedDiskSize && | ||
currentUsedDiskSize >= | ||
+convertMegabytesTo(type.disk, true) | ||
.split(/(GB|MB|KB)/i)[0] | ||
.trim() | ||
); | ||
}; |