Skip to content
6 changes: 6 additions & 0 deletions frontend/src/public/components/UI/Avatar/Avatar.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
border-radius: 50%;
align-items: center;
justify-content: center;
flex-shrink: 0;

&.is-group {
color: var(--pneumatic-color-black72);
}
}

img.avatar {
max-width: none;
object-fit: cover;
}

.avatar_xxl {
width: 80px;
height: 80px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,37 @@
}

.card-user {
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
margin-left: -4px;
display: flex;
width: 20px;
height: 20px;
flex-shrink: 0;

&:first-child {
margin-left: 0;
img {
width: 100%;
height: 100%;
vertical-align: unset;
border-radius: 50%;
object-fit: cover;
}
}

.card-users > .card-user:not(:first-child) {
margin-left: -4px;
}

.card-users button {
padding: 0;
width: 20px;
height: 20px;
cursor: pointer;
background: transparent;
border: none;
flex-shrink: 0;
}

.card-users > button:not(:first-child) {
margin-left: -4px;
}

.card-users__more {
margin-left: 8px;
font-size: 13px;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const AVATAR_SIZE = 20;
const AVATAR_OVERLAP = 4;

export const getPerformersAvatarsWidth = (performerCount: number): number => {
if (performerCount <= 0) {
return AVATAR_SIZE;
}

return AVATAR_SIZE + (performerCount - 1) * (AVATAR_SIZE - AVATAR_OVERLAP);
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
.comment-field__avatar-container {
margin-right: 16px;
align-self: flex-start;
flex-shrink: 0;

@media (--mobile) {
display: none;
Expand All @@ -29,6 +30,7 @@
width: 40px;
height: 40px;
border-radius: 50%;
object-fit: cover;

@media (--mobile) {
width: 32px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

&__avatar {
margin-right: 1.6rem;
flex-shrink: 0;

@media (--mobile) {
margin-right: 1rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.performer-column-width {
overflow: hidden;
max-width: 100%;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { getPerformersAvatarsWidth } from '../../../../../WorkflowCardUsers/utils/getPerformersAvatarsWidth';

const PERFORMER_COLUMN_DEFAULT_AVATARS = 5;

export const ETableViewFieldsWidth = {
'system-column-workflow': 376,
'system-column-templateName': 304,
'system-column-starter': 82,
'system-column-progress': 80,
'system-column-step': 304,
'system-column-performer': 80,
'system-column-performer': getPerformersAvatarsWidth(PERFORMER_COLUMN_DEFAULT_AVATARS),
number: 80,
text: 528,
string: 192,
Expand All @@ -23,7 +27,7 @@ export const EColumnWidthMinWidth = {
'system-column-starter': 82,
'system-column-progress': 80,
'system-column-step': 80,
'system-column-performer': 80,
'system-column-performer': getPerformersAvatarsWidth(PERFORMER_COLUMN_DEFAULT_AVATARS),
number: 80,
text: 80,
string: 80,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { useIsTableWiderThanScreen, useWorkflowsTableRef } from './WorkflowsTabl

import styles from './WorkflowsTable.css';
import { EColumnWidthMinWidth, ETableViewFieldsWidth } from './Columns/Cells/WorkflowTableConstants';
import { getPerformersAvatarsWidth } from '../../../WorkflowCardUsers/utils/getPerformersAvatarsWidth';
import { WorkflowsTableActions } from './WorkflowsTableActions';
import { useCheckDevice } from '../../../../hooks/useCheckDevice';
import { createResizeHandler } from './utils/resizeUtils';
Expand Down Expand Up @@ -224,6 +225,26 @@ export function WorkflowsTable({
workflowsList.items.length === 0 &&
String(lastLoadedTemplateIdForTable) === String(currentTemplateId));

const maxPerformersCount = useMemo(
() =>
workflowsList.items.reduce((max, workflow) => Math.max(max, workflow.selectedUsers?.length ?? 0), 0),
[workflowsList.items],
);

const performerColumnMinWidth = useMemo(
() => getPerformersAvatarsWidth(maxPerformersCount),
[maxPerformersCount],
);

const performerColumnWidth = useMemo(
() =>
Math.max(
savedGlobalWidths['system-column-performer'] || ETableViewFieldsWidth['system-column-performer'],
performerColumnMinWidth,
),
[performerColumnMinWidth, savedGlobalWidths],
);

const columns: Column<TableColumns>[] = useMemo(() => {
if (shouldSkeletonOptionalTable) {
return cashTableStructureRef.current;
Expand Down Expand Up @@ -313,8 +334,8 @@ export function WorkflowsTable({
),
accessor: 'system-column-performer',
Cell: ColumnCells.PerformerColumn,
width: savedGlobalWidths['system-column-performer'] || ETableViewFieldsWidth['system-column-performer'],
minWidth: EColumnWidthMinWidth['system-column-performer'],
width: performerColumnWidth,
Comment thread
cursor[bot] marked this conversation as resolved.
minWidth: performerColumnMinWidth,
columnType: 'system-column-performer',
},
]
Expand Down Expand Up @@ -350,6 +371,8 @@ export function WorkflowsTable({
workflowStartersCounters,
fieldsColumns.length,
selectedFieldsSet,
performerColumnWidth,
performerColumnMinWidth,
]);

const data = useMemo((): TableColumns[] => {
Expand Down Expand Up @@ -377,21 +400,30 @@ export function WorkflowsTable({
};

useEffect(() => {
if (workflowsLoadingStatus === EWorkflowsLoadingStatus.Loaded) {
setColWidths((prev) => {
const newWidths = { ...prev };

columns.forEach((col) => {
const id = col.accessor as string;
if (!newWidths[id]) {
newWidths[id] = col.width as number;
}
});

return newWidths;
});
if (
workflowsLoadingStatus !== EWorkflowsLoadingStatus.Loaded &&
workflowsLoadingStatus !== EWorkflowsLoadingStatus.LoadingNextPage
) {
return;
}
}, [columns.length, workflowsLoadingStatus]);

setColWidths((prev) => {
const newWidths = { ...prev };

columns.forEach((col) => {
const id = col.accessor as string;
const colWidth = col.width as number;

if (id === 'system-column-performer' && newWidths[id]) {
newWidths[id] = Math.max(newWidths[id], colWidth);
} else if (!newWidths[id]) {
newWidths[id] = colWidth;
}
});

return newWidths;
});
}, [columns, workflowsLoadingStatus, performerColumnWidth]);

const handleMouseDown = createResizeHandler(colWidths, setColWidths, currentUser?.id, templatesIdsFilter[0]);

Expand Down