Skip to content

Commit

Permalink
Issue 258 - Implement Services main page and buttons
Browse files Browse the repository at this point in the history
Convert services to use CL and make all the main buttons work as
expected

fixes: freeipa#258

Signed-off-by: Mark Reynolds <[email protected]>
  • Loading branch information
mreynolds389 committed Feb 13, 2024
1 parent e6163fb commit 6e1f135
Show file tree
Hide file tree
Showing 23 changed files with 911 additions and 343 deletions.
25 changes: 16 additions & 9 deletions src/components/BulkSelectorServicesPrep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ const BulkSelectorServicesPrep = (props: PropsToBulkSelectorPrep) => {
selectableServicesList: Service[]
) => {
props.elementData.changeSelectedServiceIds(
isSelecting ? selectableServicesList.map((r) => r.id) : []
isSelecting ? selectableServicesList.map((r) => r.krbcanonicalname) : []
);

// Update selected elements
const serviceNamesArray: string[] = [];
selectableServicesList.map((service) => {
serviceNamesArray.push(service.id);
serviceNamesArray.push(service.krbcanonicalname);
});
props.elementData.updateSelectedServices(serviceNamesArray);

Expand All @@ -133,7 +133,7 @@ const BulkSelectorServicesPrep = (props: PropsToBulkSelectorPrep) => {
servicesIdArray.push(service);
});
selectableServicesList.map((service) => {
servicesIdArray.push(service.id);
servicesIdArray.push(service.krbcanonicalname);
});
}

