Geo Replicables - Share logic between FE and BE on whether Resync/Reverify is supported

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

What / Why

Follow up for this thread: #364727 (comment 1413247121)
Expanding from work item: #414023 (closed)
Blocked behind object storage verification: &8056 (closed)

The Geo Replicables UI has begun adding support for Resync and Reverify actions on SSF Replicables. However, these actions are not always supported depending on how Geo is configured.

We would like to disable the buttons on the UI when they are not supported and include a tooltip for the customer as to why the button is disabled.

To do this we need to create a Single Source of Truth (SSoT) between the Frontend and Backend to reference when/when not an action is supported

Conditions

@jtapiab provided a breakdown of the different conditions in this table

Resync

Data type Local storage Provider managed OS replication GitLab managed OS replication
Git(Repository) Yes N/A N/A
File(Blob) Yes No Yes
Container registry Yes Yes Yes

Reverify

Data type Local storage Provider managed OS replication GitLab managed OS replication
Git(Repository) Yes N/A N/A
File(Blob) Yes No Yes
Container registry Yes Yes Yes

Proposal

Create a shared method in Rails that both the Frontend and Backend can reference to determine if an action is supported for a particular data type under the current Geo configuration.

Implementation details

  1. Add method to check if a registry is syncable to the ReplicableRegistry
def syncable?
  self.persisted?
end
  1. Add method to check if a registry is verifiable to the VerifiableReplicator
def verifiable?
  primary_checksum.present? && checksummable?
end
  1. Expose the newly created methods on the Types::Geo::RegistryType for the GraphQL query
field :syncable, GraphQL::Types::Boolean, null: true, description: "Boolean denoting if this registry is syncable."
field :verifiable, GraphQL::Types::Boolean, null: true, description: "Boolean denoting if this registry is verifiable."
  1. Expose replication_enabled? to the frontend in the replicables/index.html.haml
"replication-enabled" => @replicator_class.replication_enabled?&.to_s,
  1. Expose these newly added values to the GraphQL query builder in the frontend
nodes {
  // ...
  syncable
  verifiable
}
  1. Extract the newly added replicationEnabled property in the geo_replicable/index.js
  const {
    // ...
    replicationEnabled,
    verificationEnabled,
    // ...
  } = el.dataset;
  1. Update the bulk actions to be disabled if their respective Booleans added above are false in geo_replicable_filter_bar.vue
<script>
  export default {
    computed: {
      replicationDisabledTooltip() {
        return this.replicationEnabled ? '' : this.$options.i18n.replicationDisabledTooltip;
      }
    }
  }
</script>

<template>
  <gl-button
    v-gl-modal-directive="$options.GEO_BULK_ACTION_MODAL_ID"
    v-gl-tooltip
    :title="replicationDisabledTooltip"
    :disabled="!replicationEnabled"
    data-testid="geo-resync-all"
    @click="setModalData($options.actionTypes.RESYNC_ALL)"
    >{{ $options.i18n.resyncAll }}</gl-button
  >
</template>
  1. Update the individual actions to be disabled if their respective Booleans added above are false in geo_replicable_item.vue
<script>
  export default {
    computed: {
      replicationDisabledTooltip() {
        return this.syncable ? '' : this.$options.i18n.replicationDisabledTooltip;
      }
    }
  }
</script>

<template>
  <gl-button
    v-gl-tooltip
    :title="replicationDisabledTooltip"
    :disabled="!syncable"
    data-testid="geo-resync-item"
    size="small"
    @click="
      initiateReplicableAction({ registryId, name, action: $options.actionTypes.RESYNC })
    "
  >
</template>

cc/ @sranasinghe

Edited by 🤖 GitLab Bot 🤖