-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Remove SitesList] Add isSiteCustomizable selector #13160
Conversation
b3b731f
to
1bac497
Compare
client/state/sites/selectors.js
Outdated
@@ -14,7 +14,7 @@ import { | |||
some, | |||
split, | |||
includes, | |||
startsWith, | |||
startsWith |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this unintentional? seems like an unnecessary change…
let defaultPostFormat = getSiteOption( state, siteId, 'default_post_format' ); | ||
if ( ! defaultPostFormat || defaultPostFormat === '0' ) { | ||
defaultPostFormat = 'standard'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests like this are good reasons for normalizing data form the API on entry into Calypso. instead of scattering around the checks and converting everywhere the data is used it would be helpful if it never came into the system in the odd formats. that's a side-comment 😉
default_post_format: defaultPostFormat | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the other new selector is in the state/selectors
directory but this one is being added to the existing file. do we need to move it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about that. isSiteCustomizable()
can live on its own now, it's not a computed attribute, whereas options
still is. We might want to change it later but I think it makes sense to have it alongside getSite
for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well we have been adding all new selectors to the selector directory. I should probably rephrase the question: is there a good reason why we aren't adding it to the selector directory instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I don't feel strongly on this so if you really think this is a blocker I can simply move it to state/selectors
.
My logic is that all the selectors used to assemble the site in the getSite
selector currently lives in that file and I'm not sure we plan to even use this selector at all or if we will always just access options
through the property of the site
.
Whether we keep it as a computed property or not is probably a subject for another PR since I haven't started to update usage of site.options anywhere (and I'm not sure we should).
In the case of is_customizable
, I was able to update all usage to use the new selector instead and removed it from the site computed properties, so it's definitely a valid/useful selector and this is why it was moved to state/selectors
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's see if @aduth has an opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having authored the yet-unmerged #10234, I tend to sway more on the extreme of forbidding new selectors outside state/selectors
directory, regardless of any inconsistencies it might introduce (an expected and necessary pain of adopting a new recommendation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's put everything new on state/selectors
.
1bac497
to
08da6a7
Compare
client/state/sites/selectors.js
Outdated
}; | ||
}, | ||
( state ) => state.sites.items | ||
); | ||
|
||
export function getSiteOptions( state, siteId ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, I actually don't think we should make this an exportable selector. It should only be used in getSite
. Also probably the name of the function should be changed to reflect we are computing values and not just returning site.options
.
Changes here look pretty reasonable 👍 Looks like this needs a rebase, ping me when it's ready and I can help smoke test. |
@Tug This PR needs a rebase |
…gainst incomplete states
dc57fe6
to
158c8f0
Compare
Rebased and renamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 I haven't tested it, because I'm not sure when I shouldn't have access to themes.
I think you don't have access when you have any other role than "Administrator" on a site. |
) * WIP Add QuerySites in Layout and shift from sitesFactory to Redux sites * WIP more seek & destroy sites-list (Navigation, Picker, Sidebar) * Tackle SitesList in my-sites/controller * Use post-rebase selector areAllSitesSingleUser * Selectors: getSite: support non-ID-based retrieval In the process of removing SitesList, some instances are found of: sites.getSite( siteFragment ) where `siteFragment` is of mixed format. See lib/route/test. * my-sites: controller: SITES_ONCE_CHANGED; no more sites.once * Post-rebase fix * Update CurrentSite and AllSites to use getSites. * ES6ify SiteSelector * AllSites: Use ES6-style defaultProps * getSite: don't return false * CurrentSite: Use ES6-style state initializer * SiteSelector: Fix passing of `this` to `map` Lodash's `map` doesn't support passing of `this` (anymore?). Fixes TypeError. * Appease linter * Selectors: canManageSelectedOrAnySite, getSelectedOrAllSites * Use getSelectedOrAllSites selector in current site block. * Fix exports. * Fix switch sites. * Add isRequestingMissingSites selector. * Resetting attributes creates a circular call with getRawSite That means we end up passing a slug to getRawSite, which fails, meaning computted attributes are not set. * getSites: wrap with createSelector * Add siteSearch HoC to replace sites.search in SiteSelector * Remove sites-list from sites dropdown. * Use getPrimarySiteId() selector * CurrentSite: connect to redux; bind selector :( * siteSelection: ensure siteID is numeric before firing setting actions Adds `getSiteId` selector. * Sites: use connect to provide selected site * [DELETE AFTER 13121] PostsNavigation: connect to Redux * rm selector canManageSelectedOrAnySite * Revert "Merge pull request #13160 from Automattic/update/site-is-customizable" This reverts commit d180acc, reversing changes made to 78d8f29. * getSite: re-remove cyclical selector calls * Stats: Controllers: Don't depend on sites-list * Import was kept, as `sites` is passed as props in one controller. To be fixed in a separate PR. * SitesDropdown: "fix" tests * Avoid duplicate selector call, use `get` * state/lib/middleware: better naming, comments * siteSelection: fix redirs, wait for selected site's data * Keep SitesList's `selected` in sync with Redux - :-( - Aims to fix regressions found, notably around flows in `/domains` * siteSelect: immediately redirectToPrimary if data ready This mimics the behavior that used to be in place with `sites.initialized`. Without it, render jumps may happen as we default to a site-less view then correct to a site-specific one. * NavItem: fix propTypes (`count`) Component logic expects non-number `count`, e.g. when no site is selected. This eliminates React type warnings. * Signup: fetchSitesAndUser: wait & load new site into Redux store One of the async jobs of fetchSitesAndUser is to trigger a `fetch` on `lib/sites-list`, wait for changes to that structure, check for the local availability of data for the new site, then either continue or retrigger a fetch. This commit ports that behavior to our Redux data layer. * Invites: Pull sites from server upon accepting Before #13094, this behavior was ensured by the `acceptInvite` action creator, which dispatches old Flux actions that `lib/sites-list` listens to in order to call a `sync` on itself.
This PR creates the
isSiteCustomizable()
selector and update thegetSite
selector to use it instead of usinggetComputedAttribute
. It also updates usages ofisCustomizable()
in components so we can removeSites#isCustomizable()
as well as the computed attributesite.is_customizable
.Testing Instructions
make test
)