Skip to content

Commit 18c053e

Browse files
committed
Skip load app settings for new created resources
1 parent 8e0fe85 commit 18c053e

File tree

1 file changed

+6
-10
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/ui

1 file changed

+6
-10
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-appservice/src/main/java/com/microsoft/azure/toolkit/intellij/legacy/function/runner/deploy/ui/FunctionDeploymentPanel.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,7 @@ private void onSelectFunctionSlot(final DeploymentSlotConfig value) {
188188
}
189189
toggleDeploymentSlot(chkSlot.isSelected());
190190
if (chkSlot.isSelected()) {
191-
if (value.isNewCreate()) {
192-
appSettingsTable.clear();
193-
} else {
194-
loadAppSettings(getResourceId(functionAppComboBox.getValue(), value));
195-
}
191+
loadAppSettings(getResourceId(Objects.requireNonNull(functionAppComboBox.getValue()), value), value.isNewCreate());
196192
}
197193
}
198194

@@ -208,17 +204,17 @@ private void onSelectFunctionApp(final FunctionAppConfig value) {
208204
toggleDeploymentSlot(chkSlot.isSelected());
209205
this.cbDeploymentSlot.setAppService(value.getResourceId());
210206
if (!this.chkSlot.isSelected()) {
211-
loadAppSettings(getResourceId(value, null));
207+
loadAppSettings(getResourceId(value, null), StringUtils.isEmpty(value.getResourceId()));
212208
}
213209
}
214210

215-
private void loadAppSettings(@Nullable final String resourceId) {
211+
private void loadAppSettings(@Nullable final String resourceId, final boolean isNewResource) {
216212
if (StringUtils.equalsIgnoreCase(resourceId, this.appSettingsResourceId) && MapUtils.isNotEmpty(this.appSettingsTable.getAppSettings())) {
217213
return;
218214
}
219215
this.appSettingsResourceId = resourceId;
220216
this.appSettingsTable.loadAppSettings(() -> {
221-
final AbstractAzResource<?, ?, ?> resource = StringUtils.isBlank(resourceId) ? null : Azure.az().getById(resourceId);
217+
final AbstractAzResource<?, ?, ?> resource = StringUtils.isBlank(resourceId) || isNewResource ? null : Azure.az().getById(resourceId);
222218
return resource instanceof AppServiceAppBase<?, ?, ?> ? ((AppServiceAppBase<?, ?, ?>) resource).getAppSettings() : Collections.emptyMap();
223219
});
224220
}
@@ -252,9 +248,9 @@ private void onSlotCheckBoxChanged() {
252248
final DeploymentSlotConfig slot = cbDeploymentSlot.getValue();
253249
// reload app settings when switch slot configuration
254250
if (chkSlot.isSelected() && ObjectUtils.allNotNull(function, slot)) {
255-
loadAppSettings(getResourceId(functionAppComboBox.getValue(), slot));
251+
loadAppSettings(getResourceId(functionAppComboBox.getValue(), slot), slot.isNewCreate());
256252
} else if (!chkSlot.isSelected() && Objects.nonNull(function)) {
257-
loadAppSettings(getResourceId(functionAppComboBox.getValue(), null));
253+
loadAppSettings(getResourceId(functionAppComboBox.getValue(), null), StringUtils.isEmpty(function.getResourceId()));
258254
}
259255
}
260256

0 commit comments

Comments
 (0)