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

Change groups at topbar home icon #2072

Merged
merged 25 commits into from Aug 11, 2020
Merged

Conversation

brnsolikyl
Copy link
Contributor

Closes #1746

What does this PR do?

Adds a group switcher to the topbar home icon

Links to related issues

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • joined chat.foodsaving.world/channel/karrot-dev
  • added an entry to CHANGELOG.md (description, pull request link, username(s))

@brnsolikyl
Copy link
Contributor Author

Oh, two details that need fixing:
1 - Groups that do not have an image are not aligned with those that have. Still not sure how to fix it.
2 - How to do about inactive groups? They're probably still showing and we do not want them to show there, right?

@tiltec
Copy link
Member

tiltec commented May 26, 2020

To align groups without image, you could add a placeholder div with fixed size.

I'm not concerned about listing inactive groups - show them if the users is still member (they get removed anyways after 7 months of inactivity)

What about users that have only one group? I think the Karrot logo was a nice way to get back to the group home page. Of course, they could also use the sidenav menu to achieve the same.

I just thought of having a dropdown-type of thing next to the Karrot/group logo - it would always show your current group (replacing that part of the breadcrumb). When you click on it, jump to group home page. When you click the dropdown-arrow on the right, show the group menu. What do you think about this?

src/locales/locale-en.json Outdated Show resolved Hide resolved
@tiltec
Copy link
Member

tiltec commented Jun 6, 2020

The snapshots seem to diverge a lot from master - your packages might be out of date. To refresh them:

git checkout master -- src/__snapshots__/storyshots.spec.js.snap
git merge master
yarn
yarn test -u storyshots

One "story" also needs updating; you might have noticed the warning [vuex] unknown getter: groups/mine when updating the snapshots. To fix it, open Layout.story.js and add another mock getter in createDatastore:

From

groups: { getters: { all: () => groupsMock } },

to

groups: { getters: {
    all: () => groupsMock,
    mine: () => groupsMock,
  } },

@brnsolikyl
Copy link
Contributor Author

Thank you for the review, Tilmann! I believe the things you pointed out are fixed. However, I just noticed a little unexpected behavior that needs fixing also before merging. When going to the group gallery, all of groups in which the user's application is pending are appended to the list of groups on the topbar.

@tiltec
Copy link
Member

tiltec commented Jun 14, 2020

However, I just noticed a little unexpected behavior that needs fixing also before merging. When going to the group gallery, all of groups in which the user's application is pending are appended to the list of groups on the topbar.

Seems they should either be always there or never, regardless if the user visited the group gallery. It just affects the people that have an application pending, so it may not be many on production sites.

Which solution would you prefer? Hide groups for which applications are pending?

@tiltec
Copy link
Member

tiltec commented Jun 14, 2020

By the way, the linter wants some more newlines in the code I gave you, have a look at this:

/root/repo/src/topbar/components/Layout.story.js
   9:11  error  Expected a line break after this opening brace   object-curly-newline
  12:5   error  Expected a line break before this closing brace  object-curly-newline

@brnsolikyl
Copy link
Contributor Author

Probably not the most elegant solution, but everything seems to work now! You're welcome to change nonetheless. I'm just glad I made it work, but I can learn from other approaches.

Copy link
Member

@nicksellen nicksellen left a comment

Choose a reason for hiding this comment

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

Looks good! I wrote a few minor code style points, also needs the storyshot tests updating (yarn test -u) and the linting fixing (yarn fix).

@@ -41,6 +41,7 @@ export default {
return Object.values(state.entries).map(getters.enrich)
},
mine: (state, getters) => getters.all.filter(e => isMyGroup(e)).sort(applicationsFirstThenSortByName),
isMemberGroups: (state, getters) => getters.all.filter(e => isMemberGroup(e)).sort(applicationsFirstThenSortByName),
Copy link
Member

Choose a reason for hiding this comment

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

Minor: you can simplify this:

.filter(e => isMemberGroup(e))

to this:

.filter(isMemberGroup)

Because e => isMemberGroup(e) is just a function that takes one argument (e) and calls one function (isMemberGroup), that's also the same as just the reference to the function isMemberGroup itself...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it! I copied the line above, (e => isMyGroup(e)), so I changed both getters now to this simplified reference to the function

@@ -41,6 +41,7 @@ export default {
return Object.values(state.entries).map(getters.enrich)
},
mine: (state, getters) => getters.all.filter(e => isMyGroup(e)).sort(applicationsFirstThenSortByName),
isMemberGroups: (state, getters) => getters.all.filter(e => isMemberGroup(e)).sort(applicationsFirstThenSortByName),
Copy link
Member

Choose a reason for hiding this comment

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

Also minor.

I find the name isMemberGroups confusing, as normally something starting with is will return a boolean value (e.g. the isMemberGroup function).

I would probably call it mineWithoutApplications ... or maybe call it mine and rename the existing mine to be mineWithApplications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went for mine and mineWithApplications. Hopefully I managed to change it wherever it is referenced. Nothing seems to be broken

src/topbar/components/KTopbarUI.vue Outdated Show resolved Hide resolved
@nicksellen
Copy link
Member

Great work 👍 ... just the snapshot tests failing still... yarn test -u will fix it, then commit the src/__snapshots__ directory :) Then go for a merge!

@nicksellen
Copy link
Member

I merged master into it (rebase had conflicts) and updated the snapshots :)

@nicksellen nicksellen merged commit 2730891 into master Aug 11, 2020
@brnsolikyl brnsolikyl deleted the change-groups-at-topbar-home-icon branch December 10, 2020 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it easier to switch between groups
3 participants