Uninett / nav

Network Administration Visualized
GNU General Public License v3.0
180 stars 37 forks source link

Replace Foundation javascript #2972

Open hmpf opened 4 days ago

hmpf commented 4 days ago

For #2794

lunkwill42 commented 4 days ago

We need an initial analysis of actual usage of Foundation JS calls before we can start planning what to do with it.

podliashanyk commented 3 days ago

Found following usages directly in JS:

Targets
    Occurrences of 'foundation' in Project
Found occurrences in Project  (41 usages found)
    Unclassified  (41 usages found)
        nav  (41 usages found)
            python/nav/web/static/js/src  (26 usages found)
                devicehistory.js  (3 usages found)
                    41 Foundation.libs.tooltip.create(target);
                    43 Foundation.libs.tooltip.hide($(event.currentTarget));
                    46 Foundation.libs.tooltip.showTip(target);
                info_room.js  (2 usages found)
                    70 $(document).foundation('reveal');  // Apply reveal after ajax request
                    71 $(document).foundation('tooltip');  // Apply tooltip after ajax request
                info_room_rack.js  (5 usages found)
                    60 $sensorModal.foundation('reveal', 'open', {
                    98 $sensorModal.foundation('reveal', 'close');
                    114 $sensorModal.foundation('reveal', 'close');
                    137 $rackModal.foundation('reveal', 'close');
                    496 $(document).foundation();  // Make sure add rack modal opens
                main.js  (1 usage found)
                    68 $(document).foundation();   // Apply foundation javascript on load
                portadmin.js  (3 usages found)
                    25 this.modal.foundation('reveal', 'open', {
                    31 this.modal.foundation('reveal', 'close');
                    91 $(document).foundation('tooltip', 'reflow');
                radius.js  (1 usage found)
                    69 $('#details_modal').foundation('reveal', 'open', $(this).attr('data-bubble-reveal'));
                seeddb.js  (2 usages found)
                    126 $(document).foundation({
                    140 $(document).foundation('joyride', 'start');
                seeddb_add_patch.js  (4 usages found)
                    52 $modal.foundation('reveal', 'open');
                    66 $addModal.foundation('reveal', 'close');
                    86 $removeModal.foundation('reveal', 'close');
                    96 $removeModal.foundation('reveal', 'close');
                subnetmatrix.js  (3 usages found)
                    221 Foundation.libs.tooltip.create(target);
                    227 Foundation.libs.tooltip.hide(popped);
                    234 Foundation.libs.tooltip.showTip($target);
                threshold.js  (1 usage found)
                    56 $(document).foundation('dropdown', 'close', $parent);
                webfront.js  (1 usage found)
                    361 $(document).foundation('joyride', 'start');
            python/nav/web/static/js/src/ipam  (1 usage found)
                app.js  (1 usage found)
                    5 var Foundation = require("libs/foundation.min");
            python/nav/web/static/js/src/ipam/views  (2 usages found)
                subnetallocator.js  (2 usages found)
                    14 var Foundation = require("libs/foundation.min");
                    324 $(document).foundation();
            python/nav/web/static/js/src/netmap  (1 usage found)
                control_view.js  (1 usage found)
                    129 $(document).foundation('equalizer', 'reflow');
            python/nav/web/static/js/src/plugins  (8 usages found)
                delegate_tooltip.js  (4 usages found)
                    27 Foundation.libs.tooltip.showTip($target);
                    56 Foundation.libs.tooltip.create($target);
                    57 Foundation.libs.tooltip.showTip($target);
                    59 Foundation.libs.tooltip.hide($target);
                navlet_controller.js  (3 usages found)
                    196 $(modal).foundation('reveal', 'close');
                    212 $(modal).foundation('reveal', 'close');
                    216 $(modal).foundation('reveal', 'open');
                navlets_controller.js  (1 usage found)
                    93 $('#navlet-list').foundation('reveal', 'close');
            python/nav/web/static/js/src/status2  (1 usage found)
                views.js  (1 usage found)
                    171 $(document).foundation('dropdown', 'reflow');
            python/nav/web/templates  (1 usage found)
                styleguide.html  (1 usage found)
                    23 $(document).foundation('dropdown', 'close', $(this).parents('.f-dropdown:first'));
            python/nav/web/templates/useradmin  (1 usage found)
                token_edit.html  (1 usage found)
                    26 $(document).foundation('dropdown', 'close', $(this).parents('.f-dropdown:first'));

Additionally see https://github.com/Uninett/nav/issues/2794#issuecomment-1973038282 for usages of crispy_forms_foundation

podliashanyk commented 3 days ago

NB! Usages in https://github.com/Uninett/nav/issues/2972#issuecomment-2352818837 are not tested for redundancy, except for:

            python/nav/web/static/js/src/ipam  (1 usage found)
                app.js  (1 usage found)
                    5 var Foundation = require("libs/foundation.min");
            python/nav/web/static/js/src/ipam/views  (2 usages found)
                subnetallocator.js  (2 usages found)
                    14 var Foundation = require("libs/foundation.min");

Removing the above mentioned lines from the codebase does not seem to affect any style/behaviour in IPAM.

podliashanyk commented 3 days ago

To generally summarise so far, foundation is used:

lunkwill42 commented 3 days ago

@hmpf This is tracked by #2788 and says it's for #2794: But fixing this really isn't a requirement of either, is it? We can remove crispy-forms and make NAV run just fine on Python 3.11 without replacing calls to Foundation JavaScript.

hmpf commented 3 days ago

We can still use crispy-forms as long as we stop using crispy-forms-foundation. Foundation 5 needs to go for security reasons.

lunkwill42 commented 3 days ago

We can still use crispy-forms as long as we stop using crispy-forms-foundation. Foundation 5 needs to go for security reasons.

I don't know what those security reasons are, though I agree that Foundation needs to go, eventually. However, if we remove crispy-forms from NAV, doing something about Foundation is not a requirement to close #2788 or #2794.