Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Feature/session provider#16

Merged
maidbarion merged 1 commit into
masterfrom
feature/session-provider
Aug 3, 2020
Merged

Feature/session provider#16
maidbarion merged 1 commit into
masterfrom
feature/session-provider

Conversation

@maidbarion

Copy link
Copy Markdown
Contributor

Hey Jack, just raising a draft PR for feedback like last time. Testing to follow, just wanting some feedback while you're still in the office.

@ajacksified ajacksified left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Just a couple comments - remove src/components/dashboard, and restore the login and logout button stories.

Comment thread src/components/dashboard/index.tsx Outdated
import React, { ReactElement } from "react";
import { Button } from "@material-ui/core";
import LoginButton from "../src/logIn";
import React from "react";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These stories should still exist separately so that a user can see the documentation for login/logout buttons.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additionally, this code - because it's documentation-specific, not a component any user would actually use - should live in the SeessionProvider story.

Comment thread src/components/logIn/index.tsx Outdated
setSessionRequestInProgress(false);
onLogin();
} catch (error) {
onError(error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

setSessionRequestInProgress(false) should also be called if an error occurs.

Comment thread src/index.ts Outdated
export default {
LoginButton,
LogoutButton,
SessionContext,

@andydavison andydavison Jul 24, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm guessing this file is the list of 'public' stuff for the module/sdk? In which case, we want the SessionProvider/useSession in here (dunno about the SessionContext)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

cool, removed context and added the provider and hook

<BodyType>{sessionRequestText}</BodyType>
</div>
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this can stay here for now (file's not too long, and makes it easier to see the full picture in one file), but one for a discussion at some point I think — we might want to set up a common folder in /stories for this sort of demo component, or give each story it's own folder where these can live

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I think it will be a bit cleaner splittling it into a different folder. Will leave it for now, but a discussion to be had later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that this is a very specific component used to show how useSession is used, so sharing isn't necessarily useful. Additionally, in order for the documentation to be useful, we need the source displayed, and keeping the definition in a separate file makes that more difficult (if Storybook can even handle it.)

Each component should have a story with minimal "noise"; that is to say, add just enough code to show all possible configurations for the component you're documenting, and not anything more. In this case, as per my comments above, you should remove the styling, onLogin, onError, etc - this is meant to show SessionProvider, not how to inject JSS into headings.

@maidbarion maidbarion marked this pull request as ready for review July 24, 2020 15:02
@maidbarion

Copy link
Copy Markdown
Contributor Author

Hey Jack, if you're around - could you take a look at this?

}

function Dashboard() {
const { session, sessionRequestInProgress } = useSession();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When looking at the generated documentation, this example doesn't actually show how useSession is actually getting used:

Screen Shot 2020-07-24 at 12 30 52 PM

I think you should minimize the extra code so that the focus is on the SessionProvider:

  • Get rid of the onLogin / onError functions
  • Get rid of the styling

Additionally, we may need to replace @storybook/addon-docs with @storybook/addon-storysource in order to display the actual source code, so that the Dashboard function- which is what developers are likely most interested in- is displayed in the documentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey Jack, Iatest version has the syling removed and I've replaced addon-docs with addon-storysource. I noticed in the docs, that the actions pane isn't being utilised at the moment - will this be required for other components, or should we remove it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it could be useful for onLogin, onLogout, onSave, and onError - not sure yet. I'd leave it for now. We can remove it later if we don't end up using it.

<BodyType>{sessionRequestText}</BodyType>
</div>
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that this is a very specific component used to show how useSession is used, so sharing isn't necessarily useful. Additionally, in order for the documentation to be useful, we need the source displayed, and keeping the definition in a separate file makes that more difficult (if Storybook can even handle it.)

Each component should have a story with minimal "noise"; that is to say, add just enough code to show all possible configurations for the component you're documenting, and not anything more. In this case, as per my comments above, you should remove the styling, onLogin, onError, etc - this is meant to show SessionProvider, not how to inject JSS into headings.

Comment thread stories/3-SessionProvider.stories.tsx Outdated
<SessionProvider>
<LoginButton
popupUrl="./popup.html"
onLogin={() => console.log("On Login")}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

onlogin / onlogout should be removed from the SessionProvider story.

@vercel

vercel Bot commented Jul 29, 2020

Copy link
Copy Markdown

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

Comment thread src/logOut/index.test.tsx
@@ -1,83 +0,0 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why were these tests deleted?

@andydavison

Copy link
Copy Markdown
Contributor

@maidbarion one quick thing — I think we mentioned in passing in a chat, but I don't know if it makes sense to number the story files for the components e.g. stories/3-SessionProvider.stories.tsx could just be stories/SessionProvider.stories.tsx.

Just alphabetical would make it easier to find things and we don't have to worry about editing all the other file names to put something in a specific place.

@ajacksified ajacksified force-pushed the feature/session-provider branch from e7f3322 to c55a695 Compare August 3, 2020 14:58
@maidbarion maidbarion merged commit 0dd7b5c into master Aug 3, 2020
ajacksified pushed a commit that referenced this pull request Aug 4, 2020
Co-authored-by: Aaron James Madden <aaronjamesmadden@Aarons-MacBook-Pro.local>
@maidbarion maidbarion deleted the feature/session-provider branch August 12, 2020 12:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants