Skip to content

Commit 6731432

Browse files
committed
Better visualization of for-term attributes.
1 parent 940f99f commit 6731432

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

src/components/Groups/GroupsTreeView/GroupsTreeNode.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ import Button from '../../widgets/TheButton';
88
import Confirm from '../../widgets/Confirm';
99
import GroupsTreeList from './GroupsTreeList.js';
1010
import GroupMembershipIcon from '../GroupMembershipIcon';
11-
import Icon, { AddIcon, CloseIcon, GroupIcon, LectureIcon, LoadingIcon, TermIcon, WarningIcon } from '../../icons';
11+
import Icon, {
12+
AddIcon,
13+
CloseIcon,
14+
GroupIcon,
15+
LectureIcon,
16+
LoadingIcon,
17+
PlantIcon,
18+
TermIcon,
19+
WarningIcon,
20+
} from '../../icons';
1221
import { EMPTY_OBJ } from '../../../helpers/common.js';
1322

1423
const DEFAULT_ICON = ['far', 'square'];
@@ -34,16 +43,29 @@ const getLocalizedName = (name, id, locale) => {
3443

3544
const KNOWN_ATTR_KEYS = {
3645
course: 'primary',
46+
'for-term': 'success',
3747
term: 'info',
3848
group: 'warning',
3949
};
4050

4151
const ATTR_ICONS = {
4252
course: <LectureIcon gapRight />,
53+
'for-term': <PlantIcon gapRight />,
4354
term: <TermIcon gapRight />,
4455
group: <GroupIcon gapRight />,
4556
};
4657

58+
const ATTR_TRANSFORM = {
59+
'for-term': value =>
60+
value === '1' ? (
61+
<FormattedMessage id="app.terms.winter" defaultMessage="Winter" />
62+
) : value === '2' ? (
63+
<FormattedMessage id="app.terms.summer" defaultMessage="Summer" />
64+
) : (
65+
value
66+
),
67+
};
68+
4769
const GroupsTreeNode = React.memo(
4870
({
4971
group,
@@ -195,7 +217,7 @@ const GroupsTreeNode = React.memo(
195217
className={'ms-1' + (pending ? ' opacity-25' : '')}>
196218
{ATTR_ICONS[key]}
197219
{!KNOWN_ATTR_KEYS[key] && `${key}: `}
198-
{value}
220+
{ATTR_TRANSFORM[key] ? ATTR_TRANSFORM[key](value) : value}
199221

200222
{removeAttribute && !pending && (
201223
<Confirm

src/components/icons/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const PersonalDataIcon = props => <Icon {...props} icon="id-card" />;
8888
export const PipelineIcon = props => <Icon {...props} icon="random" />;
8989
export const PipelineStructureIcon = props => <Icon {...props} icon="sitemap" />;
9090
export const PlagiarismIcon = props => <Icon icon="person-circle-exclamation" {...props} />;
91+
export const PlantIcon = props => <Icon icon="leaf" {...props} />;
9192
export const PointsIcon = props => <Icon icon="comment-dollar" {...props} />;
9293
export const PointsDecreasedIcon = props => <Icon icon="level-down-alt" className="text-body-secondary" {...props} />;
9394
export const PointsGraphIcon = props => <Icon icon={['far', 'chart-bar']} {...props} />;

src/pages/GroupsSuperadmin/GroupsSuperadmin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import AddAttributeForm, { INITIAL_VALUES as ADD_FORM_INITIAL_VALUES } from '../
1515
import PlantTermGroupsForm, {
1616
initialValuesCreator as plantFormInitialValuesCreator,
1717
} from '../../components/forms/PlantTermGroupsForm';
18-
import Icon, { CloseIcon, GroupIcon, LoadingIcon, ManagementIcon } from '../../components/icons';
18+
import Icon, { CloseIcon, GroupIcon, LoadingIcon, ManagementIcon, PlantIcon } from '../../components/icons';
1919
import ResourceRenderer from '../../components/helpers/ResourceRenderer';
2020
import Button, { TheButtonGroup } from '../../components/widgets/TheButton';
2121
import Callout from '../../components/widgets/Callout';
@@ -291,7 +291,7 @@ class GroupsSuperadmin extends Component {
291291
size="sm"
292292
onClick={() => this.plantGroups(this.state.plantTerm || terms[0])}
293293
disabled={this.state.plantGroupsCount === 0 || this.state.plantGroupsPending}>
294-
{this.state.plantGroupsPending ? <LoadingIcon gapRight /> : <Icon icon="leaf" gapRight />}
294+
{this.state.plantGroupsPending ? <LoadingIcon gapRight /> : <PlantIcon gapRight />}
295295
<FormattedMessage
296296
id="app.groupsSupervisor.plantTermGroupsConfirmButton"
297297
defaultMessage="Plant Term Groups"
@@ -356,7 +356,7 @@ class GroupsSuperadmin extends Component {
356356
<Button
357357
variant="success"
358358
onClick={() => this.openModalPlant(groups, this.state.plantTerm || terms[0])}>
359-
<Icon icon="leaf" gapRight />
359+
<PlantIcon gapRight />
360360
<FormattedMessage
361361
id="app.groupsSupervisor.plantTermButton"
362362
defaultMessage="Plant groups for"
@@ -380,7 +380,7 @@ class GroupsSuperadmin extends Component {
380380
variant={this.state.plantGroupsErrors ? 'danger' : 'success'}
381381
onClick={() => this.plantGroups(this.state.plantTerm || terms[0])}
382382
disabled={this.state.plantGroupsCount === 0 || this.state.plantGroupsPending}>
383-
{this.state.plantGroupsPending ? <LoadingIcon gapRight /> : <Icon icon="leaf" gapRight />}
383+
{this.state.plantGroupsPending ? <LoadingIcon gapRight /> : <PlantIcon gapRight />}
384384
<FormattedMessage
385385
id="app.groupsSupervisor.plantTermGroupsConfirmButton"
386386
defaultMessage="Plant Term Groups"

0 commit comments

Comments
 (0)