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

fix: Repo create provider select error #354

Merged
merged 2 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Base/Select/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class Select extends React.Component {

return (
<div className={styles.control} onClick={this.handleControlClick}>
<div className={styles.controlLabel}>{value}</div>
<div className={styles.controlLabel}>{this.currentLabel}</div>
<Icon name={isOpen && !disabled ? 'caret-up' : 'caret-down'} type="dark" />
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Admin/Apps/Deploy/Cell/YamlCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ export default class YamlCell extends PureComponent {
render() {
const { name, value, className } = this.props;
const isRadio = typeof value === 'boolean';

const showName = name.replace(/>>>/g, '.');
if (value === null) {
return null;
}

return (
<div className={classNames(styles.cell, className)}>
<label className={classNames(styles.name, styles.inputName)} title={name}>
{name}
<label className={classNames(styles.name, styles.inputName)} title={showName}>
{showName}
</label>

{!isRadio && (
Expand Down
1 change: 0 additions & 1 deletion src/pages/Admin/Repos/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default class Repos extends Component {
const { repoStore } = this.props;
const { jobs } = repoStore;
const repoIds = repoStore.repos.map(repo => repo.repo_id);
console.log(repoIds);

const status = _.pick(values, ['status', 'transition_status']);
const logJobs = () => repoStore.info(`${op}: ${rid}, ${JSON.stringify(status)}`);
Expand Down
1 change: 0 additions & 1 deletion src/pages/Admin/Users/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export default class Detail extends Component {
break;
case 'Repos':
repoStore.userId = userId;
console.log('Repos', userId);
await repoStore.fetchAll();
break;
}
Expand Down
11 changes: 7 additions & 4 deletions src/stores/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export default class AppDeployStore extends Store {
@action
changeRuntime = async runtimeId => {
this.runtimeId = runtimeId;
await this.fetchSubnets(runtimeId);

if (!this.isKubernetes) {
await this.fetchSubnets(runtimeId);
}
};

@action
Expand All @@ -88,21 +91,21 @@ export default class AppDeployStore extends Store {

if (this.isKubernetes) {
const yamlObj = unflattenObject(this.yamlObj);
yamlObj.name = this.name;
yamlObj.Name = this.name; // ymal config api need Name
conf = yaml.safeDump(yamlObj);
} else {
this.getConfigData();
conf = JSON.stringify(this.configData);
}

if (this.checkResult === 'ok') {
//fix config key contains '.'
let params = {
app_id: this.appId,
version_id: this.versionId,
runtime_id: this.runtimeId,
conf: conf
conf: conf.replace(/>>>/g, '.')
};

const res = await this.create(params);

if (!res.err && _.get(this.appDeployed, 'cluster_id')) {
Expand Down
17 changes: 10 additions & 7 deletions src/stores/repo/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class RepoCreateStore extends Store {
const len = providers.length;
if (len > 1 && providers.includes('kubernetes')) {
providers = providers.filter(data => data !== 'kubernetes');
return this.info("Kubernetes can't be selected with others");
this.info("Kubernetes can't be selected with others");
}
this.providers = providers;
};
Expand Down Expand Up @@ -136,7 +136,10 @@ export default class RepoCreateStore extends Store {
};

toQueryString(items) {
return items.map(item => [item.label_key, item.label_value].join('=')).join('&');
return items
.filter(label => label.label_key)
.map(item => [item.label_key, item.label_value].join('='))
.join('&');
}

@action
Expand Down Expand Up @@ -202,19 +205,19 @@ export default class RepoCreateStore extends Store {
data.credential = '{}';
}

// fixme: both labels and selectors pass as query string
data.selectors = selectors.map(selector => ({
// fixme: both labels and selectors pass as queryString
/* data.selectors = selectors.map(selector => ({
selector_key: selector.label_key,
selector_value: selector.label_value
}));

data.labels = labels.map(label => ({
label_key: label.label_key,
label_value: label.label_value
}));
}));*/

// data.selectors = this.toQueryString(selectors);
// data.labels = this.toQueryString(labels);
data.selectors = this.toQueryString(selectors);
data.labels = this.toQueryString(labels);

// fix: provider is mobx array
let flatProviders = providers.toJSON();
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function flattenObject(obj) {
cur.forEach((item, index) => recurse(item, `${prop}[${index}]`));
} else {
Object.entries(cur).forEach(([key, value]) => {
key = key.replace(/\./g, '>>>'); //fix key contains '.'
recurse(value, prop ? `${prop}.${key}` : key);
});
}
Expand Down