Files
n8n-enterprise-unlocked/packages/design-system/src/components/N8nUsersList/UsersList.vue
Mutasem Aldmour 577c73ee25 feat(editor): Add drag and drop data mapping (#3708)
* commit package lock

* refactor param options out

* use action toggle

* handle click on toggle

* update color toggle

* fix toggle

* show options

* update expression color

* update pointer

* fix readonly

* fix readonly

* fix expression spacing

* refactor input label

* show icon for headers

* center icon

* fix multi params

* add credential options

* increase spacing

* update expression view

* update transition

* update el padding

* rename side to options

* fix label overflow

* fix bug with unnessary lines

* add overlay

* fix bug affecting other pages

* clean up spacing

* rename

* update icon size

* fix toggle in users

* clean up func

* clean up css

* use css var

* fix overlay bug

* clean up input

* clean up input

* clean up unnessary css

* revert

* update quotes

* rename method

* remove console errors

* refactor data table

* add drag button

* make hoverable cells

* add drag hint

* disabel for output panel

* add drag

* disable for readonly

* Add dragging

* add draggable pill

* add mapping targets

* remove font color

* Transferable

* fix linting issue

* teleport component

* fix line

* disable for readonly

* fix position of data pill

* fix position of data pill

* ignore import

* add droppable state

* remove draggable key

* update bg color

* add value drop

* use direct input

* remove transition

* add animation

* shorten name

* handle empty value

* fix switch bug

* fix up animation

* add notification

* add hint

* add tooltip

* show draggable hintm

* fix multiple expre

* fix hoverable

* keep options on focus

* increase timeouts

* fix bug in set node

* add transition on hover out

* fix tooltip onboarding bug

* only update expression if changes

* add open delay

* fix header highlight issue

* update text

* dont show tooltip always

* update docs url

* update ee border

* add sticky behav

* hide error highlight if dropping

* switch out grip icon

* increase timeout

* add delay

* show hint on execprev

* add telemetry event

* add telemetry event

* add telemetry event

* fire event on hint showing

* fix telemetry event

* add path

* fix drag hint issue

* decrease bottom margin

* update mapping keys

* remove file

* hide overflow

* sort params

* add space

* prevent scrolling

* remove dropshadow

* force cursor

* address some comments

* add thead tbody

* add size opt
2022-07-20 13:32:51 +02:00

151 lines
2.9 KiB
Vue

<template>
<div>
<div
v-for="(user, i) in sortedUsers"
:key="user.id"
:class="i === sortedUsers.length - 1 ? $style.itemContainer : $style.itemWithBorder"
>
<n8n-user-info v-bind="user" :isCurrentUser="currentUserId === user.id" />
<div :class="$style.badgeContainer">
<n8n-badge v-if="user.isOwner" theme="secondary">{{ t('nds.auth.roles.owner') }}</n8n-badge>
<n8n-action-toggle
v-if="!user.isOwner"
placement="bottom"
:actions="getActions(user)"
theme="dark"
@action="(action) => onUserAction(user, action)"
/>
</div>
</div>
</div>
</template>
<script lang="ts">
import { IUser } from '../../types';
import Vue from 'vue';
import N8nActionToggle from '../N8nActionToggle';
import N8nBadge from '../N8nBadge';
import N8nIcon from '../N8nIcon';
import N8nLink from '../N8nLink';
import N8nText from '../N8nText';
import N8nUserInfo from '../N8nUserInfo';
import Locale from '../../mixins/locale';
import mixins from 'vue-typed-mixins';
export default mixins(Locale).extend({
name: 'n8n-users-list',
components: {
N8nActionToggle,
N8nBadge,
N8nUserInfo,
},
props: {
users: {
type: Array,
required: true,
default() {
return [];
},
},
currentUserId: {
type: String,
},
},
computed: {
sortedUsers(): IUser[] {
return [...(this.users as IUser[])].sort((a: IUser, b: IUser) => {
// invited users sorted by email
if (a.isPendingUser && b.isPendingUser) {
return a.email > b.email ? 1 : -1;
}
if (a.isPendingUser) {
return -1;
}
if (b.isPendingUser) {
return 1;
}
if (a.isOwner) {
return -1;
}
if (b.isOwner) {
return 1;
}
if (a.lastName && b.lastName && a.firstName && b.firstName) {
if (a.lastName !== b.lastName) {
return a.lastName > b.lastName ? 1 : -1;
}
if (a.firstName !== b.firstName) {
return a.firstName > b.firstName? 1 : -1;
}
}
return a.email > b.email ? 1 : -1;
});
},
},
methods: {
getActions(user: IUser) {
const DELETE = {
label: this.t('nds.usersList.deleteUser'),
value: 'delete',
};
const REINVITE = {
label: this.t('nds.usersList.reinviteUser'),
value: 'reinvite',
};
if (user.isOwner) {
return [];
}
if (user.firstName) {
return [
DELETE,
];
}
else {
return [
REINVITE,
DELETE,
];
}
},
onUserAction(user: IUser, action: string) {
if (action === 'delete' || action === 'reinvite') {
this.$emit(action, user.id);
}
},
},
});
</script>
<style lang="scss" module>
.itemContainer {
display: flex;
padding: var(--spacing-2xs) 0 vaR(--spacing-2xs) 0;
> *:first-child {
flex-grow: 1;
}
}
.itemWithBorder {
composes: itemContainer;
border-bottom: var(--border-base);
}
.badgeContainer {
display: flex;
align-items: center;
> * {
margin-left: var(--spacing-2xs);
}
}
</style>