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

[Research] OUI Compliance Audit of dev_tools plugin #4160

Open
sayuree opened this issue May 28, 2023 · 1 comment
Open

[Research] OUI Compliance Audit of dev_tools plugin #4160

sayuree opened this issue May 28, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request OSCI Open Source Contributor Initiative OUI compliance Issues and PRs to maximize OUI usage and remove style and component hacks OUI Issues that require migration to OUI

Comments

@sayuree
Copy link
Contributor

sayuree commented May 28, 2023

Audit of #4078

The dev_tools plugin has 1 Sass file: index.scss:

.devApp__container,
.devApp {
flex: 1 1 auto;
display: flex;
flex-direction: column;
> * {
flex-shrink: 0;
}
}
.devAppWrapper {
display: flex;
flex-direction: column;
flex-grow: 1;
}
.devAppDataSourcePicker {
margin: 7px 8px 0 0;
min-width: 400px;
}
.devAppTabs {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}

  1. The plugin does not contain img, span HTML tags, but uses main, div tags.

    <main className="devApp">
    <EuiTabs className="devAppTabs">
    {devTools.map((currentDevTool) => (
    <EuiToolTip content={currentDevTool.tooltipContent} key={currentDevTool.id}>
    <EuiTab
    disabled={currentDevTool.isDisabled()}
    isSelected={currentDevTool === activeDevTool}
    onClick={() => {
    if (!currentDevTool.isDisabled()) {
    updateRoute(`/${currentDevTool.id}`);
    }
    }}
    >
    {currentDevTool.title}
    </EuiTab>
    </EuiToolTip>
    ))}
    {dataSourceEnabled ? (
    <div className="devAppDataSourcePicker">
    <EuiComboBox
    aria-label={i18n.translate('devTool.devToolWrapper.DataSourceComboBoxAriaLabel', {
    defaultMessage: 'Select a Data Source',
    })}
    placeholder={i18n.translate('devTool.devToolWrapper.DataSourceComboBoxPlaceholder', {
    defaultMessage: 'Select a Data Source',
    })}
    singleSelection={{ asPlainText: true }}
    options={dataSources}
    selectedOptions={selectedOptions}
    onChange={onChange}
    prepend="DataSource"
    compressed
    isDisabled={!dataSourceEnabled}
    />
    </div>
    ) : null}
    </EuiTabs>
    <div
    className="devApp__container"
    role="tabpanel"
    data-test-subj={activeDevTool.id}
    ref={async (element) => {
    if (
    element &&
    (mountedTool.current === null ||
    mountedTool.current.devTool !== activeDevTool ||
    mountedTool.current.mountpoint !== element)
    ) {
    await remount(element);
    }
    }}
    />
    </main>

  2. The plugin has a component DevToolsWrapper, which mostly uses OUI library components and occasionally uses HTML tags for wrapping:

    function DevToolsWrapper({
    devTools,
    activeDevTool,
    updateRoute,
    savedObjects,
    notifications: { toasts },
    dataSourceEnabled,
    }: DevToolsWrapperProps) {

  • devApp__container, devApp classes are identical:
    .devApp__container,
    .devApp {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    > * {
    flex-shrink: 0;
    }
    }

    These could be replaced by adding some properties to EuiFlexGroup and EuiFlexItem, however, OUI doesn't allow editing flex-shrink or flex-basis on EuiFlexItem.
  • devAppWrapper can be easily replaced by EuiFlexGroup and EuiFlexItems using their corresponding properties like display, direction, grow:
    .devAppWrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    }
  • devAppTabs can also be replaced by EuiFlexGroup and EuiFlexItem. Although EuiFlexGroup does not have flex-flow property it can be replaced by using both direction and wrap properties, since

The flex-flow property is a shorthand property for the flex-direction and the flex-wrap properties.

.devAppTabs {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}

Conclusion

  1. Allow EuiFlexItem to modify flex-shrink and flex-basis;
  2. Replace devAppWrapper, devAppTabs with OUI library items;
@joshuarrrr
Copy link
Member

joshuarrrr commented May 31, 2023

Thanks @sayuree, this is a helpful start. I think the primary issue to address here is the fact that this plugin doesn't use https://oui.opensearch.org/1.0/#/layout/page for handling the page layout (the use of <main> is a really important hint/finding here). Note that, if we were using OuiPage* components for layout, the tab structure could easily be handled by https://oui.opensearch.org/1.0/#/layout/page-header#tabs-in-the-page-header (rather than the more generic EuiTabs), which would also mean there's no need for the spacing hacks of devAppDataSourcePicker.

@joshuarrrr joshuarrrr added OSCI Open Source Contributor Initiative OUI Issues that require migration to OUI OUI compliance Issues and PRs to maximize OUI usage and remove style and component hacks labels May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request OSCI Open Source Contributor Initiative OUI compliance Issues and PRs to maximize OUI usage and remove style and component hacks OUI Issues that require migration to OUI
Projects
Status: In Progress
Development

No branches or pull requests

3 participants