Skip to content

Commit

Permalink
fix: Repo create provider select error (#354)
Browse files Browse the repository at this point in the history
* fix: Repo create provider select

fix: Deploy app config format error

* fix: Remove console info
  • Loading branch information
whDongRui authored Sep 13, 2018
1 parent c5f2e81 commit 5e6b6d1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
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

0 comments on commit 5e6b6d1

Please sign in to comment.