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

feat(organizations): add Organization Settings route TASK-981 #5299

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

magicznyleszek
Copy link
Member

@magicznyleszek magicznyleszek commented Nov 25, 2024

🗒️ Checklist

  1. run linter locally
  2. update all related docs (API, README, inline, etc.), if any
  3. draft PR with a title <type>(<scope>)<!>: <title> TASK-1234
  4. tag PR: at least frontend or backend unless it's global
  5. fill in the template below and delete template comments
  6. review thyself: read the diff and repro the preview as written
  7. open PR & confirm that CI passes
  8. request reviewers, if needed
  9. delete this section before merging

📣 Summary

In Organization Settings route (#/account/organization/settings) display editable organization name, and website. Also display non-editable organization type.

📖 Description

Only some roles allow editing the fields, and there is some logic in regards to fields being visible.

👀 Preview steps

  1. for one of the users (e.g. "joe"), use http://kf.kobo.local/admin/organizations/organization/ to enable "Multi-members override" (for "joe's organization")
  2. enable feature flag mmosEnabled
  3. navigate to #/account/organization/settings
  4. 🟢 notice that at least "Team name"/"Organization name" field is being displayed and is editable(-ish)
  • Editing the field doesn't do anything yet - this will be implemented in next PR
  1. 🟢 if you have enabled Stripe - notice that "Team website"/"Organization website" field and "Team type"/"Organzation type" (non editable) fields are also being displayed

Next steps:

  1. for another user (e.g. "zoe"), use http://kf.kobo.local/admin/organizations/organization/ to add "zoe" into "joe's organization"
  2. logged in as "zoe", navigate to #/account/organization/settings
  3. 🟢 notice that at least "Team name"/"Organization name" field is being displayed (non editable)
  4. 🟢 if you have enabled Stripe - notice that "Team website"/"Organization website" field and "Team type"/"Organzation type" fields are also being displayed (both non editable)

💭 Notes

Includes planName code being moved out of jsapp/js/account/usage/yourPlan.component.tsx into jsapp/js/account/subscriptionStore.ts so it can be used in both places now.

@magicznyleszek magicznyleszek changed the title feaet(organizations): add Organization Settings route TASK-981 feat(organizations): add Organization Settings route TASK-981 Nov 26, 2024
@magicznyleszek magicznyleszek marked this pull request as ready for review November 26, 2024 19:33
@@ -13,7 +13,7 @@ import type {
} from './account.constants';

// See: kobo/apps/accounts/forms.py (KoboSignupMixin)
const ORGANIZATION_TYPE_SELECT_OPTIONS = [
export const ORGANIZATION_TYPE_SELECT_OPTIONS = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's a bit off to have this exported from "accountFieldsEditor", maybe we should move this const somewhere else more directed to organizations?

}

/**
* A `TextBox` wrapper componet for `OrganizationSettingsRoute` that makes code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Suggested change
* A `TextBox` wrapper componet for `OrganizationSettingsRoute` that makes code
* A `TextBox` wrapper component for `OrganizationSettingsRoute` that makes code

);
const mmoLabelLowercase = mmoLabel.toLowerCase();

if (!orgQuery.data) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should use the loading flag instead.

Suggested change
if (!orgQuery.data) {
if (orgQuery.data.isLoading) {

required
onChange={onChange}
disabled={!onChange || isDisabled}
errors={validateValue ? validateValue(value) : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

the logic here seems to be reversed, or the naming may be confusing.

validateValue seems like it should return true if the field is valid.

Maybe we could just have the same errors prop as boolean being set in the parent and passed through?

export default function OrganizationSettingsRoute() {
const orgQuery = useOrganizationQuery();
const [subscriptions] = useState(() => subscriptionStore);
const [state, setState] = useState<State>({name: ''});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really a fan of this pattern of having an object in state.
Usually when that's the case it's common to use useReducer, but in this case, just for a few fields I'd go with multiple states.

isDisabled={!isUserAdminOrOwner || isPendingOrgPatch}
/>

{isStripeEnabled && state.website && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, who doesn't have the website filled in yet, the field is not displayed for editing. Is this on purpose?
Same thing for the type

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.

3 participants