-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This takes the empty list components from e and moves them to OSS. The main difference is the different CTAs and buttons now displayed in oss v e. The empty list itself is unchanged, only moved
- Loading branch information
Showing
5 changed files
with
632 additions
and
148 deletions.
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
web/packages/teleport/src/DeviceTrust/DeviceList/DeviceList.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,116 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import styled from 'styled-components'; | ||
|
||
import Box from 'design/Box'; | ||
import Table, { Cell } from 'design/DataTable'; | ||
import { ResourceIcon, ResourceIconName } from 'design/ResourceIcon'; | ||
import { P2 } from 'design/Text'; | ||
|
||
import { | ||
DeviceListProps, | ||
TrustedDeviceOSType, | ||
} from 'teleport/DeviceTrust/types'; | ||
|
||
export const DeviceList = ({ | ||
items = [], | ||
pageSize = 50, | ||
pagerPosition = null, | ||
fetchStatus = '', | ||
fetchData, | ||
}: DeviceListProps) => { | ||
return ( | ||
<Table | ||
data={items} | ||
columns={[ | ||
{ | ||
key: 'osType', | ||
headerText: 'OS Type', | ||
render: ({ osType }) => <IconCell osType={osType} />, | ||
}, | ||
{ | ||
key: 'assetTag', | ||
headerText: 'Asset Tag', | ||
}, | ||
{ | ||
key: 'enrollStatus', | ||
headerText: 'Enroll Status', | ||
render: ({ enrollStatus }) => ( | ||
<EnrollmentStatusCell status={enrollStatus} /> | ||
), | ||
}, | ||
{ | ||
key: 'owner', | ||
headerText: 'Owner', | ||
}, | ||
]} | ||
emptyText="No Devices Found" | ||
pagination={{ pageSize, pagerPosition }} | ||
fetching={{ onFetchMore: fetchData, fetchStatus }} | ||
isSearchable | ||
/> | ||
); | ||
}; | ||
|
||
const EnrollmentStatusCell = ({ status }: { status: string }) => { | ||
const enrolled = status === 'enrolled'; | ||
return ( | ||
<Cell | ||
align="left" | ||
css={` | ||
display: flex; | ||
align-items: center; | ||
`} | ||
> | ||
<EnrollmentIcon enrolled={enrolled} /> | ||
<P2 color={enrolled ? 'success.main' : 'error.main'}>{status}</P2> | ||
</Cell> | ||
); | ||
}; | ||
|
||
export const IconCell = ({ osType }: { osType: TrustedDeviceOSType }) => { | ||
let iconName: ResourceIconName; | ||
switch (osType) { | ||
case 'Windows': | ||
iconName = 'microsoft'; | ||
break; | ||
case 'Linux': | ||
iconName = 'linux'; | ||
break; | ||
case 'macOS': | ||
iconName = 'apple'; | ||
break; | ||
} | ||
return ( | ||
<Cell align="left" style={{ display: 'flex', alignItems: 'center' }}> | ||
<ResourceIcon name={iconName} width="14px" mr={3} /> | ||
{osType} | ||
</Cell> | ||
); | ||
}; | ||
|
||
const EnrollmentIcon = styled(Box)<{ enrolled: boolean }>` | ||
width: 12px; | ||
height: 12px; | ||
margin-right: ${p => p.theme.space[1]}px; | ||
border-radius: 50%; | ||
background-color: ${p => | ||
p.enrolled ? p.theme.colors.success.main : p.theme.colors.error.main}; | ||
}; | ||
`; |
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,19 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
export { DeviceList } from './DeviceList'; |
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.