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

Make blocks stale-able and fix emotion warning #2333

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions frontend/src/components/core/Block/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ class Block extends PureComponent<Props> {
return true
}
if (this.props.reportRunState === ReportRunState.RUNNING) {
return (
node instanceof ElementNode && node.reportId !== this.props.reportId
)
return node.reportId !== this.props.reportId
}
return false
}
Expand All @@ -213,10 +211,13 @@ class Block extends PureComponent<Props> {
const BlockType = node.deltaBlock.expandable
? Block.WithExpandableBlock
: Block
const enable = this.shouldComponentBeEnabled(false)
const isStale = this.isComponentStale(enable, node)

const optionalProps = node.deltaBlock.expandable
? {
empty: node.isEmpty,
isStale,
...node.deltaBlock.expandable,
}
: {}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hocs/withExpandable/styled-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const StyledExpandableContainer = styled.div(({ theme }) => ({
paddingTop: theme.spacing.lg,

"&:before": {
content: "empty",
content: '"empty"',
},
},
},
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/hocs/withExpandable/withExpandable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,18 @@ describe("withExpandable HOC", () => {

expect(accordion.prop("expanded").length).toBe(0)
})

it("should become stale", () => {
const props = getProps({
isStale: true,
})
const WithHoc = withExpandable(testComponent)
// @ts-ignore
const wrapper = shallow(<WithHoc {...props} />)
const accordion = wrapper.find(StatelessAccordion)
const overrides = accordion.prop("overrides")

// @ts-ignore
expect(overrides.Header.props.className).toContain("stale-element")
})
})
8 changes: 7 additions & 1 deletion frontend/src/hocs/withExpandable/withExpandable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface Props {
expanded: boolean
empty: boolean
widgetsDisabled: boolean
isStale: boolean
}

function withExpandable(
Expand All @@ -39,6 +40,7 @@ function withExpandable(
expanded: initialExpanded,
empty,
widgetsDisabled,
isStale,
...componentProps
} = props

Expand Down Expand Up @@ -107,7 +109,11 @@ function withExpandable(
borderBottomColor: colors.primary,
},
}),
props: { className: "streamlit-expanderHeader" },
props: {
className: classNames("streamlit-expanderHeader", {
"stale-element": isStale,
}),
},
},
ToggleIcon: {
style: ({ $disabled }) => ({
Expand Down