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

feat: add initial value for JSON configuration #2708

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const CreatePublishTarget = props => {

const updateType = (e, type) => {
setTargetType(type.key);
// update configuration
const current = props.targetTypes.find(item => item.key);
current.configuration ? setConfig(current.configuration) : setConfig({});
};
const updateConfig = newConfig => {
setConfig(newConfig);
Expand Down Expand Up @@ -77,7 +80,7 @@ export const CreatePublishTarget = props => {
onChange={updateType}
/>
<div css={label}>{formatMessage('Paste Configuration')}</div>
<JsonEditor onChange={updateConfig} height={200} value={config} />
<JsonEditor key={targetType} onChange={updateConfig} height={200} value={config} />
</form>
<DialogFooter>
<DefaultButton onClick={props.closeDialog} text={formatMessage('Cancel')} />
Expand Down
6 changes: 3 additions & 3 deletions Composer/packages/client/src/pages/publish/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const Publish: React.FC<PublishPageProps> = props => {
actions.getPublishHistory(projectId, _selected);
}
}
}, [settings.publishTargets, selectedTargetName]);
}, [projectId, selectedTargetName]);

// once history is loaded, display it
useEffect(() => {
Expand Down Expand Up @@ -265,7 +265,7 @@ const Publish: React.FC<PublishPageProps> = props => {
children: (
<CreatePublishTarget
targetTypes={publishTypes.map(type => {
return { key: type.name, text: type.name };
return { key: type.name, text: type.name, configuration: type.configuration };
})}
targets={settings.publishTargets}
updateSettings={savePublishTarget}
Expand All @@ -283,7 +283,7 @@ const Publish: React.FC<PublishPageProps> = props => {
children: (
<CreatePublishTarget
targetTypes={publishTypes.map(type => {
return { key: type.name, text: type.name };
return { key: type.name, text: type.name, configuration: type.configuration };
})}
current={editTarget ? editTarget.item : null}
targets={settings.publishTargets?.filter(item => editTarget && item.name != editTarget.item.name)}
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/client/src/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface PublishType {
rollback: boolean;
status: boolean;
};
configuration: any;
}

export interface PublishTarget {
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/server/src/controllers/publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const PublishController = {
status: pluginLoader.extensions.publish[i].methods.getStatus ? true : false,
rollback: pluginLoader.extensions.publish[i].methods.rollback ? true : false,
},
configuration: pluginLoader.extensions.publish[i].methods.configuration || {},
};
})
);
Expand Down
4 changes: 4 additions & 0 deletions Composer/plugins/mockRemotePublish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class LocalPublisher {
};
}
};

configuration = {
clientId: '<please input client id>',
};
}

const publisher = new LocalPublisher();
Expand Down
2 changes: 0 additions & 2 deletions Composer/plugins/mockRemotePublish/src/interface.ts

This file was deleted.