-
Notifications
You must be signed in to change notification settings - Fork 955
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge c93191a into sapling-pr-archive-passy
- Loading branch information
Showing
79 changed files
with
2,160 additions
and
659 deletions.
There are no files selected for viewing
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
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
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
75 changes: 75 additions & 0 deletions
75
desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchAbsoluteDateTerm.tsx
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,75 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
import {DatePicker, DatePickerProps} from 'antd'; | ||
import React from 'react'; | ||
|
||
type PowerSearchAbsoluteTermProps = { | ||
onCancel: () => void; | ||
onChange: (value: Date) => void; | ||
dateOnly?: boolean; | ||
minValue?: Date; | ||
maxValue?: Date; | ||
}; | ||
|
||
export const DATE_ONLY_FORMAT = 'YYYY-MM-DD'; | ||
export const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'; | ||
|
||
export const PowerSearchAbsoluteDateTerm: React.FC< | ||
PowerSearchAbsoluteTermProps | ||
> = ({onCancel, onChange, dateOnly, minValue, maxValue}) => { | ||
const disabledDate: DatePickerProps['disabledDate'] = React.useCallback( | ||
(date) => { | ||
if (minValue !== undefined && date < minValue) { | ||
return true; | ||
} | ||
if (maxValue !== undefined && date > maxValue) { | ||
return true; | ||
} | ||
return false; | ||
}, | ||
[minValue, maxValue], | ||
); | ||
|
||
const format = dateOnly ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'; | ||
|
||
const valueRef = React.useRef<Date>(); | ||
|
||
return ( | ||
<DatePicker | ||
autoFocus | ||
style={{width: 100}} | ||
placeholder="..." | ||
format={format} | ||
onChange={(newValue) => { | ||
if (!newValue) { | ||
onCancel(); | ||
return; | ||
} | ||
|
||
const newDate = newValue.toDate(); | ||
valueRef.current = newDate; | ||
onChange(newDate); | ||
}} | ||
onKeyDown={(event) => { | ||
if (event.key === 'Escape') { | ||
onCancel(); | ||
} | ||
}} | ||
onBlur={() => { | ||
if (!valueRef.current) { | ||
onCancel(); | ||
} | ||
}} | ||
disabledDate={disabledDate} | ||
showTime={!dateOnly} | ||
defaultOpen | ||
/> | ||
); | ||
}; |
59 changes: 59 additions & 0 deletions
59
desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchConfig.tsx
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,59 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
// Mostly matches https://www.internalfb.com/code/www/html/intern/js/ui/PowerSearch/PowerSearchExampleConfig.js | ||
|
||
export type SimpleFilterValueType = | ||
| 'NO_VALUE' | ||
| 'INTEGER' | ||
| 'FLOAT' | ||
| 'STRING' | ||
| 'STRING_SET'; | ||
|
||
export type EnumFilterValueType = 'ENUM' | 'ENUM_SET'; | ||
|
||
export type AbsoluteDateFilterValueType = 'ABSOLUTE_DATE'; | ||
|
||
export type SimpleOperatorConfig = { | ||
valueType: SimpleFilterValueType; | ||
key: string; | ||
label: string; | ||
}; | ||
|
||
export type EnumOperatorConfig = { | ||
valueType: EnumFilterValueType; | ||
key: string; | ||
label: string; | ||
enumLabels: {[key: string]: string}; | ||
}; | ||
|
||
export type AbsoluteDateOperatorConfig = { | ||
valueType: AbsoluteDateFilterValueType; | ||
key: string; | ||
label: string; | ||
dateOnly?: boolean; | ||
minValue?: Date; | ||
maxValue?: Date; | ||
}; | ||
|
||
export type OperatorConfig = | ||
| SimpleOperatorConfig | ||
| EnumOperatorConfig | ||
| AbsoluteDateOperatorConfig; | ||
|
||
export type FieldConfig = { | ||
key: string; | ||
label: string; | ||
operators: {[key: string]: OperatorConfig}; | ||
}; | ||
|
||
export type PowerSearchConfig = { | ||
name: string; | ||
fields: {[key: string]: FieldConfig}; | ||
}; |
31 changes: 31 additions & 0 deletions
31
desktop/flipper-plugin/src/ui/PowerSearch/PowerSearchContainer.tsx
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,31 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
import * as React from 'react'; | ||
import {css} from '@emotion/css'; | ||
import {theme} from '../theme'; | ||
|
||
const containerStyle = css` | ||
display: flex; | ||
flex-direction: row; | ||
border-radius: ${theme.borderRadius}; | ||
border: 1px solid ${theme.borderColor}; | ||
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); | ||
padding: 0 ${theme.space.tiny}px; | ||
&:focus-within, | ||
&:hover { | ||
border-color: ${theme.primaryColor}; | ||
box-shadow: 0 0 0 2px rgba(114, 46, 209, 0.2); | ||
} | ||
`; | ||
|
||
export const PowerSearchContainer: React.FC = ({children}) => { | ||
return <div className={containerStyle}>{children}</div>; | ||
}; |
Oops, something went wrong.