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

Refactor header using GravityUI #566

Merged
merged 3 commits into from
Jul 12, 2024
Merged

Refactor header using GravityUI #566

merged 3 commits into from
Jul 12, 2024

Conversation

Kabir-Ivan
Copy link
Contributor

@Kabir-Ivan Kabir-Ivan commented Jul 5, 2024

Screenshot 2024-07-09 at 14 46 24

@Kabir-Ivan Kabir-Ivan force-pushed the use-gravity-ui branch 2 times, most recently from 620327d to 80bb4e6 Compare July 8, 2024 07:50
Copy link
Member

@KuznetsovRoman KuznetsovRoman left a comment

Choose a reason for hiding this comment

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

I would also like to see the screenshots (of that browser list especially)

Copy link
Member

Choose a reason for hiding this comment

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

Why did the menu went in the left?
It should stay at the right

await browser.$('button*=Expand all').click();
await browser.$('//*[contains(@class, "expand-dropdown")]//button').click();
await browser.$('//*[contains(@class, "g-popup")]//span[contains(normalize-space(), "Expand all")]').click();
// await browser.$('//label[contains(normalize-space(), "Expand all")]').click();
Copy link
Member

Choose a reason for hiding this comment

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

Commented code should be removed

}
versions.forEach((version) => {
hasSpecialGroup = true;
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to assign true to hasSpecialGroup in every iteration of this forEach loop

const getOptions = () => {
const groups = {};
const DEFAULT_GROUP = "other";
let hasSpecialGroup = false;
Copy link
Member

Choose a reason for hiding this comment

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

From its name, it is unobvious, what makes the group "special"
Variable name should be more self-explanatory. For example: "hasNestedOptions", or "hasMultipleVersions", etc...


if (!isEmpty(versions) && versions.length > 1) {
node.children = versions.map(version => mkNode({browserId, version}));
const rawOptions = useMemo(getOptions, [available]);
Copy link
Member

Choose a reason for hiding this comment

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

Double "space" between "=" and "useMemo" here and at line#96
Interesting, how didn't eslint notice that.

Copy link
Member

Choose a reason for hiding this comment

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

Let's write new files in typescript: ".tsx"

@@ -46,6 +47,18 @@ const RunButton = ({actions, autoRun, isDisabled, isRunning, failedTests, checke
action();
};

const handleSelect = (values) => {
if (values.length) {
Copy link
Member

Choose a reason for hiding this comment

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

How could there be multiple values?

Comment on lines 39 to 45
// const additionalInfo = fetchDbDetails.map(({url, status, success}) => (
// <Menu.Item key={url}>
// {' '}
// {url} responded with
// <span className={success ? 'db-info__row_success' : 'db-info__row_fail'}>{' ' + status}</span>
// </Menu.Item>
// ));
Copy link
Member

Choose a reason for hiding this comment

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

Commented code should be removed

Comment on lines +49 to 48
<Popover
disablePortal
placement={'bottom'}
content={
additionalInfo
}
>
Copy link
Member

Choose a reason for hiding this comment

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

Strange formatting.
Have you launched npm run lint -- --fix?

@@ -34,19 +35,15 @@
display: inline;
}

.db-info__popup {
.db-info-container {
--g-popover-max-width: 5000px;
Copy link
Member

Choose a reason for hiding this comment

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

Why 5000px?

Comment on lines 21 to 23
.browserlist__row:hover
.action-button
opacity 1
Copy link
Member

Choose a reason for hiding this comment

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

It should be:

.g-select-list__option:hover
    .browserlist__row
        .action-button
            opacity 1

That way the "Only"/"Except" button will be shown while hovering the entire line, including the check mark.
Currently "Only"/"Except" is not shown while hovering the check mark

Copy link
Member

@KuznetsovRoman KuznetsovRoman left a comment

Choose a reason for hiding this comment

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

/ok

fix: fix copy button

feat: use gravity ui in header

refactor: refactor header using gravityUI

test: fix tests

refactor: use gravity ui in menu bar

test: debug

test: add retries

refactor: refactor code
@Kabir-Ivan Kabir-Ivan merged commit e68d6be into master Jul 12, 2024
4 checks passed
if (!hasNestedOptions) {
return groups[DEFAULT_GROUP];
}
else {
Copy link
Member

Choose a reason for hiding this comment

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

A few remarks about code style:

  • There are almost no blank lines at all. It makes code harder to read. Look at how the code was structured before — we usually divide code into sections (grouped by meaning) with blank lines between them. For instance, it's almost always a good idea to insert a blank line before return statement (unless it's the only statement in the code block e.g. if (...) { return ...; }
  • We usually write else clauses like this } else {. But here we don't need else clause altogether — it just introduces unnecessary level of nesting.

label: name,
options: groups[name]
})
})
Copy link
Member

Choose a reason for hiding this comment

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

Here, there's no semicolon. And this is not the only place. Don't we have a linter rule turned on for that? Can you please check? eslint should issue warnings/errors for missing semicolons.

});
return mapping;
}
const getSelected = () => {
Copy link
Member

Choose a reason for hiding this comment

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

This is not a descriptive&clear name either. By reading getSelected I don't understand at all what this function will return — will it return a single selected string? Or a selected element? Or will it return an array of them?

I suggest something like getSelectedBrowserIds. Feel free to choose the other name, but it should be clear what function does just by looking at its name.

});
import { Button, Select, useSelectOptions } from '@gravity-ui/uikit';

const BrowserList = ({available, onChange, selected: selectedProp}) => {
Copy link
Member

Choose a reason for hiding this comment

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

I see that selectedProp was here before, but I think it's bad naming too — it doesn't reflect what the variable holds at all. Let's name it something like selectedBrowsersProp, or you can try to come up with a better name.

and maybe available -> availableBrowsersProp too. This would indicate that these props store values of similar shape.

if (isEmpty(available)) {
return (<div></div>);
return (
<div className='browserlist__row'>
Copy link
Member

Choose a reason for hiding this comment

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

Right now when you click on only/except the width of the popup changes, but it shouldn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants