Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

States "genericity" #16198

Merged
merged 38 commits into from
Mar 4, 2024
Merged

States "genericity" #16198

merged 38 commits into from
Mar 4, 2024

Conversation

trasher
Copy link
Contributor

@trasher trasher commented Dec 14, 2023

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes

Should be more or less OK.
No SO is working.
Naming is probably not OK everywhere.

Since I'm not sure the way I've chosen is OK, I don't waste more time on that for now.

@cedric-anne cedric-anne changed the base branch from 10.0/bugfixes to main December 14, 2023 15:05
@cedric-anne cedric-anne added this to the 10.1.0 milestone Dec 14, 2023
@trasher
Copy link
Contributor Author

trasher commented Jan 10, 2024

ping @cedric-anne @orthagh

As said already on internal channel, I need a first validation/talk on this one. Main problem will be search options; I do not even know if current system can handle current PR.
Also, if one of you see another solution to make states generic, I'll be happy to think about it.

@trasher trasher force-pushed the feature/states branch 2 times, most recently from 868deeb to 2b1c405 Compare January 15, 2024 08:06
trasher added a commit to trasher/glpi that referenced this pull request Feb 22, 2024
trasher added a commit to trasher/glpi that referenced this pull request Feb 22, 2024
@trasher trasher marked this pull request as ready for review February 22, 2024 14:06
@cconard96
Copy link
Contributor

cconard96 commented Feb 23, 2024

Commit to support the new state visibilties in the new API:
cconard96@232bc69

This info for states can only be seen through GraphQL at the moment (POST request at /api.php/GraphQL).
Sample GraphQL JSON body to test this:

query {
    Computer(limit: 10) {
        id
        status {
            name
            visibilities {
                computer
                monitor
            }
        }
    }
}

@trasher
Copy link
Contributor Author

trasher commented Feb 23, 2024

I've never been able to use API; if tests are OK, that's OK for me (need someone else to do the review).

@cconard96
Copy link
Contributor

I've never been able to use API; if tests are OK, that's OK for me (need someone else to do the review).

Is there a technical issue with it that I need to check/fix?

@trasher
Copy link
Contributor Author

trasher commented Feb 23, 2024

Is there a technical issue with it that I need to check/fix?

No :) I just cannot test API side if any state change are working.

src/DBmysqlIterator.php Outdated Show resolved Hide resolved
@trasher trasher force-pushed the feature/states branch 2 times, most recently from bbfe926 to 0fcf292 Compare February 26, 2024 08:43
@trasher trasher requested a review from cedric-anne February 26, 2024 09:10
@trasher
Copy link
Contributor Author

trasher commented Feb 26, 2024

I've fixed all remaining cases I saw; should be OK now.

@trasher trasher requested a review from orthagh February 26, 2024 09:21
@cedric-anne
Copy link
Member

cedric-anne commented Feb 29, 2024

I pushed a commit to check that all items having the states_id field are present in $CFG_GLPI['state_types'].

  1. There are 2 exceptions: DeviceGeneric and DeviceSensor have this type, in contrary to other devices. IMHO, we should drop this field. Indeed, the state should be set on Item_DeviceGeneric and Item_DeviceSensor items, not on the "model" itself.

@orthagh @trasher Are you OK to remove this field?

  1. Now Item_Device* will have a filtered list of status. Until now, the list was not filtered, meaning that existing Item_Device* may already be assigne to some statuses that will no longer be available. There are multiple solutions to this:
    1. add a warning to tell to the administrator that states visibility should be configured manually;
    2. make a migration to make the already used states visible for the devices that areay use them;
    3. make a migration to make the existing states visible for all devices.

I think the first solution is sufficient, as an already define status will still be displayed in the dropdown:
image

@orthagh @trasher What is your opinion on this point ?

@trasher
Copy link
Contributor Author

trasher commented Mar 4, 2024

1. There are 2 exceptions: `DeviceGeneric` and `DeviceSensor` have this type, in contrary to other devices. IMHO, we should drop this field. Indeed, the state should be set on `Item_DeviceGeneric` and `Item_DeviceSensor` items, not on the "model" itself.
   @orthagh @trasher Are you OK to remove this field?

Yes; it has nothing to do in main device table.

2. Now `Item_Device*` will have a filtered list of status. Until now, the list was not filtered, meaning that existing `Item_Device*` may already be assigne to some statuses that will no longer be available. There are multiple solutions to this:


1. add a warning to tell to the administrator that states visibility should be configured manually;

2. make a migration to make the already used states visible for the devices that areay use them;

3. make a migration to make the existing states visible for all devices.

I think the first solution is sufficient, as an already define status will still be displayed in the dropdown: image

@orthagh @trasher What is your opinion on this point ?

I guess it would be preferable not to change data if possible. So, if just keeping values as-is does not break any feature; I guess it's enough.

trasher added 2 commits March 4, 2024 09:29
Add new relation table,
Drop existign columns,
Add migration,
Adapt add/update
Add tests
@cedric-anne cedric-anne merged commit be13ec1 into glpi-project:main Mar 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants