Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [AXIMST-93, 99, 105, 518, 537] Group configuration - Experiment Groups #188

Merged
merged 4 commits into from
Feb 29, 2024

Conversation

ruzniaievdm
Copy link

@ruzniaievdm ruzniaievdm commented Feb 26, 2024

Add-Experiment-Groups
Delete-Experiment-Group
Edit-Experiment-Group
No-Internet-connection-alert-is-shown-with-incorrect-styles
sidebar-text-isnt-aligned-with-legacy

The main group configuration page

image

There were added actions to handle group configuration:

Create

image

Edit

image

Delete

image

@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/feat/experiment-configuration branch from 4ea5971 to a1500ed Compare February 26, 2024 17:49
@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/feat/experiment-configuration branch from a1500ed to a162c3b Compare February 26, 2024 17:55
@ruzniaievdm ruzniaievdm self-assigned this Feb 26, 2024
@ruzniaievdm ruzniaievdm marked this pull request as ready for review February 27, 2024 16:23
@ruzniaievdm ruzniaievdm changed the title feat: [AXIMST-93, 99, 105] Group configuration - Experiment Groups feat: [AXIMST-93, 99, 105, 518, 537] Group configuration - Experiment Groups Feb 27, 2024
Copy link

@PKulkoRaccoonGang PKulkoRaccoonGang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruzniaievdm The feature with percentage looks pretty cool!!!
I have a couple of suggestions:

  1. Should the font size of error text be the same?
Screenshot 2024-02-27 at 18 55 07
  1. In the current implementation, the user can create a group with an empty value (if you add spaces instead of text, the groups can be saved)
image

},
subtitleModalDelete: {
id: 'course-authoring.group-configurations.container.delete-modal.subtitle',
defaultMessage: 'content group',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] should be lowercase?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should it used like changing variable for sentence

}

/**
* Delete exists experimental configuration from the course.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Delete exists experimental configuration from the course.
* Delete existing experimental configuration from the course.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

* @param {object} configuration
* @returns {Promise<Object>}
*/
export async function createExperimentConfiguration(courseId, configuration) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] Do we delete configuration or group? In case if we delete a group it requires renaming to createExperimentGroup. For other functions the same question.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We remove exactly configuration.
There are types content group, experiment configuration with actions.
That's what I called such them

configuration: experimentConfigurationUpdated,
});

const cardTitle = getByTestId('configuration-card-header__button');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] I think this double underscore here is not needed. Let's refactor a bit.

Suggested change
const cardTitle = getByTestId('configuration-card-header__button');
const cardTitle = getByTestId('configuration-card-header-button');

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

