From ea2ef4b9e38b6ce1480252f707589e17e58c556b Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 13 May 2024 20:18:14 +0530 Subject: [PATCH] ADST-431 (#345) * update text color of action button * review correction * review correction * added api error handling message * added api error handling message * localisation added --- .../com/alfresco/content/actions/Action.kt | 4 +++- capture/src/main/res/values/strings.xml | 2 +- .../main/res/layout/view_actions_list_row.xml | 1 + .../alfresco/content/data/AnalyticsManager.kt | 5 ++++- .../alfresco/content/data/AnalyticsRepository.kt | 3 +++ .../alfresco/content/listview/ListViewMessage.kt | 5 +++++ .../process/ui/fragments/FormViewModel.kt | 16 ++++++++++++++-- .../ui/fragments/ProcessAttachFilesFragment.kt | 7 ++++++- .../ui/fragments/ProcessAttachFilesViewModel.kt | 3 ++- .../process/ui/fragments/ProcessFragment.kt | 13 +++++++++++++ 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 + process-app/src/main/res/values/strings.xml | 4 +++- 16 files changed, 60 insertions(+), 8 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 2a69185bb..d662c1943 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 05af356dd..7304edf42 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. 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 7a36fe391..ce0a2bb51 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/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt index ff7dafa6e..b1f8ace23 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 b02067f77..3486e63ac 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/listview/src/main/kotlin/com/alfresco/content/listview/ListViewMessage.kt b/listview/src/main/kotlin/com/alfresco/content/listview/ListViewMessage.kt index 80e91eade..3aac0932e 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/FormViewModel.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/FormViewModel.kt index 2b4afddcd..8c55ace68 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/ProcessAttachFilesFragment.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessAttachFilesFragment.kt index 9daffecdb..963e9d365 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 @@ -84,7 +85,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, 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 31f870eca..bc93eebc7 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/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/fragments/ProcessFragment.kt index 866d4f283..50cd74db7 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-de/strings.xml b/process-app/src/main/res/values-de/strings.xml index 33edfd9e6..d6d7f2d79 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 c8e8f334d..4f7d4c984 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 a2bc7a82e..5754cce49 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 a349f8d2c..2110011dc 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 c00e6052b..fb35be3c2 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. diff --git a/process-app/src/main/res/values/strings.xml b/process-app/src/main/res/values/strings.xml index c49a69d8d..6c20f52f8 100644 --- a/process-app/src/main/res/values/strings.xml +++ b/process-app/src/main/res/values/strings.xml @@ -13,8 +13,10 @@ 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: %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 %d MB. + Something went wrong. Contact your administrator for help.