Expand Down Expand Up @@ -165,20 +165,22 @@ const BulkSelectorServicesPrep = (props: PropsToBulkSelectorPrep) => {
selectableServicesList: Service[]
) => {
props.elementData.changeSelectedServiceIds(
isSelecting ? selectableServicesList.map((r) => r.id) : []
isSelecting ? selectableServicesList.map((r) => r.krbcanonicalname) : []
);

// Update selected elements
const serviceNamesArray: string[] = [];
selectableServicesList.map((service) => {
serviceNamesArray.push(service.id);
serviceNamesArray.push(service.krbcanonicalname);
});
props.elementData.updateSelectedServices(serviceNamesArray);

// Enable/disable 'Delete' button
if (isSelecting) {
const servicesIdArray: string[] = [];
selectableServicesList.map((service) => servicesIdArray.push(service.id));
selectableServicesList.map((service) =>
servicesIdArray.push(service.krbcanonicalname)
);
props.elementData.changeSelectedServiceIds(servicesIdArray);
props.elementData.updateSelectedServices(servicesIdArray);
props.buttonsData.updateIsDeleteButtonDisabled(false);
Expand All @@ -194,8 +196,9 @@ const BulkSelectorServicesPrep = (props: PropsToBulkSelectorPrep) => {
// - Some rows selected: null (-)
// - None selected: false (empty)
const areAllElementsSelected: boolean | null =
props.elementData.selectedServices.length > 0 &&
props.elementData.selectedServices.length ===
props.elementData.selectableServicesTable.length
props.elementData.selectableServicesTable.length
? true
: props.elementData.selectedServices.length > 0
? null
Expand Down Expand Up @@ -241,7 +244,9 @@ const BulkSelectorServicesPrep = (props: PropsToBulkSelectorPrep) => {
// The 'currentPageAlreadySelected' should be set when elements are selected
useEffect(() => {
const found = props.shownElementsList.every(
(service) => props.elementData.selectedServices.indexOf(service.id) >= 0
(service) =>
props.elementData.selectedServices.indexOf(service.krbcanonicalname) >=
0
);

if (found) {
Expand All @@ -254,7 +259,9 @@ const BulkSelectorServicesPrep = (props: PropsToBulkSelectorPrep) => {
if (
!props.shownElementsList.some(
(service) =>
props.elementData.selectedServices.indexOf(service.id) >= 0
props.elementData.selectedServices.indexOf(
service.krbcanonicalname
) >= 0
)
) {
props.selectedPerPageData.updateSelectedPerPage(0);
Expand Down
1 change: 1 addition & 0 deletions src/components/ManagedBy/ManagedByDeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ManagedByDeleteModal = (props: PropsToDeleteModal) => {
elementsToDelete={props.groupNamesToDelete}
columnNames={["Host"]}
elementType={props.tabData.tabName}
idAttr="fqdn"
/>
),
},
Expand Down
10 changes: 5 additions & 5 deletions src/components/ServicesSections/AllowedCreateKeytab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CreateKeytabUserGroupsTable from "../tables/HostsSettings/CreateKeytabUse
import CreateKeytabHostsTable from "../tables/HostsSettings/CreateKeytabHostsTable";
import CreateKeytabHostGroupsTable from "../tables/HostsSettings/CreateKeytabHostGroupsTable";
// Data types
import { Service } from "src/utils/datatypes/globalDataTypes";
import { Service } from "../../utils/datatypes/globalDataTypes";

interface PropsToAllowCreateKeytab {
service: Service;
Expand All @@ -17,12 +17,12 @@ const AllowedCreateKeytab = (props: PropsToAllowCreateKeytab) => {
return (
<Flex direction={{ default: "column", lg: "row" }}>
<FlexItem flex={{ default: "flex_1" }}>
<CreateKeytabUsersTable host={props.service.id} />
<CreateKeytabHostsTable host={props.service.id} />
<CreateKeytabUsersTable host={props.service.krbcanonicalname} />
<CreateKeytabHostsTable host={props.service.krbcanonicalname} />
</FlexItem>
<FlexItem flex={{ default: "flex_1" }}>
<CreateKeytabUserGroupsTable host={props.service.id} />
<CreateKeytabHostGroupsTable host={props.service.id} />
<CreateKeytabUserGroupsTable host={props.service.krbcanonicalname} />
<CreateKeytabHostGroupsTable host={props.service.krbcanonicalname} />
</FlexItem>
</Flex>
);
Expand Down
10 changes: 5 additions & 5 deletions src/components/ServicesSections/AllowedRetrieveKeytab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RetrieveKeytabUserGroupsTable from "../tables/HostsSettings/RetrieveKeyta
import RetrieveKeytabHostsTable from "../tables/HostsSettings/RetrieveKeytabHostsTable";
import RetrieveKeytabHostGroupsTable from "../tables/HostsSettings/RetrieveKeytabHostGroupTable";
// Data types
import { Service } from "src/utils/datatypes/globalDataTypes";
import { Service } from "../../utils/datatypes/globalDataTypes";

interface PropsToAllowCreateKeytab {
service: Service;
Expand All @@ -17,12 +17,12 @@ const AllowedRetrieveKeytab = (props: PropsToAllowCreateKeytab) => {
return (
<Flex direction={{ default: "column", lg: "row" }}>
<FlexItem flex={{ default: "flex_1" }}>
<RetrieveKeytabUsersTable host={props.service.id} />
<RetrieveKeytabHostsTable host={props.service.id} />
<RetrieveKeytabUsersTable host={props.service.krbcanonicalname} />
<RetrieveKeytabHostsTable host={props.service.krbcanonicalname} />
</FlexItem>
<FlexItem flex={{ default: "flex_1" }}>
<RetrieveKeytabUserGroupsTable host={props.service.id} />
<RetrieveKeytabHostGroupsTable host={props.service.id} />
<RetrieveKeytabUserGroupsTable host={props.service.krbcanonicalname} />
<RetrieveKeytabHostGroupsTable host={props.service.krbcanonicalname} />
</FlexItem>
</Flex>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/ServicesSections/ServiceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ServiceSettings = (props: PropsToServiceSettings) => {
>([
{
id: 0,
alias: props.service.id,
alias: props.service.krbcanonicalname,
},
]);

Expand Down Expand Up @@ -261,7 +261,7 @@ const ServiceSettings = (props: PropsToServiceSettings) => {
<TextInput
id="host-name"
name="host"
value={props.service.host}
value={props.service.krbcanonicalname}
type="text"
aria-label="host name"
isDisabled
Expand Down
Loading

0 comments on commit 6e1f135

Please sign in to comment.