refactor(editor): Turn showMessage mixin to composable (#6081)
* refactor(editor): move $getExecutionError from showMessages mixin to pushConnection (it is used there only) * refactor(editor): resolve showMessage mixin methods * fix(editor): use composable instead of mixin * fix(editor): resolve conflicts * fix(editor): replace clearAllStickyNotifications * fix(editor): replace confirmMessage * fix(editor): replace confirmMessage * fix(editor): replace confirmMessage * fix(editor): remove last confirmMessage usage * fix(editor): remove $prompt usage * fix(editor): remove $show methods * fix(editor): lint fix * fix(editor): lint fix * fix(editor): fixes after review
This commit is contained in:
@@ -143,8 +143,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { convertToDisplayDate } from '@/utils';
|
||||
import { showMessage } from '@/mixins/showMessage';
|
||||
import { useToast, useMessage } from '@/composables';
|
||||
import type {
|
||||
ILdapConfig,
|
||||
ILdapSyncData,
|
||||
@@ -153,7 +154,7 @@ import type {
|
||||
IFormInputs,
|
||||
IUser,
|
||||
} from '@/Interface';
|
||||
import mixins from 'vue-typed-mixins';
|
||||
import { MODAL_CONFIRM } from '@/constants';
|
||||
|
||||
import humanizeDuration from 'humanize-duration';
|
||||
import type { rowCallbackParams, cellCallbackParams } from 'element-ui/types/table';
|
||||
@@ -180,11 +181,17 @@ type rowType = rowCallbackParams & tableRow;
|
||||
|
||||
type cellType = cellCallbackParams & { property: keyof tableRow };
|
||||
|
||||
export default mixins(showMessage).extend({
|
||||
export default defineComponent({
|
||||
name: 'SettingsLdapView',
|
||||
components: {
|
||||
InfiniteLoading,
|
||||
},
|
||||
setup() {
|
||||
return {
|
||||
...useToast(),
|
||||
...useMessage(),
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dataTable: [] as ILdapSyncTable[],
|
||||
@@ -301,13 +308,20 @@ export default mixins(showMessage).extend({
|
||||
|
||||
try {
|
||||
if (this.adConfig.loginEnabled === true && newConfiguration.loginEnabled === false) {
|
||||
saveForm = await this.confirmMessage(
|
||||
const confirmAction = await this.confirm(
|
||||
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.message'),
|
||||
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.headline'),
|
||||
null,
|
||||
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.cancelButtonText'),
|
||||
this.$locale.baseText('settings.ldap.confirmMessage.beforeSaveForm.confirmButtonText'),
|
||||
{
|
||||
cancelButtonText: this.$locale.baseText(
|
||||
'settings.ldap.confirmMessage.beforeSaveForm.cancelButtonText',
|
||||
),
|
||||
confirmButtonText: this.$locale.baseText(
|
||||
'settings.ldap.confirmMessage.beforeSaveForm.confirmButtonText',
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
saveForm = confirmAction === MODAL_CONFIRM;
|
||||
}
|
||||
|
||||
if (!saveForm) {
|
||||
@@ -315,13 +329,13 @@ export default mixins(showMessage).extend({
|
||||
}
|
||||
|
||||
this.adConfig = await this.settingsStore.updateLdapConfig(newConfiguration);
|
||||
this.$showToast({
|
||||
this.showToast({
|
||||
title: this.$locale.baseText('settings.ldap.updateConfiguration'),
|
||||
message: '',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
this.$showError(error, this.$locale.baseText('settings.ldap.configurationError'));
|
||||
this.showError(error, this.$locale.baseText('settings.ldap.configurationError'));
|
||||
} finally {
|
||||
if (saveForm) {
|
||||
this.hasAnyChanges = false;
|
||||
@@ -335,13 +349,13 @@ export default mixins(showMessage).extend({
|
||||
this.loadingTestConnection = true;
|
||||
try {
|
||||
await this.settingsStore.testLdapConnection();
|
||||
this.$showToast({
|
||||
this.showToast({
|
||||
title: this.$locale.baseText('settings.ldap.connectionTest'),
|
||||
message: this.$locale.baseText('settings.ldap.toast.connection.success'),
|
||||
type: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
this.$showToast({
|
||||
this.showToast({
|
||||
title: this.$locale.baseText('settings.ldap.connectionTestError'),
|
||||
message: error.message,
|
||||
type: 'error',
|
||||
@@ -354,13 +368,13 @@ export default mixins(showMessage).extend({
|
||||
this.loadingDryRun = true;
|
||||
try {
|
||||
await this.settingsStore.runLdapSync({ type: 'dry' });
|
||||
this.$showToast({
|
||||
this.showToast({
|
||||
title: this.$locale.baseText('settings.ldap.runSync.title'),
|
||||
message: this.$locale.baseText('settings.ldap.toast.sync.success'),
|
||||
type: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
} finally {
|
||||
this.loadingDryRun = false;
|
||||
await this.reloadLdapSynchronizations();
|
||||
@@ -370,13 +384,13 @@ export default mixins(showMessage).extend({
|
||||
this.loadingLiveRun = true;
|
||||
try {
|
||||
await this.settingsStore.runLdapSync({ type: 'live' });
|
||||
this.$showToast({
|
||||
this.showToast({
|
||||
title: this.$locale.baseText('settings.ldap.runSync.title'),
|
||||
message: this.$locale.baseText('settings.ldap.toast.sync.success'),
|
||||
type: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
} finally {
|
||||
this.loadingLiveRun = false;
|
||||
await this.reloadLdapSynchronizations();
|
||||
@@ -669,7 +683,7 @@ export default mixins(showMessage).extend({
|
||||
},
|
||||
];
|
||||
} catch (error) {
|
||||
this.$showError(error, this.$locale.baseText('settings.ldap.configurationError'));
|
||||
this.showError(error, this.$locale.baseText('settings.ldap.configurationError'));
|
||||
}
|
||||
},
|
||||
async getLdapSynchronizations(state: any) {
|
||||
@@ -688,7 +702,7 @@ export default mixins(showMessage).extend({
|
||||
}
|
||||
this.loadingTable = false;
|
||||
} catch (error) {
|
||||
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
}
|
||||
},
|
||||
async reloadLdapSynchronizations() {
|
||||
@@ -697,7 +711,7 @@ export default mixins(showMessage).extend({
|
||||
this.tableKey += 1;
|
||||
this.dataTable = [];
|
||||
} catch (error) {
|
||||
this.$showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
this.showError(error, this.$locale.baseText('settings.ldap.synchronizationError'));
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user