-
Notifications
You must be signed in to change notification settings - Fork 17
Enable updating revision drafts through commands & leverage with Scale Rules
#423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weāll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
9ef3efa
Impl
MicroFish91 15f370f
Misc
MicroFish91 fc5b808
Import type
MicroFish91 26da94a
Misc
MicroFish91 f8cd7e0
Remove secret changes for separate PR
MicroFish91 10fa6d6
Remove extra refresh
MicroFish91 7da6384
Fix pick item logic in multiple revisions mode
MicroFish91 8f53127
noPicksMessage
MicroFish91 32b9861
Revert change for future PR
MicroFish91 95b66b3
Merge with main
MicroFish91 d95d633
First pass of fixes
MicroFish91 8fe805b
Remove abstract class
MicroFish91 fe93023
Rename context vars
MicroFish91 837d356
Merge branch 'main' of https://github.com/microsoft/vscode-azurecontaā¦
MicroFish91 1abc75d
RevisionDraftDescendantBase
MicroFish91 a40fc12
remove instanceof
MicroFish91 c13608a
import type
MicroFish91 fb901f2
Update regexp ref
MicroFish91 bb2484b
Remove optional
MicroFish91 0fe631d
More changes
MicroFish91 1847804
writeFile
MicroFish91 24da2bf
Changes
MicroFish91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,9 @@ | ||
| ## Detecting Unsaved Changes | ||
|
|
||
| When comparing items for changes in single revision mode, prefer referencing the `containerApp` template. When comparing items in multiple revisions mode, prefer referencing the `revision` template. | ||
|
|
||
| Reason: Even though the `containerApp` template is essentially equivalent to the `latest` revision template... sometimes there are micro-differences present. Although they end up being functionally equivalent, they may not always be equivalent enough to consistently pass a deep copy test (which is how we are set up to detect unsaved changes). | ||
|
|
||
| ## Data Sources for Tree Items | ||
|
|
||
| Until the addition of revision drafts, the view has always reflected only one source of truth - the latest deployed changes. With the addition of revision drafts, the view now prioritizes showing the latest draft `Unsaved changes` when they are present. Model properties `containerApp` and `revision` should be kept consistent with the latest deployed changes so that methods like `hasUnsavedChanges` always have a reliable data reference for deep copy comparison. |
This file contains hidden or 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 hidden or 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,41 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import type { Template } from "@azure/arm-appcontainers"; | ||
| import { AzureWizardExecuteStep, nonNullValueAndProp } from "@microsoft/vscode-azext-utils"; | ||
| import type { Progress } from "vscode"; | ||
| import { ext } from "../../extensionVariables"; | ||
| import type { RevisionsItemModel } from "../../tree/revisionManagement/RevisionItem"; | ||
| import type { IContainerAppContext } from "../IContainerAppContext"; | ||
|
|
||
| export abstract class RevisionDraftUpdateBaseStep<T extends IContainerAppContext> extends AzureWizardExecuteStep<T> { | ||
| /** | ||
| * This property holds the active template revisions used for updating the revision draft | ||
| */ | ||
| protected revisionDraftTemplate: Template; | ||
|
|
||
| constructor(readonly baseItem: RevisionsItemModel) { | ||
| super(); | ||
| this.revisionDraftTemplate = this.initRevisionDraftTemplate(); | ||
| } | ||
|
|
||
| abstract execute(context: T, progress: Progress<{ message?: string | undefined; increment?: number | undefined }>): Promise<void>; | ||
| abstract shouldExecute(context: T): boolean; | ||
|
|
||
| /** | ||
| * Call this method to upload `revisionDraftTemplate` changes to the container app revision draft | ||
| */ | ||
| protected updateRevisionDraftWithTemplate(): void { | ||
| ext.revisionDraftFileSystem.updateRevisionDraftWithTemplate(this.baseItem, this.revisionDraftTemplate); | ||
| } | ||
|
|
||
| private initRevisionDraftTemplate(): Template { | ||
| let template: Template | undefined = ext.revisionDraftFileSystem.parseRevisionDraft(this.baseItem); | ||
| if (!template) { | ||
| template = nonNullValueAndProp(this.baseItem.revision, 'template'); | ||
| } | ||
| return template; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of a weird name to me. I get that
getParentResourceis the command being invoked, butparentResourceNameis always referring to the container app name, right? Since the parent of the scale rule is the scale rule group item this was especially confusing to me.Can we just call it
containerAppName? Or can we not just get the CA name from the container app model? I think whether or not we're using the template or revision, thecontainerApp.nameproperty should be correct.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, so in general the parent resource name could be the container app name or the revision name, so we don't know which one it is until we actually build the context. It's following the same naming convention as used for the util which returns a container app model or revision model. We might still be able to come up with a better name though, since it's definitely not a direct parent and I see why that could be confusing
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially I could add
parentResource: ContainerAppItem | Revisionand just access the name property later when I need it. Felt like overkill to tack the whole thing on at the time, but it would make it a lot less confusing for situations like this where the nameparentis a bit ambiguous š¤There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just a comment about that then? I personally felt like it was pretty confusing.