High-level: Our front-end JS certainly is messy in some places.  Especially some
EasyWidget stuff that has JS embedded in .py files!  At least we don't write any
new stuff like that.  Since React is self-contained and small I don't think
there's any problem with introducing it.  The only thing would be that it adds a
bit more to learn to Allura's wide tech stack, when maintaining code that uses
it.  I think that's ok though.  Are we going to use JSX though?  That would add
a compilation step, and some complexity across the board for deployment.

More specifically to your example: I have noticed we have several places that do
semi-complex status polling (this merge request status, also repo refresh
status, and repo zip file status).  Things like that perhaps could be made into
a re-usable component without using React.  It could be a few JS functions, or a
jquery plugin for example.  That said, React is fine to start using by me.

-Dave

On 5/8/15 7:04 AM, Igor Bondarenko wrote:
> Hey guys!
> 
> Every time I'm working on some small js/ajax piece of UI for Allura I'm
> thinking
> that I'm creating something fragile which can break apart in any moment
> without
> me even noticing. That's mainly because of direct DOM manipulation. The
> latest
> example of this is https://forge-allura.apache.org/p/allura/tickets/7866/
> where
> I needed to check a state of background task and display status to the user
> and
> enable/disable different pieces of UI depending on task result (this pattern
> actually can be found in a few places in Allura). Every time I write
> something
> like this
> https://forge-allura.apache.org/p/allura/git/ci/master/tree/Allura/allura/templates/repo/merge_request.html#l218
> I feel like I'm stepping on a landmine :)
> 
> Does it happen to any of you? :)
> 
> The reason I bring this up now is that I'm starting work on phone
> verification
> UI (#7868) and I expect some of js/ajax shenanigans there as well.  I would
> like
> to try a different approach for dealing with the DOM, but since it requires
> to
> pull a new technology into our stack I can't do it before discussing it with
> you.
> 
> There's a library that removes this pain. It's React.js.  I have some
> experience
> using it and it's just a breeze for tasks like that. It is built in a way
> that
> allows to use it only for a small piece of a page, exactly where you need
> it, so
> there's no need to worry about rewriting existing code to support it and it
> can
> be included only on a pages that need it. It's pretty small, latest
> compressed
> version is 129K. For example our jquery-base, which we include on every
> page is
> twice that size (332K). It's BSD licensed.
> 
> I don't think our current situation is *that* bad, but on the other hand it
> can
> restrain us from trying to build more complex things, UI wise.  In my
> opinion it
> worth to try React in Allura, starting with such small problems as I
> described.
> In my case, I'm sure it will give me more confidence, that UI pieces I build
> work as expected.
> 
> What do you think?
> 



-- 
Dave Brondsema : [email protected]
http://www.brondsema.net : personal
http://www.splike.com : programming
              <><

Reply via email to