From e9f429a32bb1c1f07636bdaa25590a1c125883df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20D=C3=B6rbandt?= Date: Wed, 3 Jul 2024 17:16:36 +0200 Subject: [PATCH] Add option to skipp or overwrite all mapped paths when importing a directory --- .../instance/importDirectory..st | 49 +++++++++++++++++-- .../methodProperties.json | 2 +- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/Squot.package/SquotAssetBrowser.class/instance/importDirectory..st b/src/Squot.package/SquotAssetBrowser.class/instance/importDirectory..st index 13055c179..a1de58fbe 100644 --- a/src/Squot.package/SquotAssetBrowser.class/instance/importDirectory..st +++ b/src/Squot.package/SquotAssetBrowser.class/instance/importDirectory..st @@ -1,8 +1,47 @@ importing importDirectory: aReference - | basePath | - basePath := (self - requestPathWithSuffix: nil - title: 'Base path for assets in the repository:') ifNil: [^ self]. + | optionIfMapped basePath | + optionIfMapped := nil. + basePath := self initialPathRequestAnswerWithSuffix: nil. + [| askAgain mappedPaths | + basePath := (SquotPathUtilities + requestAbsolute: 'Base path for assets in the repository:' + initialAnswer: basePath) + ifNil: [^ self]. + askAgain := false. + mappedPaths := ((aReference allFiles + collect: [:each | basePath resolve: (each path relativeTo: aReference path)]) + reject: [:each | self activeWorkingCopy isUnmappedPath: each]) + collect: [:each | SquotPathUtilities asString: each]. + mappedPaths ifNotEmpty: [| answer | + answer := UIManager default + chooseOptionFrom: { + 'Choose a different base path'. + 'Skip taken paths'. + 'Overwrite taken paths (if possible)'. + 'Ask for each taken path'. + 'Cancel'. + } + values: {#different. #skip. #overwrite. #ask. #cancel} + title: (('{1} paths' format: {mappedPaths size}) asText + addAttribute: (PluggableTextAttribute evalBlock: [ + self inform: (mappedPaths joinSeparatedBy: String cr)]); + yourself), ' inside the base path are already taken.'. + answer caseOf: { + [#different] -> [askAgain := true]. + [#skip] -> [optionIfMapped := #skip]. + [#overwrite] -> [optionIfMapped := #overwrite]. + [#ask] -> ["fall through"]. + [#cancel] -> [^ self]. + }]. + askAgain] whileTrue. aReference allFiles do: [:each | - self importFile: each getPath: [basePath resolve: (each path relativeTo: aReference path)]]. \ No newline at end of file + self importFile: each getPath: [| relativePath answer | + relativePath := each path relativeTo: aReference path. + answer := self activeWorkingCopy + getUnmappedPathFrom: (basePath resolve: relativePath) + withTitle: ('Path in the respository for the imported asset {1}:' format: {relativePath}) + additionalOptions: {'Skip this file' -> #skip} + optionIfMapped: [optionIfMapped]. + answer ifNil: [^ self "cancel entire directory import"]. + answer = #skip ifTrue: [nil] ifFalse: [answer]]]. \ No newline at end of file diff --git a/src/Squot.package/SquotAssetBrowser.class/methodProperties.json b/src/Squot.package/SquotAssetBrowser.class/methodProperties.json index 4b8507b06..b5ad9fb19 100644 --- a/src/Squot.package/SquotAssetBrowser.class/methodProperties.json +++ b/src/Squot.package/SquotAssetBrowser.class/methodProperties.json @@ -45,7 +45,7 @@ "defaultFileNameFor:" : "mad 10/21/2023 23:08", "defaultPath" : "mad 10/19/2023 12:08", "formatFileName:" : "mad 10/21/2023 23:11", - "importDirectory:" : "mad 10/19/2023 13:53", + "importDirectory:" : "mad 7/3/2024 17:13", "importFile:" : "mad 10/19/2023 13:52", "importFile:getPath:" : "mad 4/5/2024 19:49", "importMapper:fromStream:" : "mad 10/23/2023 14:43",