-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: factor out the readonly input used in Bulk Update and Bulk Del…
…ete modals COMPASS-7387 (#5048) * factor out the readonly input used in Bulk Update and Bulk Delete modals * update test id
- Loading branch information
Showing
5 changed files
with
78 additions
and
85 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
TextInput, | ||
InfoSprinkle, | ||
Label, | ||
css, | ||
spacing, | ||
fontFamilies, | ||
} from '@mongodb-js/compass-components'; | ||
|
||
type QueryLabelProps = { | ||
tooltip: string; | ||
label: string; | ||
}; | ||
|
||
const queryLabelStyles = css({ | ||
display: 'flex', | ||
gap: spacing[2], | ||
alignItems: 'center', | ||
height: '17px', // align with the Preview label | ||
}); | ||
|
||
const QueryLabel: React.FunctionComponent<QueryLabelProps> = ({ | ||
tooltip, | ||
label, | ||
}) => { | ||
return ( | ||
<div className={queryLabelStyles}> | ||
<Label htmlFor="readonly-filter">{label}</Label> | ||
<InfoSprinkle align="right">{tooltip}</InfoSprinkle> | ||
</div> | ||
); | ||
}; | ||
|
||
const textInputStyles = css({ | ||
input: { | ||
fontFamily: fontFamilies.code, | ||
}, | ||
}); | ||
|
||
type ReadonlyFilterProps = { | ||
queryLabel: string; | ||
filterQuery: string; | ||
}; | ||
|
||
export function ReadonlyFilter({ | ||
queryLabel, | ||
filterQuery, | ||
}: ReadonlyFilterProps) { | ||
return ( | ||
<TextInput | ||
id="readonly-filter" | ||
data-testid="readonly-filter" | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore the label can be any component, but it's weirdly typed to string | ||
label={ | ||
<QueryLabel | ||
label={queryLabel} | ||
tooltip="Return to the Documents tab to edit this query." | ||
/> | ||
} | ||
disabled={true} | ||
value={filterQuery} | ||
className={textInputStyles} | ||
/> | ||
); | ||
} |