fleet/frontend/pages/SoftwarePage/SoftwareAddPage/SoftwareAppStoreVpp/helpers.ts
Gabriel Hernandez 0359290662
implement add Vpp software UI to new add software pages (#22264)
relates to #21811

This adds the UI for the new add vpp software flow. This moves the add
app store vpp flow under the App Store (Vpp) Tab panel. This includes:

**add vpp software form**


![image](https://github.com/user-attachments/assets/0b8cea88-baea-4da7-88f7-6c392a8af4a6)

**has now vpp token setup UI**


![image](https://github.com/user-attachments/assets/40142599-f5d9-4602-a731-786b69a6b8b9)


**has no vpp apps UI**


![image](https://github.com/user-attachments/assets/5aa29772-037c-456a-894b-cf99f5f35cb4)


<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
- [ ] Added/updated tests
- [x] Manual QA for all new/changed functionality
2024-09-20 16:15:10 +01:00

26 lines
698 B
TypeScript

import { IMdmVppToken } from "interfaces/mdm";
/**
* Checks if the given team has an available VPP token (either a token
* that's associated with the team, or a token that's available to "All
* teams")
*/
// eslint-disable-next-line import/prefer-default-export
export const teamHasVPPToken = (
currentTeamId: number,
tokens?: IMdmVppToken[]
) => {
if (!tokens || tokens.length === 0) {
return false;
}
return tokens.some((token) => {
// if we've got a non-null, empty array it means the token is available for
// "All teams"
if (token.teams?.length === 0) {
return true;
}
return token.teams?.some((team) => team.team_id === currentTeamId);
});
};