Skip to content

Commit

Permalink
Make blocks stale-able and fix emotion warning (#2333)
Browse files Browse the repository at this point in the history
  • Loading branch information
karriebear committed Nov 11, 2020
1 parent b7ccd70 commit fd6d99e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
7 changes: 4 additions & 3 deletions frontend/src/components/core/Block/Block.tsx
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
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
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
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

0 comments on commit fd6d99e

Please sign in to comment.