{groups.map((item) => (
<div
className="configuration-card-content__experiment-stack"
data-testid="configuration-card-content__experiment-stack"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data-testid="configuration-card-content__experiment-stack"
data-testid="configuration-card-content-experiment-stack"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

values, errors, dirty, handleChange, handleSubmit,
}) => (
<>
<Form.Group className="mt-3 form-group-configuration" isInvalid={!!errors.name}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Form.Group className="mt-3 form-group-configuration" isInvalid={!!errors.name}>
<Form.Group className="mt-3 configuration-form-group" isInvalid={!!errors.name}>

To stick to the pattern above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed


return (
<Form.Group
key={idx}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key={idx}
key={group.name}

will it be unique or maybe group.id? If you change here you can remove eslint-disable on top of the file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const initialExperimentConfiguration = {
  name: '',
  description: '',
  groups: [
    { name: 'Group A', version: 1, usage: [] },
    { name: 'Group B', version: 1, usage: [] },
  ],
  scheme: 'random',
  parameters: {},
  usage: [],
  active: true,
  version: 1,
};

This component handle each group item, so we don't always have id field

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it is initial groups without preinstalled id value

Comment on lines 11 to 35
const getNextGroupName = (groups, groupFieldName = 'name') => {
const existingGroupNames = groups.map((group) => group.name);

let nextIndex = existingGroupNames.length + 1;

let groupName = '';
while (nextIndex > 0) {
groupName = ALPHABET_LETTERS[(nextIndex - 1) % 26] + groupName;
nextIndex = Math.floor((nextIndex - 1) / 26);
}

let counter = 0;
let newName = groupName;
while (existingGroupNames.includes(`Group ${newName}`)) {
counter++;
let newIndex = existingGroupNames.length + 1 + counter;
groupName = '';
while (newIndex > 0) {
groupName = ALPHABET_LETTERS[(newIndex - 1) % 26] + groupName;
newIndex = Math.floor((newIndex - 1) / 26);
}
newName = groupName;
}
return { [groupFieldName]: `Group ${newName}`, version: 1, usage: [] };
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const getNextGroupName = (groups, groupFieldName = 'name') => {
const existingGroupNames = groups.map((group) => group.name);
let nextIndex = existingGroupNames.length + 1;
let groupName = '';
while (nextIndex > 0) {
groupName = ALPHABET_LETTERS[(nextIndex - 1) % 26] + groupName;
nextIndex = Math.floor((nextIndex - 1) / 26);
}
let counter = 0;
let newName = groupName;
while (existingGroupNames.includes(`Group ${newName}`)) {
counter++;
let newIndex = existingGroupNames.length + 1 + counter;
groupName = '';
while (newIndex > 0) {
groupName = ALPHABET_LETTERS[(newIndex - 1) % 26] + groupName;
newIndex = Math.floor((newIndex - 1) / 26);
}
newName = groupName;
}
return { [groupFieldName]: `Group ${newName}`, version: 1, usage: [] };
};
const getNextGroupName = (groups, groupFieldName = 'name') => {
const existingGroupNames = new Set(groups.map((group) => group[groupFieldName]));
let baseName = 'A';
let counter = 1;
while (existingGroupNames.has(`Group ${baseName}${counter}`)) {
counter++;
if (counter > 26) {
baseName = String.fromCharCode(baseName.charCodeAt(0) + 1); // Increment base letter
counter = 1;
}
}
return { [groupFieldName]: `Group ${baseName}${counter}`, version: 1, usage: [] };
};

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add variables where you think is needed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what we need to have/
Your solution generates groups in the sequence [A1, A2, A3,..]

* @param {Array} groups - An array of group objects.
* @returns {boolean} True if all group names are unique, otherwise false.
*/
const allGroupNameAreUnique = (groups) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const allGroupNameAreUnique = (groups) => {
const allGroupNamesAreUnique = (groups) => {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

* @param {number} totalGroups - Total number of groups.
* @returns {string} The percentage of groups, each group has the same value.
*/
const getGroupPercentage = (totalGroups) => `${totalGroups === 0 ? 0 : Math.floor(100 / totalGroups)}%`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const getGroupPercentage = (totalGroups) => `${totalGroups === 0 ? 0 : Math.floor(100 / totalGroups)}%`;
const getGroupPercentage = (totalGroups) => totalGroups === 0 ? '0%' : `${Math.floor(100 / totalGroups)}%`;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@ruzniaievdm
Copy link
Author

@ruzniaievdm The feature with percentage looks pretty cool!!! I have a couple of suggestions:

  1. Should the font size of error text be the same?
Screenshot 2024-02-27 at 18 55 07 3. In the current implementation, the user can create a group with an empty value (if you add spaces instead of text, the groups can be saved) image

Good catch for both, thanks!

@@ -26,7 +26,7 @@
align-content: center;
justify-content: space-between;

.configuration-card-header__button {
.configuration-card-header-button {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously it was OK for class names. Only change for data-test-id is required to the word-word-word-word pattern. classNames should be with double underscores as you had previously.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for confusion

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted changed

@@ -10,8 +10,8 @@ const ExperimentCardGroup = ({ groups }) => {
<Stack className="mb-3">
{groups.map((item) => (
<div
className="configuration-card-content__experiment-stack"
data-testid="configuration-card-content__experiment-stack"
className="configuration-card-content-experiment-stack"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also configuration-card-content__experiment-stack

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 62.50000% with 90 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (ts-develop@68d7533). Click here to learn what that means.

Files Patch % Lines
src/group-configurations/data/thunk.js 0.00% 34 Missing ⚠️
src/group-configurations/hooks.jsx 11.76% 15 Missing ⚠️
src/group-configurations/data/slice.js 0.00% 13 Missing and 1 partial ⚠️
src/group-configurations/data/api.js 0.00% 9 Missing ⚠️
...periment-configurations-section/ExperimentCard.jsx 82.85% 5 Missing and 1 partial ⚠️
...ations/content-groups-section/ContentGroupCard.jsx 70.00% 3 Missing ⚠️
...up-configurations/content-groups-section/index.jsx 50.00% 2 Missing ⚠️
...periment-configurations-section/ExperimentForm.jsx 92.00% 2 Missing ⚠️
...nt-configurations-section/ExperimentFormGroups.jsx 88.88% 2 Missing ⚠️
...ations/experiment-configurations-section/index.jsx 83.33% 2 Missing ⚠️
... and 1 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@              Coverage Diff              @@
##             ts-develop     #188   +/-   ##
=============================================
  Coverage              ?   89.07%           
=============================================
  Files                 ?      680           
  Lines                 ?    11500           
  Branches              ?     2436           
=============================================
  Hits                  ?    10244           
  Misses                ?     1216           
  Partials              ?       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/feat/experiment-configuration branch from 740dc5e to 05362bb Compare February 29, 2024 11:40
@monteri monteri merged commit 819e60b into ts-develop Feb 29, 2024
3 checks passed
ihor-romaniuk pushed a commit that referenced this pull request Feb 29, 2024
… Groups (#188)

* feat: [AXIMST-93, 99, 105] Group configuration - Experiment Groups

* fix: [AXIMST-518, 537] Group configuration - resolve bugs

* fix: review discussions

* fix: revert classname case
ihor-romaniuk pushed a commit that referenced this pull request Feb 29, 2024
… Groups (#188)

* feat: [AXIMST-93, 99, 105] Group configuration - Experiment Groups

* fix: [AXIMST-518, 537] Group configuration - resolve bugs

* fix: review discussions

* fix: revert classname case
khudym pushed a commit that referenced this pull request Mar 25, 2024
… Groups (#188)

* feat: [AXIMST-93, 99, 105] Group configuration - Experiment Groups

* fix: [AXIMST-518, 537] Group configuration - resolve bugs

* fix: review discussions

* fix: revert classname case
monteri pushed a commit that referenced this pull request Apr 1, 2024
… Groups (#188)

* feat: [AXIMST-93, 99, 105] Group configuration - Experiment Groups

* fix: [AXIMST-518, 537] Group configuration - resolve bugs

* fix: review discussions

* fix: revert classname case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants