Merge branch '2023.9.x-fix-dedup' into 2023.9.x
This commit is contained in:
@@ -1,36 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-form-group label-class="d-flex align-items-center text-primary p-0">
|
||||
<template #label>
|
||||
{{ $t('enabled') }}
|
||||
<c-hint
|
||||
:tooltip="$t('tooltip.performance')"
|
||||
icon-class="text-warning"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<c-input-checkbox
|
||||
v-model="isEnabled"
|
||||
switch
|
||||
:labels="checkboxLabel"
|
||||
data-test-id="checkbox-enabled"
|
||||
<h5 class="d-flex align-items-center mb-3">
|
||||
{{ $t('duplicationDetection') }}
|
||||
<c-hint
|
||||
:tooltip="$t('tooltip.performance')"
|
||||
icon-class="text-warning"
|
||||
/>
|
||||
</b-form-group>
|
||||
</h5>
|
||||
|
||||
<div
|
||||
v-for="(rule, index) in rules"
|
||||
:key="index"
|
||||
>
|
||||
<hr>
|
||||
|
||||
<h5 class="d-flex align-items-center">
|
||||
<label class="d-flex align-items-center text-primary">
|
||||
{{ $t('uniqueValueConstraint', { index: index + 1 }) }}
|
||||
<c-input-confirm
|
||||
show-icon
|
||||
class="ml-2"
|
||||
@confirmed="rules.splice(index, 1)"
|
||||
/>
|
||||
</h5>
|
||||
</label>
|
||||
|
||||
<div class="d-flex align-items-center justify-content-between flex-wrap w-100">
|
||||
<b-form-group>
|
||||
@@ -132,14 +121,14 @@
|
||||
</tbody>
|
||||
</b-table-simple>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="d-flex justify-content-end">
|
||||
<div class="d-flex">
|
||||
<b-button
|
||||
variant="outline-light"
|
||||
class="d-flex align-items-center border-0 text-primary"
|
||||
class="d-flex align-items-center border-0 text-primary ml-auto"
|
||||
@click="addNewConstraint"
|
||||
>
|
||||
<font-awesome-icon
|
||||
|
||||
@@ -58,7 +58,6 @@ interface Config {
|
||||
};
|
||||
|
||||
recordDeDup: {
|
||||
enabled: boolean;
|
||||
rules: RecordDeDupRule[];
|
||||
};
|
||||
}
|
||||
@@ -175,7 +174,6 @@ export class Module {
|
||||
},
|
||||
|
||||
recordDeDup: {
|
||||
enabled: false,
|
||||
rules: [],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ edit:
|
||||
|
||||
uniqueValues:
|
||||
title: Unique values
|
||||
enabled: Enable duplication detection
|
||||
duplicationDetection: Duplication detection
|
||||
preventRecordsSave: Prevent record saving if duplicate values are found
|
||||
warningLabel: Warning or error message toast when constraint matches
|
||||
valueModifiers: Value modifiers
|
||||
|
||||
@@ -2025,11 +2025,7 @@ func (svc record) DupDetection(ctx context.Context, m *types.Module, rec *types.
|
||||
config = m.Config.RecordDeDup
|
||||
)
|
||||
|
||||
if !config.Enabled {
|
||||
return
|
||||
}
|
||||
|
||||
if len(config.Rules) > 0 {
|
||||
if len(config.Rules) > 0 && config.Rules.Validate() == nil {
|
||||
records, _, err = svc.Find(ctx, types.RecordFilter{
|
||||
ModuleID: m.ID,
|
||||
NamespaceID: m.NamespaceID,
|
||||
|
||||
@@ -90,8 +90,6 @@ type (
|
||||
}
|
||||
|
||||
ModuleConfigRecordDeDup struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// strictly restrict record saving
|
||||
// otherwise show a warning with list of duplicated records
|
||||
Strict bool `json:"-"`
|
||||
|
||||
@@ -15,12 +15,14 @@ func invalidateDedupRules(ctx context.Context, log *zap.Logger, s store.Storer)
|
||||
return
|
||||
}
|
||||
|
||||
// find only the invalid ones and empty the rules, leave the valid ones
|
||||
// as they were
|
||||
ll, _ = ll.Filter(func(m *types.Module) (bool, error) {
|
||||
return m.Config.RecordDeDup.Rules.Validate() != nil, nil
|
||||
})
|
||||
|
||||
ll.Walk(func(m *types.Module) error {
|
||||
m.Config.RecordDeDup.Enabled = false
|
||||
m.Config.RecordDeDup.Rules = types.DeDupRuleSet{}
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user