Permalink
Browse files

feat(Recipes): Add `hasHostedOption` to enable hosted & self hosted s…

…ervices
  • Loading branch information...
adlk committed Dec 15, 2017
1 parent 873957d commit 03610f2dd6833b3b6358790d044b852c154b4bf3
@@ -47,6 +47,10 @@ const messages = defineMessages({
id: 'settings.service.form.tabOnPremise',
defaultMessage: '!!!Self hosted ⭐️',
},
useHostedService: {
id: 'settings.service.form.useHostedService',
defaultMessage: '!!!Use the hosted {name} service.',
},
customUrlValidationError: {
id: 'settings.service.form.customUrlValidationError',
defaultMessage: '!!!Could not validate custom {name} server.',
@@ -108,7 +112,6 @@ export default class EditServiceForm extends Component {
this.props.form.submit({
onSuccess: async (form) => {
const values = form.values();
let isValid = true;
if (recipe.validateUrl && values.customUrl) {
@@ -166,6 +169,13 @@ export default class EditServiceForm extends Component {
/>
);
let activeTabIndex = 0;
if (recipe.hasHostedOption && service.team) {
activeTabIndex = 1;
} else if (recipe.hasHostedOption && service.customUrl) {
activeTabIndex = 2;
}
return (
<div className="settings__main">
<div className="settings__header">
@@ -198,8 +208,13 @@ export default class EditServiceForm extends Component {
<Input field={form.$('name')} focus />
{(recipe.hasTeamId || recipe.hasCustomUrl) && (
<Tabs
active={service.customUrl ? 1 : 0}
active={activeTabIndex}
>
{recipe.hasHostedOption && (
<TabItem title={recipe.name}>
{intl.formatMessage(messages.useHostedService, { name: recipe.name })}
</TabItem>
)}
{recipe.hasTeamId && (
<TabItem title={intl.formatMessage(messages.tabHosted)}>
<Input
@@ -118,11 +118,22 @@ export default class EditServiceScreen extends Component {
});
}
// More fine grained and use case specific validation rules
if (recipe.hasTeamId && recipe.hasCustomUrl) {
config.fields.team.validate = [oneRequired(['team', 'customUrl'])];
config.fields.customUrl.validate = [url, oneRequired(['team', 'customUrl'])];
}
// If a service can be hosted and has a teamId or customUrl
if (recipe.hasHostedOption && (recipe.hasTeamId || recipe.hasCustomUrl)) {
if (config.fields.team) {
config.fields.team.validate = [];
}
if (config.fields.customUrl) {
config.fields.customUrl.validate = [url];
}
}
if (recipe.hasIndirectMessages) {
Object.assign(config.fields, {
isIndirectMessageBadgeEnabled: {
@@ -15,6 +15,7 @@ export default class Recipe {
hasTeamId = false;
hasPredefinedUrl = false;
hasCustomUrl = false;
hasHostedOption = false;
urlInputPrefix = '';
urlInputSuffix = '';
@@ -45,6 +46,7 @@ export default class Recipe {
this.hasTeamId = data.config.hasTeamId || this.hasTeamId;
this.hasPredefinedUrl = data.config.hasPredefinedUrl || this.hasPredefinedUrl;
this.hasCustomUrl = data.config.hasCustomUrl || this.hasCustomUrl;
this.hasHostedOption = data.config.hasHostedOption || this.hasHostedOption;
this.urlInputPrefix = data.config.urlInputPrefix || this.urlInputPrefix;
this.urlInputSuffix = data.config.urlInputSuffix || this.urlInputSuffix;
@@ -12,15 +12,17 @@
flex: 1;
// border: 1px solid $theme-gray-lightest;
color: $theme-gray-dark;
background: $theme-gray-lightest;
border-bottom: 1px solid $theme-gray-lighter;
box-shadow: inset 0px -3px 10px rgba(black, 0.05);
transition: all $theme-transition-time;
background: linear-gradient($theme-gray-lightest 80%, darken($theme-gray-lightest, 3%));
border-right: 1px solid $theme-gray-lighter;
transition: background $theme-transition-time;
&:last-of-type {
border-right: 0;
}
&.is-active {
background: $theme-brand-primary;
color: #FFF;
border-bottom: 1px solid $theme-brand-primary;
box-shadow: none;
}
}
@@ -47,6 +47,10 @@
padding: 8px;
// font-size: 18px;
color: $theme-gray;
&::placeholder {
color: lighten($theme-gray-light, 10%);
}
}
.franz-form__input-prefix,

0 comments on commit 03610f2

Please sign in to comment.