Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent/app/dto/response/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ type AppInstallDTO struct {
App AppDetail `json:"app"`
Container string `json:"container"`
IsEdit bool `json:"isEdit"`
LinkDB bool `json:"linkDB"`
}

type AppInstallInfo struct {
Expand Down
69 changes: 41 additions & 28 deletions agent/app/service/app_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1567,43 +1567,37 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool)
Favorite: installed.Favorite,
Container: installed.ContainerName,
}
if updated {
detail, _ := appDetailRepo.GetFirst(repo.WithByID(installed.AppDetailId))
installDTO.DockerCompose = installed.DockerCompose
rawCompose, _ := getUpgradeCompose(installed, detail)
if rawCompose != installed.DockerCompose {
installDTO.IsEdit = true
}
if !updated {
installDTO.LinkDB = hasLinkDB(installed.ID)
res = append(res, installDTO)
continue
}
app, err := appRepo.GetFirst(repo.WithByID(installed.AppId))
if err != nil {
return nil, err
if installed.Version == "latest" {
continue
}
details, err := appDetailRepo.GetBy(appDetailRepo.WithAppId(app.ID))
installDTO.DockerCompose = installed.DockerCompose
installDTO.IsEdit = isEditCompose(installed)
details, err := appDetailRepo.GetBy(appDetailRepo.WithAppId(installed.App.ID))
if err != nil {
return nil, err
}
var versions []string
for _, detail := range details {
ignores, _ := appIgnoreUpgradeRepo.List(runtimeRepo.WithDetailId(detail.ID), appIgnoreUpgradeRepo.WithScope("version"))
if len(ignores) > 0 || installed.Version == "latest" {
for _, appDetail := range details {
ignores, _ := appIgnoreUpgradeRepo.List(runtimeRepo.WithDetailId(appDetail.ID), appIgnoreUpgradeRepo.WithScope("version"))
if len(ignores) > 0 {
continue
}
if common.IsCrossVersion(installed.Version, detail.Version) && !app.CrossVersionUpdate {
if common.IsCrossVersion(installed.Version, appDetail.Version) && !installed.App.CrossVersionUpdate {
continue
}
versions = append(versions, detail.Version)
versions = append(versions, appDetail.Version)
}
versions = common.GetSortedVersions(versions)
if len(versions) == 0 {
if !updated {
installDTO.CanUpdate = false
res = append(res, installDTO)
}
continue
}
versions = common.GetSortedVersions(versions)
lastVersion := versions[0]
if app.Key == constant.AppMysql || app.Key == constant.AppMysqlCluster {
if installed.App.Key == constant.AppMysql || installed.App.Key == constant.AppMysqlCluster {
for _, version := range versions {
majorVersion := getMajorVersion(installed.Version)
if !strings.HasPrefix(version, majorVersion) {
Expand All @@ -1615,15 +1609,11 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool)
}
}
if common.IsCrossVersion(installed.Version, lastVersion) {
installDTO.CanUpdate = app.CrossVersionUpdate
installDTO.CanUpdate = installed.App.CrossVersionUpdate
} else {
installDTO.CanUpdate = common.CompareVersion(lastVersion, installed.Version)
}
if updated {
if installDTO.CanUpdate {
res = append(res, installDTO)
}
} else {
if installDTO.CanUpdate {
res = append(res, installDTO)
}
}
Expand Down Expand Up @@ -2142,3 +2132,26 @@ func needsUpdate(localTag *model.Tag, remoteTag dto.Tag, translations string) bo
localTag.Sort != remoteTag.Sort ||
localTag.Translations != translations
}

func hasLinkDB(installID uint) bool {
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(installID))
if len(resources) > 0 {
for _, resource := range resources {
if resource.Key == constant.AppPostgres || resource.Key == constant.AppMysql ||
resource.Key == constant.AppMariaDB || resource.Key == constant.AppMysqlCluster ||
resource.Key == constant.AppPostgresql || resource.Key == constant.AppPostgresqlCluster {
return true
}
}
}
return false
}

func isEditCompose(installed model.AppInstall) bool {
detail, _ := appDetailRepo.GetFirst(repo.WithByID(installed.AppDetailId))
rawCompose, _ := getUpgradeCompose(installed, detail)
if rawCompose != installed.DockerCompose {
return true
}
return false
}
1 change: 1 addition & 0 deletions frontend/src/api/interface/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export namespace App {
isEdit: boolean;
dockerCompose: string;
app: App.AppDetail;
linkDB: boolean;
}

export interface AppInstalledInfo {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/views/app-store/installed/delete/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{ $t('app.deleteImageHelper') }}
</span>
</el-form-item>
<el-form-item v-if="appType === 'website'">
<el-form-item v-if="appType === 'website' && linkDB">
<el-checkbox v-model="deleteReq.deleteDB" :label="$t('app.deleteDB')" />
<span class="input-help">
{{ $t('app.deleteDBHelper') }}
Expand Down Expand Up @@ -76,6 +76,7 @@ const deleteInfo = ref('');
const appInstallName = ref('');
const appType = ref('');
const taskLogRef = ref();
const linkDB = ref(false);

const deleteForm = ref<FormInstance>();
const em = defineEmits(['close']);
Expand Down Expand Up @@ -107,6 +108,7 @@ const acceptParams = async (app: App.AppInstallDto) => {
appType.value = app.appType;
deleteHelper.value = i18n.global.t('website.deleteConfirmHelper', [app.name]);
appInstallName.value = app.name;
linkDB.value = app.linkDB;
open.value = true;
};

Expand Down
Loading