From 282260cb5869302924ad5da305838fc44cbffac9 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Fri, 10 May 2024 21:58:16 +0530 Subject: [PATCH 1/6] update text color of action button --- component/src/main/res/layout/view_actions_list_row.xml | 1 + .../process/ui/fragments/ProcessAttachFilesFragment.kt | 6 +++++- process-app/src/main/res/values/strings.xml | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/component/src/main/res/layout/view_actions_list_row.xml b/component/src/main/res/layout/view_actions_list_row.xml index 7a36fe39..ce0a2bb5 100644 --- a/component/src/main/res/layout/view_actions_list_row.xml +++ b/component/src/main/res/layout/view_actions_list_row.xml @@ -11,6 +11,7 @@ style="@style/Widget.Alfresco.Component.Primary" android:layout_width="0dp" android:layout_height="48dp" + android:textColor="@color/white" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt index 9daffecd..68d5cf48 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt @@ -84,7 +84,11 @@ class ProcessAttachFilesFragment : ProcessBaseFragment(), MavericksView, EntryLi if (isAdded) { if (state.listContents.isNotEmpty()) { binding.tvNoOfAttachments.visibility = View.VISIBLE - binding.tvNoOfAttachments.text = getString(R.string.text_multiple_attachment, state.listContents.size) + val filesHeader = StringBuilder() + filesHeader.append(getString(R.string.text_multiple_attachment, state.listContents.size)) + .append("\n") + .append(getString(R.string.process_max_file_size)) + binding.tvNoOfAttachments.text = filesHeader } else { binding.tvNoOfAttachments.visibility = View.GONE } diff --git a/process-app/src/main/res/values/strings.xml b/process-app/src/main/res/values/strings.xml index c49a69d8..bbc70100 100644 --- a/process-app/src/main/res/values/strings.xml +++ b/process-app/src/main/res/values/strings.xml @@ -13,8 +13,9 @@ No Folder Attached %d folder(s) Info - Looks like you haven’t\nadded any files yet. + Looks like you haven’t\nadded any files yet\n(Max file size: 10 MB). Search Folder %1$s has Invalid URL Not able to attach the selected content in this form. + Please note: Maximum file size for uploads is 10 MB. From e117f4c2b39c786e2a98d2d8cc48e66717d997ed Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 13 May 2024 15:50:00 +0530 Subject: [PATCH 2/6] review correction --- .../src/main/kotlin/com/alfresco/content/actions/Action.kt | 4 +++- capture/src/main/res/values/strings.xml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/Action.kt b/actions/src/main/kotlin/com/alfresco/content/actions/Action.kt index 2a69185b..d662c194 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/Action.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/Action.kt @@ -5,6 +5,7 @@ import android.content.Context import android.view.View import androidx.annotation.StringRes import com.alfresco.Logger +import com.alfresco.content.GetMultipleContents.Companion.MAX_FILE_SIZE_10 import com.alfresco.content.data.APIEvent import com.alfresco.content.data.AnalyticsManager import com.alfresco.content.data.Entry @@ -55,9 +56,10 @@ interface Action { ex.message == ERROR_FILE_SIZE_EXCEED -> { bus.send(Error(context.getString(R.string.error_file_size_exceed))) } + entry is Entry && (entry as Entry).uploadServer == UploadServerType.UPLOAD_TO_PROCESS && ex.message == ERROR_FILE_SIZE_EXCEED -> { - bus.send(Error(context.getString(R.string.error_file_size_exceed_10mb))) + bus.send(Error(context.getString(R.string.error_file_size_exceed_10mb, MAX_FILE_SIZE_10))) } } } catch (ex: Exception) { diff --git a/capture/src/main/res/values/strings.xml b/capture/src/main/res/values/strings.xml index 05af356d..7304edf4 100644 --- a/capture/src/main/res/values/strings.xml +++ b/capture/src/main/res/values/strings.xml @@ -28,6 +28,6 @@ %02d:%02d:%02d %02d:%02d The selected file size cannot exceed 100MB to upload. - The selected file size cannot exceed 10MB to upload. + The selected file size cannot exceed %d MB to upload. From 76ba8c3eca29f43c9d70f2ec672921d2f445987c Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 13 May 2024 16:01:40 +0530 Subject: [PATCH 3/6] review correction --- .../kotlin/com/alfresco/content/listview/ListViewMessage.kt | 5 +++++ .../process/ui/fragments/ProcessAttachFilesFragment.kt | 3 ++- .../process/ui/fragments/ProcessAttachFilesViewModel.kt | 3 ++- process-app/src/main/res/values/strings.xml | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/listview/src/main/kotlin/com/alfresco/content/listview/ListViewMessage.kt b/listview/src/main/kotlin/com/alfresco/content/listview/ListViewMessage.kt index 80e91ead..3aac0932 100644 --- a/listview/src/main/kotlin/com/alfresco/content/listview/ListViewMessage.kt +++ b/listview/src/main/kotlin/com/alfresco/content/listview/ListViewMessage.kt @@ -33,4 +33,9 @@ class ListViewMessage @JvmOverloads constructor( fun setMessage(@StringRes stringRes: Int) { binding.message.text = resources.getText(stringRes) } + + @ModelProp + fun setMessage(stringRes: String) { + binding.message.text = stringRes + } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt index 68d5cf48..963e9d36 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt @@ -12,6 +12,7 @@ import com.airbnb.epoxy.AsyncEpoxyController import com.airbnb.mvrx.MavericksView import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState +import com.alfresco.content.GetMultipleContents import com.alfresco.content.actions.ActionOpenWith import com.alfresco.content.common.EntryListener import com.alfresco.content.data.AnalyticsManager @@ -87,7 +88,7 @@ class ProcessAttachFilesFragment : ProcessBaseFragment(), MavericksView, EntryLi val filesHeader = StringBuilder() filesHeader.append(getString(R.string.text_multiple_attachment, state.listContents.size)) .append("\n") - .append(getString(R.string.process_max_file_size)) + .append(getString(R.string.process_max_file_size, GetMultipleContents.MAX_FILE_SIZE_10)) binding.tvNoOfAttachments.text = filesHeader } else { binding.tvNoOfAttachments.visibility = View.GONE diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesViewModel.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesViewModel.kt index 31f870ec..bc93eebc 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesViewModel.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesViewModel.kt @@ -5,6 +5,7 @@ import com.airbnb.mvrx.MavericksViewModel import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.Success import com.airbnb.mvrx.ViewModelContext +import com.alfresco.content.GetMultipleContents import com.alfresco.content.actions.Action import com.alfresco.content.actions.ActionOpenWith import com.alfresco.content.common.EntryListener @@ -85,7 +86,7 @@ class ProcessAttachFilesViewModel( fun emptyMessageArgs(state: ProcessAttachFilesViewState) = when { else -> - Triple(R.drawable.ic_empty_files, R.string.no_attached_files, R.string.file_empty_message) + Triple(R.drawable.ic_empty_files, R.string.no_attached_files, context.getString(R.string.file_empty_message, GetMultipleContents.MAX_FILE_SIZE_10)) } /** diff --git a/process-app/src/main/res/values/strings.xml b/process-app/src/main/res/values/strings.xml index bbc70100..d703b5f6 100644 --- a/process-app/src/main/res/values/strings.xml +++ b/process-app/src/main/res/values/strings.xml @@ -13,9 +13,9 @@ No Folder Attached %d folder(s) Info - Looks like you haven’t\nadded any files yet\n(Max file size: 10 MB). + Looks like you haven’t\nadded any files yet\n(Max file size: %d MB). Search Folder %1$s has Invalid URL Not able to attach the selected content in this form. - Please note: Maximum file size for uploads is 10 MB. + Please note: Maximum file size for uploads is %d MB. From ec22d40e93e451ae1e1e1101b6ea4c0d95bbedff Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 13 May 2024 20:01:36 +0530 Subject: [PATCH 4/6] added api error handling message --- .../alfresco/content/data/AnalyticsManager.kt | 5 ++++- .../alfresco/content/data/AnalyticsRepository.kt | 3 +++ .../com/alfresco/content/data/TaskRepository.kt | 2 +- .../process/ui/fragments/FormViewModel.kt | 16 ++++++++++++++-- .../process/ui/fragments/ProcessFragment.kt | 13 +++++++++++++ process-app/src/main/res/values/strings.xml | 1 + 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt index ff7dafa6..b1f8ace2 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt @@ -118,7 +118,7 @@ class AnalyticsManager(otherSession: Session? = null) { /** * analytics for API tracker */ - fun apiTracker(apiName: APIEvent, status: Boolean = false, size: String = "") { + fun apiTracker(apiName: APIEvent, status: Boolean = false, size: String = "", outcome: String = "") { val apiTrackName = if (status) "${apiName.value}_success".lowercase() else "${apiName.value}_fail".lowercase() val params = repository.defaultParams() @@ -127,6 +127,9 @@ class AnalyticsManager(otherSession: Session? = null) { if (size.isNotEmpty()) { params.putString(Parameters.FileSize.value, size) } + if (outcome.isNotEmpty()) { + params.putString(Parameters.ActionOutcome.value, outcome) + } repository.logEvent(apiTrackName, params) } } diff --git a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt index b02067f7..3486e63a 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt @@ -156,6 +156,8 @@ enum class APIEvent(val value: String) { DeleteTaskAttachment("event_api_delete_task_attachment"), AssignUser("event_api_assign_user"), SearchUser("event_api_search_user"), + StartWorkflow("event_api_start_workflow"), + Outcomes("event_api_outcomes"), } /** @@ -191,4 +193,5 @@ enum class Parameters(val value: String) { NumberOfFiles("number_of_files"), FacetName("facet_name"), Success("success"), + ActionOutcome("action_outcome"), } diff --git a/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt b/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt index 7d879bab..858df82d 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt @@ -384,7 +384,7 @@ class TaskRepository { processesService.createProcessInstance( RequestProcessInstances( name = processEntry?.name, - processDefinitionId = processEntry?.id, + processDefinitionId = "", values = values, ), ), diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt index 2b4afddc..8c55ace6 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt @@ -14,6 +14,8 @@ import com.alfresco.content.DATE_FORMAT_2_1 import com.alfresco.content.DATE_FORMAT_4_1 import com.alfresco.content.DATE_FORMAT_5 import com.alfresco.content.common.EntryListener +import com.alfresco.content.data.APIEvent +import com.alfresco.content.data.AnalyticsManager import com.alfresco.content.data.AttachFilesData import com.alfresco.content.data.AttachFolderSearchData import com.alfresco.content.data.DefaultOutcomesID @@ -448,8 +450,16 @@ class FormViewModel( repository::startWorkflow.asFlow(state.parent, "", convertFieldsToValues(state.formFields)).execute { when (it) { is Loading -> copy(requestStartWorkflow = Loading()) - is Fail -> copy(requestStartWorkflow = Fail(it.error)) - is Success -> copy(requestStartWorkflow = Success(it())) + is Fail -> { + AnalyticsManager().apiTracker(APIEvent.StartWorkflow, false) + copy(requestStartWorkflow = Fail(it.error)) + } + + is Success -> { + AnalyticsManager().apiTracker(APIEvent.StartWorkflow, true) + copy(requestStartWorkflow = Success(it())) + } + else -> this } } @@ -473,10 +483,12 @@ class FormViewModel( when (it) { is Loading -> copy(requestOutcomes = Loading()) is Fail -> { + AnalyticsManager().apiTracker(APIEvent.Outcomes, false, outcome = outcome) copy(requestOutcomes = Fail(it.error)) } is Success -> { + AnalyticsManager().apiTracker(APIEvent.Outcomes, true, outcome = outcome) copy(requestOutcomes = Success(it())) } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt index 866d4f28..50cd74db 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.navigation.findNavController +import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Loading import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.MavericksView @@ -162,6 +163,7 @@ class ProcessFragment : Fragment(), MavericksView, EntryListener { state.requestSaveForm is Loading || state.requestOutcomes is Loading || state.requestProfile is Loading || state.requestAccountInfo is Loading || state.requestContent is Loading + handleError(state) when { state.requestStartWorkflow is Success || state.requestSaveForm is Success || state.requestOutcomes is Success || state.requestClaimRelease is Success -> { @@ -215,6 +217,17 @@ class ProcessFragment : Fragment(), MavericksView, EntryListener { menu?.findItem(R.id.action_info)?.isVisible = state.parent.processInstanceId != null } + private fun handleError(state: FormViewState) { + when { + state.requestStartWorkflow is Fail<*> || state.requestForm is Fail<*> || + state.requestSaveForm is Fail<*> || state.requestProfile is Fail<*> || state.request is Fail<*> || + state.requestOutcomes is Fail<*> || state.requestContent is Fail<*> || state.requestProcessDefinition is Fail<*> || + state.requestClaimRelease is Fail<*> || state.requestFormVariables is Fail<*> || state.requestAccountInfo is Fail<*> -> { + showSnackBar(getString(R.string.error_process_failure)) + } + } + } + override fun onAttachFolder(entry: ParentEntry) = withState(viewModel) { if (isAdded && viewModel.selectedField?.type == FieldType.SELECT_FOLDER.value()) { viewModel.updateFieldValue( diff --git a/process-app/src/main/res/values/strings.xml b/process-app/src/main/res/values/strings.xml index d703b5f6..6c20f52f 100644 --- a/process-app/src/main/res/values/strings.xml +++ b/process-app/src/main/res/values/strings.xml @@ -18,4 +18,5 @@ %1$s has Invalid URL Not able to attach the selected content in this form. Please note: Maximum file size for uploads is %d MB. + Something went wrong. Contact your administrator for help. From 5fd22b1f658f155ad0dd46e271e2db5ffb42e0ac Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 13 May 2024 20:02:09 +0530 Subject: [PATCH 5/6] added api error handling message --- .../src/main/kotlin/com/alfresco/content/data/TaskRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt b/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt index 858df82d..7d879bab 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/TaskRepository.kt @@ -384,7 +384,7 @@ class TaskRepository { processesService.createProcessInstance( RequestProcessInstances( name = processEntry?.name, - processDefinitionId = "", + processDefinitionId = processEntry?.id, values = values, ), ), From dd8b65b032fc0ff633f3176ee94ab73ac0c56611 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 13 May 2024 20:08:51 +0530 Subject: [PATCH 6/6] localisation added --- process-app/src/main/res/values-de/strings.xml | 1 + process-app/src/main/res/values-es/strings.xml | 1 + process-app/src/main/res/values-fr/strings.xml | 1 + process-app/src/main/res/values-it/strings.xml | 1 + process-app/src/main/res/values-nl/strings.xml | 1 + 5 files changed, 5 insertions(+) diff --git a/process-app/src/main/res/values-de/strings.xml b/process-app/src/main/res/values-de/strings.xml index 33edfd9e..d6d7f2d7 100644 --- a/process-app/src/main/res/values-de/strings.xml +++ b/process-app/src/main/res/values-de/strings.xml @@ -10,4 +10,5 @@ Aktionen Schaltfläche „Aktionen verarbeiten“ Keine Anhänge + Etwas ist schiefgelaufen. Kontaktieren Sie Ihren Administrator für Hilfe. diff --git a/process-app/src/main/res/values-es/strings.xml b/process-app/src/main/res/values-es/strings.xml index c8e8f334..4f7d4c98 100644 --- a/process-app/src/main/res/values-es/strings.xml +++ b/process-app/src/main/res/values-es/strings.xml @@ -10,4 +10,5 @@ Acciones Botón de acciones de procesos Sin adjuntos + Ha surgido un error. Contacte a su administrador para obtener ayuda. diff --git a/process-app/src/main/res/values-fr/strings.xml b/process-app/src/main/res/values-fr/strings.xml index a2bc7a82..5754cce4 100644 --- a/process-app/src/main/res/values-fr/strings.xml +++ b/process-app/src/main/res/values-fr/strings.xml @@ -10,4 +10,5 @@ Actions Bouton d\'actions de traitement Aucune pièce jointe + Un problème est survenu. Pour obtenir de l\'aide, contactez votre administrateur Alfresco. diff --git a/process-app/src/main/res/values-it/strings.xml b/process-app/src/main/res/values-it/strings.xml index a349f8d2..2110011d 100644 --- a/process-app/src/main/res/values-it/strings.xml +++ b/process-app/src/main/res/values-it/strings.xml @@ -10,4 +10,5 @@ Azioni Pulsante Elabora azioni Nessun allegato + Si è verificato un problema. Per assistenza, contatta il tuo amministratore. diff --git a/process-app/src/main/res/values-nl/strings.xml b/process-app/src/main/res/values-nl/strings.xml index c00e6052..fb35be3c 100644 --- a/process-app/src/main/res/values-nl/strings.xml +++ b/process-app/src/main/res/values-nl/strings.xml @@ -10,4 +10,5 @@ Acties Knop Procesacties Geen bijlagen + Er is iets fout gegaan. Neem contact op met uw beheerder voor hulp.