-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b8a5ee
commit bf62d2e
Showing
10 changed files
with
376 additions
and
322 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Tooltip } from '@devtron-labs/devtron-fe-common-lib' | ||
|
||
interface InteractiveCellTextProps { | ||
text: string | ||
linkRedirectsTo?: () => void | ||
dataTestId?: string | ||
} | ||
|
||
export const InteractiveCellText = ({ text, linkRedirectsTo, dataTestId }: InteractiveCellTextProps) => ( | ||
<Tooltip | ||
content={text} | ||
placement="bottom" | ||
showOnTruncate={!!text} | ||
className="mxh-210 dc__overflow-auto" | ||
interactive | ||
> | ||
{typeof linkRedirectsTo === 'function' ? ( | ||
<button | ||
type="button" | ||
onClick={linkRedirectsTo} | ||
className="flex left dc__unset-button-styles lh-20 dc__ellipsis-right fs-13 cb-5 dc__no-decor cursor" | ||
data-testid={dataTestId} | ||
> | ||
{text || '-'} | ||
</button> | ||
) : ( | ||
<p className="lh-20 dc__ellipsis-right m-0 fs-13" data-testid={dataTestId}> | ||
{text || '-'} | ||
</p> | ||
)} | ||
</Tooltip> | ||
) |
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,51 @@ | ||
import { FilterSelectPicker } from '@devtron-labs/devtron-fe-common-lib' | ||
import { useEffect } from 'react' | ||
import { | ||
ExternalLinkFiltersProps, | ||
ExternalLinkFilters, | ||
IdentifierOptionType, | ||
ExternalLinkIdentifierType, | ||
} from './ExternalLinks.type' | ||
|
||
const createAppFilterKey = (value: string) => { | ||
const appValue = value.split('|') | ||
return `${appValue[0]}_${appValue[2] === ExternalLinkIdentifierType.DevtronApp ? 'd' : 'h'}` | ||
} | ||
|
||
export const ExternalLinkFilter = ({ | ||
allApps, | ||
updateSearchParams, | ||
appliedApps, | ||
setAppliedApps, | ||
queryParams, | ||
}: ExternalLinkFiltersProps) => { | ||
// To update the dropdown selections on query param value change or page reload | ||
useEffect(() => { | ||
if (allApps.length > 0 && queryParams.has('apps')) { | ||
const _appliedAppIds = queryParams.get('apps').split(',') | ||
const _appliedApps = allApps.filter((app) => _appliedAppIds.includes(createAppFilterKey(app.value))) | ||
|
||
setAppliedApps(_appliedApps) | ||
} | ||
}, [allApps, queryParams.get('apps')]) | ||
|
||
const handleUpdateFilters = (filterKey: ExternalLinkFilters) => (selectedOptions: IdentifierOptionType[]) => { | ||
console.log(selectedOptions, 'selectedOptions') | ||
setAppliedApps(selectedOptions) | ||
updateSearchParams({ [filterKey]: selectedOptions.map((option) => String(option.value)) }) | ||
} | ||
|
||
return ( | ||
<div className="filters-wrapper ml-8"> | ||
<FilterSelectPicker | ||
placeholder="Application" | ||
inputId="app-list-app-status-select" | ||
options={allApps} | ||
appliedFilterOptions={appliedApps} | ||
isDisabled={false} | ||
isLoading={false} | ||
handleApplyFilter={handleUpdateFilters(ExternalLinkFilters.APPS)} | ||
/> | ||
</div> | ||
) | ||
} |
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
Oops, something went wrong.