- Notifications
You must be signed in to change notification settings - Fork1k
feat: add storybook for /deployment/appearance page#5582
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
5 commits Select commitHold shift + click to select a range
784e274
wip
jsjoeioe0946ce
wip: move appearancesettingspage
jsjoeio8da6899
refactor: separate page and view ApperanceSettings
jsjoeio9f2f9a5
refactor: create storybook from AppearanceSettingsView
jsjoeio1c9deaa
fixup: formatting and types
jsjoeioFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletionssite/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useActor } from "@xstate/react" | ||
import { FeatureNames } from "api/types" | ||
import { AppearanceConfig } from "api/typesGenerated" | ||
import React, { useContext } from "react" | ||
import { Helmet } from "react-helmet-async" | ||
import { pageTitle } from "util/page" | ||
import { XServiceContext } from "xServices/StateContext" | ||
import { AppearanceSettingsPageView } from "./AppearanceSettingsPageView" | ||
// ServiceBanner is unlike the other Deployment Settings pages because it | ||
// implements a form, whereas the others are read-only. We make this | ||
// exception because the Service Banner is visual, and configuring it from | ||
// the command line would be a significantly worse user experience. | ||
const AppearanceSettingsPage: React.FC = () => { | ||
const xServices = useContext(XServiceContext) | ||
const [appearanceXService, appearanceSend] = useActor( | ||
xServices.appearanceXService, | ||
) | ||
const [entitlementsState] = useActor(xServices.entitlementsXService) | ||
const appearance = appearanceXService.context.appearance | ||
const isEntitled = | ||
entitlementsState.context.entitlements.features[FeatureNames.Appearance] | ||
.entitlement !== "not_entitled" | ||
const updateAppearance = ( | ||
newConfig: Partial<AppearanceConfig>, | ||
preview: boolean, | ||
) => { | ||
const newAppearance = { | ||
...appearance, | ||
...newConfig, | ||
} | ||
if (preview) { | ||
appearanceSend({ | ||
type: "SET_PREVIEW_APPEARANCE", | ||
appearance: newAppearance, | ||
}) | ||
return | ||
} | ||
appearanceSend({ | ||
type: "SET_APPEARANCE", | ||
appearance: newAppearance, | ||
}) | ||
} | ||
return ( | ||
<> | ||
<Helmet> | ||
<title>{pageTitle("Appearance Settings")}</title> | ||
</Helmet> | ||
<AppearanceSettingsPageView | ||
appearance={appearance} | ||
isEntitled={isEntitled} | ||
updateAppearance={updateAppearance} | ||
/> | ||
</> | ||
) | ||
} | ||
export default AppearanceSettingsPage |
35 changes: 35 additions & 0 deletions...rc/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ComponentMeta, Story } from "@storybook/react" | ||
import { | ||
AppearanceSettingsPageView, | ||
AppearanceSettingsPageViewProps, | ||
} from "./AppearanceSettingsPageView" | ||
export default { | ||
title: "pages/AppearanceSettingsPageView", | ||
component: AppearanceSettingsPageView, | ||
argTypes: { | ||
appearance: { | ||
defaultValue: { | ||
logo_url: "https://github.com/coder.png", | ||
service_banner: { | ||
enabled: true, | ||
message: "hello world", | ||
background_color: "white", | ||
}, | ||
}, | ||
}, | ||
isEntitled: { | ||
defaultValue: false, | ||
}, | ||
updateAppearance: { | ||
defaultValue: () => { | ||
return undefined | ||
}, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof AppearanceSettingsPageView> | ||
const Template: Story<AppearanceSettingsPageViewProps> = (args) => ( | ||
<AppearanceSettingsPageView {...args} /> | ||
) | ||
export const Page = Template.bind({}) |
93 changes: 28 additions & 65 deletions...oySettingsPage/AppearanceSettingsPage.tsx → ...ttingsPage/AppearanceSettingsPageView.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.