Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADST-431 #345

Merged
merged 6 commits into from
May 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion capture/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
<string name="format_video_duration_hour" translatable="false">%02d:%02d:%02d</string>
<string name="format_video_duration_minute" translatable="false">%02d:%02d</string>
<string name="error_file_size_exceed">The selected file size cannot exceed 100MB to upload.</string>
<string name="error_file_size_exceed_10mb">The selected file size cannot exceed 10MB to upload.</string>
<string name="error_file_size_exceed_10mb">The selected file size cannot exceed %d MB to upload.</string>

</resources>
1 change: 1 addition & 0 deletions component/src/main/res/layout/view_actions_list_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}

/**
Expand Down Expand Up @@ -191,4 +193,5 @@ enum class Parameters(val value: String) {
NumberOfFiles("number_of_files"),
FacetName("facet_name"),
Success("success"),
ActionOutcome("action_outcome"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 -> {
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions process-app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<string name="title_actions">Aktionen</string>
<string name="accessibility_process_actions">Schaltfläche „Aktionen verarbeiten“</string>
<string name="no_attachments">Keine Anhänge</string>
<string name="error_process_failure">Etwas ist schiefgelaufen. Kontaktieren Sie Ihren Administrator für Hilfe.</string>
</resources>
1 change: 1 addition & 0 deletions process-app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<string name="title_actions">Acciones</string>
<string name="accessibility_process_actions">Botón de acciones de procesos</string>
<string name="no_attachments">Sin adjuntos</string>
<string name="error_process_failure">Ha surgido un error. Contacte a su administrador para obtener ayuda.</string>
</resources>
1 change: 1 addition & 0 deletions process-app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<string name="title_actions">Actions</string>
<string name="accessibility_process_actions">Bouton d\'actions de traitement</string>
<string name="no_attachments">Aucune pièce jointe</string>
<string name="error_process_failure">Un problème est survenu. Pour obtenir de l\'aide, contactez votre administrateur Alfresco.</string>
</resources>
1 change: 1 addition & 0 deletions process-app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<string name="title_actions">Azioni</string>
<string name="accessibility_process_actions">Pulsante Elabora azioni</string>
<string name="no_attachments">Nessun allegato</string>
<string name="error_process_failure">Si è verificato un problema. Per assistenza, contatta il tuo amministratore.</string>
</resources>
1 change: 1 addition & 0 deletions process-app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<string name="title_actions">Acties</string>
<string name="accessibility_process_actions">Knop Procesacties</string>
<string name="no_attachments">Geen bijlagen</string>
<string name="error_process_failure">Er is iets fout gegaan. Neem contact op met uw beheerder voor hulp.</string>
</resources>
4 changes: 3 additions & 1 deletion process-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
<string name="no_attached_folder">No Folder Attached</string>
<string name="text_attached_folder">%d folder(s)</string>
<string name="action_info">Info</string>
<string name="file_empty_message">Looks like you haven’t\nadded any files yet.</string>
<string name="file_empty_message">Looks like you haven’t\nadded any files yet\n(Max file size: %d MB).</string>
<string name="title_search_folder">Search Folder</string>
<string name="error_hyperlink_invalid_url">%1$s has Invalid URL</string>
<string name="error_no_upload_fields">Not able to attach the selected content in this form.</string>
<string name="process_max_file_size">Please note: Maximum file size for uploads is %d MB.</string>
<string name="error_process_failure">Something went wrong. Contact your administrator for help.</string>
</resources>
Loading