-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor): UX Improvements to RBAC feature set (#9683)
- Loading branch information
Showing
32 changed files
with
335 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/N8nMenuItem/__tests__/labelUtil.spec.ts → ...design-system/src/utils/labelUtil.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 85 additions & 18 deletions
103
packages/editor-ui/src/components/Projects/ProjectCardBadge.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,119 @@ | ||
<script lang="ts" setup> | ||
import { computed } from 'vue'; | ||
import { useI18n } from '@/composables/useI18n'; | ||
import type { ResourceType } from '@/utils/projects.utils'; | ||
import { splitName } from '@/utils/projects.utils'; | ||
import type { ICredentialsResponse, IWorkflowDb } from '@/Interface'; | ||
import type { Project } from '@/types/projects.types'; | ||
import { ProjectTypes } from '@/types/projects.types'; | ||
type Props = { | ||
resource: IWorkflowDb | ICredentialsResponse; | ||
resourceType: ResourceType; | ||
resourceTypeLabel: string; | ||
personalProject: Project | null; | ||
}; | ||
const enum ProjectState { | ||
SharedPersonal = 'shared-personal', | ||
SharedOwned = 'shared-owned', | ||
Owned = 'owned', | ||
Personal = 'personal', | ||
Team = 'team', | ||
Unknown = 'unknown', | ||
} | ||
const props = defineProps<Props>(); | ||
const locale = useI18n(); | ||
const i18n = useI18n(); | ||
const badgeText = computed(() => { | ||
const projectState = computed(() => { | ||
if ( | ||
(props.resource.homeProject && | ||
props.personalProject && | ||
props.resource.homeProject.id === props.personalProject.id) || | ||
!props.resource.homeProject | ||
) { | ||
return locale.baseText('generic.ownedByMe'); | ||
} else { | ||
const { firstName, lastName, email } = splitName(props.resource.homeProject?.name ?? ''); | ||
return !firstName ? email : `${firstName}${lastName ? ' ' + lastName : ''}`; | ||
if (props.resource.sharedWithProjects?.length) { | ||
return ProjectState.SharedOwned; | ||
} | ||
return ProjectState.Owned; | ||
} else if (props.resource.homeProject?.type !== ProjectTypes.Team) { | ||
if (props.resource.sharedWithProjects?.length) { | ||
return ProjectState.SharedPersonal; | ||
} | ||
return ProjectState.Personal; | ||
} else if (props.resource.homeProject?.type === ProjectTypes.Team) { | ||
return ProjectState.Team; | ||
} | ||
return ProjectState.Unknown; | ||
}); | ||
const badgeIcon = computed(() => { | ||
const badgeText = computed(() => { | ||
if ( | ||
props.resource.sharedWithProjects?.length && | ||
props.resource.homeProject?.type !== ProjectTypes.Team | ||
projectState.value === ProjectState.Owned || | ||
projectState.value === ProjectState.SharedOwned | ||
) { | ||
return 'user-friends'; | ||
} else if (props.resource.homeProject?.type === ProjectTypes.Team) { | ||
return 'archive'; | ||
return i18n.baseText('generic.ownedByMe'); | ||
} else { | ||
return ''; | ||
const { firstName, lastName, email } = splitName(props.resource.homeProject?.name ?? ''); | ||
return (!firstName ? email : `${firstName}${lastName ? ' ' + lastName : ''}`) ?? ''; | ||
} | ||
}); | ||
const badgeIcon = computed(() => { | ||
switch (projectState.value) { | ||
case ProjectState.SharedPersonal: | ||
case ProjectState.SharedOwned: | ||
return 'user-friends'; | ||
case ProjectState.Team: | ||
return 'archive'; | ||
default: | ||
return ''; | ||
} | ||
}); | ||
const badgeTooltip = computed(() => { | ||
switch (projectState.value) { | ||
case ProjectState.SharedOwned: | ||
return i18n.baseText('projects.badge.tooltip.sharedOwned', { | ||
interpolate: { | ||
resourceTypeLabel: props.resourceTypeLabel, | ||
}, | ||
}); | ||
case ProjectState.SharedPersonal: | ||
return i18n.baseText('projects.badge.tooltip.sharedPersonal', { | ||
interpolate: { | ||
resourceTypeLabel: props.resourceTypeLabel, | ||
name: badgeText.value, | ||
}, | ||
}); | ||
case ProjectState.Personal: | ||
return i18n.baseText('projects.badge.tooltip.personal', { | ||
interpolate: { | ||
resourceTypeLabel: props.resourceTypeLabel, | ||
name: badgeText.value, | ||
}, | ||
}); | ||
case ProjectState.Team: | ||
return i18n.baseText('projects.badge.tooltip.team', { | ||
interpolate: { | ||
resourceTypeLabel: props.resourceTypeLabel, | ||
name: badgeText.value, | ||
}, | ||
}); | ||
default: | ||
return ''; | ||
} | ||
}); | ||
</script> | ||
<template> | ||
<n8n-badge v-if="badgeText" class="mr-xs" theme="tertiary" bold data-test-id="card-badge"> | ||
{{ badgeText }} | ||
<n8n-icon v-if="badgeIcon" :icon="badgeIcon" size="small" class="ml-5xs" /> | ||
</n8n-badge> | ||
<N8nTooltip :disabled="!badgeTooltip" placement="top"> | ||
<N8nBadge v-if="badgeText" class="mr-xs" theme="tertiary" bold data-test-id="card-badge"> | ||
{{ badgeText }} | ||
<N8nIcon v-if="badgeIcon" :icon="badgeIcon" size="small" class="ml-5xs" /> | ||
</N8nBadge> | ||
<template #content> | ||
{{ badgeTooltip }} | ||
</template> | ||
</N8nTooltip> | ||
</template> | ||
|
||
<style lang="scss" module></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.