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

chore(react-components): fixes related to recent changes in Cogs #4895

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"devDependencies": {
"@cognite/cdf-i18n-utils": "^0.7.5",
"@cognite/cdf-utilities": "^3.6.0",
"@cognite/cogs-lab": "^9.0.0-alpha.113",
"@cognite/cogs-lab": "^9.0.0-alpha.130",
"@cognite/cogs.js": "^10.25.0",
"@cognite/reveal": "^4.22.0",
"@cognite/sdk": "^9.13.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ const DropdownElement = ({
onOpenChange={(open: boolean) => {
setOpen(open);
}}
hideOnSelect={true}
appendTo={'parent'}
placement={'bottom-start'}
renderTrigger={(props: any) => (
<CogsTooltip
Expand Down Expand Up @@ -171,10 +169,9 @@ function createMenuItem(command: BaseCommand, t: TranslateDelegate): ReactElemen
return (
<Menu.ItemToggled
key={command.uniqueId}
icon={command.icon}
trailingContent={command.icon}
disabled={!command.isEnabled}
toggled={command.isChecked}
iconPlacement="left"
label={command.getLabel(t)}
onClick={() => {
command.invoke();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const FilterButton = ({
command={command}
isAllChecked={isAllChecked}
isSomeChecked={isSomeChecked}
label={label}
/>
);

Expand Down Expand Up @@ -181,7 +180,7 @@ const FilterDropdown = ({
return (
<StyledDropdownRow>
<label>{label}</label>
<StyledSelectPanel appendTo={'parent'} placement={'right-end'} hideOnOutsideClick>
<StyledSelectPanel appendTo={document.body} placement={'right-end'} hideOnOutsideClick>
<SelectPanel.Trigger>
<Button
color="#000044"
Expand Down Expand Up @@ -212,11 +211,9 @@ const FilterDropdown = ({
const FilterSelectPanelContent = ({
command,
isAllChecked,
isSomeChecked,
label
isSomeChecked
}: {
command: BaseFilterCommand;
label: string;
isAllChecked: boolean;
isSomeChecked: boolean;
}): ReactElement => {
Expand All @@ -239,7 +236,7 @@ const FilterSelectPanelContent = ({
{BaseFilterCommand.getAllString(t)}
</SelectPanel.Item>
</SelectPanel.Section>
<SelectPanel.Body label={label} style={{ maxHeight: '300px' }}>
<SelectPanel.Body style={{ maxHeight: '300px' }}>
<SelectPanel.Section>
{children?.map((child, _index): ReactElement => {
return <FilterItem key={child.uniqueId} command={child} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,19 @@ export const SettingsButton = ({
const children = command.children;
return (
<StyledMenu
hideOnSelect={false}
disableCloseOnClickInside
onOpenChange={(open: boolean) => {
for (const child of children) {
child.update();
}
setOpen(open);
}}
floatingProps={{ middleware: [offset(TOOLBAR_HORIZONTAL_PANEL_OFFSET)] }}
container={'parent'}
placement="right-end"
style={{
flexDirection,
padding: DEFAULT_PADDING
}}
disableCloseOnClickInside
renderTrigger={(props: any) => (
<CogsTooltip
content={<LabelWithShortcut label={label} command={command} />}
Expand Down Expand Up @@ -204,14 +202,12 @@ function createToggle(command: BaseCommand, t: TranslateDelegate): ReactNode {

function createButton(command: BaseCommand, t: TranslateDelegate): ReactNode {
// @update-ui-component-pattern
const [isChecked, setChecked] = useState(false);
const [isEnabled, setEnabled] = useState(true);
const [isVisible, setVisible] = useState(true);
const [uniqueId, setUniqueId] = useState(0);
const [icon, setIcon] = useState<IconName>(undefined);

useOnUpdate(command, () => {
setChecked(command.isChecked);
setEnabled(command.isEnabled);
setVisible(command.isVisible);
setUniqueId(command.uniqueId);
Expand All @@ -228,15 +224,12 @@ function createButton(command: BaseCommand, t: TranslateDelegate): ReactNode {
<Menu.ItemAction
key={uniqueId}
disabled={!isEnabled}
toggled={isChecked}
icon={<IconComponent iconName={icon} />}
iconPlacement="left"
style={{ padding: DEFAULT_PADDING }}
shortcutKeys={command.getShortCutKeys()}
label={label}
onClick={() => {
command.invoke();
setChecked(command.isChecked);
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ export const LayersButton = ({

return (
<>
<SelectPanel
placement="right"
appendTo={'parent'}
hideOnOutsideClick
offset={TOOLBAR_HORIZONTAL_PANEL_OFFSET}>
<SelectPanel placement="right" hideOnOutsideClick offset={TOOLBAR_HORIZONTAL_PANEL_OFFSET}>
<SelectPanel.Trigger>
<Tooltip
content={<LabelWithShortcut label={t({ key: 'LAYERS_FILTER_TOOLTIP' })} />}
Expand Down Expand Up @@ -105,11 +101,7 @@ const ModelLayerSelection = ({
}, [update]);

return (
<SelectPanel
placement="right"
appendTo={'parent'}
hideOnOutsideClick={true}
openOnHover={!isDisabled}>
<SelectPanel placement="right" hideOnOutsideClick={true} openOnHover={!isDisabled}>
<SelectPanel.Trigger>
<WholeLayerVisibilitySelectItem
label={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export const RuleBasedOutputsButton = ({
return (
<Menu
placement="right-start"
disabled={disabled}
style={{
maxHeight: 300,
overflow: 'auto',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const SettingsButton = ({
return (
<StyledMenu
placement="right"
container={'parent'}
floatingProps={{ middleware: [offset(TOOLBAR_HORIZONTAL_PANEL_OFFSET)] }}
disableCloseOnClickInside
renderTrigger={(props: any) => (
Expand Down
91 changes: 82 additions & 9 deletions react-components/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading