Skip to content

Commit

Permalink
feat: 수정사항 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
westofsky committed Aug 28, 2024
1 parent f03ff8a commit 3c7cd3b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 64 deletions.
2 changes: 1 addition & 1 deletion dist/swagger-ui-bundle.js

Large diffs are not rendered by default.

90 changes: 45 additions & 45 deletions src/core/components/operation-summary.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { PureComponent } from "react"
import PropTypes from "prop-types"
import { Iterable, List } from "immutable"
import ImPropTypes from "react-immutable-proptypes"
import toString from "lodash/toString"
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
import { Iterable, List } from "immutable";
import ImPropTypes from "react-immutable-proptypes";
import toString from "lodash/toString";

export default class OperationSummary extends PureComponent {
static propTypes = {
Expand All @@ -14,40 +14,43 @@ export default class OperationSummary extends PureComponent {
getConfigs: PropTypes.func.isRequired,
authActions: PropTypes.object,
authSelectors: PropTypes.object,
//swaggy-swagger
isChanged: PropTypes.bool.isRequired,
isChanged: PropTypes.bool,
changedTypes: PropTypes.array
}
};

static defaultProps = {
operationProps: null,
specPath: List(),
summary: ""
}
summary: "",
};

constructor(props) {
super(props)
super(props);
this.state = {
isChanged: this.props.isChanged,
}
};
}

handleComponentClick = () => {
this.setState({ isChanged: false })
}
this.setState({ isChanged: false });
};

handleToggle = () => {
this.setState({ isChanged: false }, () => {
this.props.toggleShown();
});
};

render() {
let {
isShown,
toggleShown,
getComponent,
authActions,
authSelectors,
operationProps,
specPath,
//swaggy-swagger
changedTypes
} = this.props
changedTypes,
} = this.props;

let {
summary,
Expand All @@ -58,53 +61,49 @@ export default class OperationSummary extends PureComponent {
path,
operationId,
originalOperationId,
displayOperationId,
} = operationProps.toJS()
displayOperationId
} = operationProps.toJS();

let {
summary: resolvedSummary,
} = op

let security = operationProps.get("security")
let resolvedSummary = op.summary;

const AuthorizeOperationBtn = getComponent("authorizeOperationBtn", true)
const OperationSummaryMethod = getComponent("OperationSummaryMethod")
const OperationSummaryPath = getComponent("OperationSummaryPath")
const JumpToPath = getComponent("JumpToPath", true)
const CopyToClipboardBtn = getComponent("CopyToClipboardBtn", true)
const ArrowUpIcon = getComponent("ArrowUpIcon")
const ArrowDownIcon = getComponent("ArrowDownIcon")
let security = operationProps.get("security");
const AuthorizeOperationBtn = getComponent("authorizeOperationBtn", true);
const OperationSummaryMethod = getComponent("OperationSummaryMethod");
const OperationSummaryPath = getComponent("OperationSummaryPath");
const JumpToPath = getComponent("JumpToPath", true);
const CopyToClipboardBtn = getComponent("CopyToClipboardBtn", true);
const ArrowUpIcon = getComponent("ArrowUpIcon");
const ArrowDownIcon = getComponent("ArrowDownIcon");

const hasSecurity = security && !!security.count()
const securityIsOptional = hasSecurity && security.size === 1 && security.first().isEmpty()
const allowAnonymous = !hasSecurity || securityIsOptional
const hasSecurity = security && !!security.count();
const securityIsOptional = hasSecurity && security.size === 1 && security.first().isEmpty();
const allowAnonymous = !hasSecurity || securityIsOptional;

return (
<div className={`opblock-summary opblock-summary-${method}`} onClick={this.handleComponentClick}>
<button
aria-expanded={isShown}
className="opblock-summary-control"
onClick={toggleShown}
onClick={this.handleToggle}
>
<OperationSummaryMethod method={method}/>
<div className="opblock-summary-path-description-wrapper">
<OperationSummaryPath getComponent={getComponent} operationProps={operationProps} specPath={specPath} />
{!showSummary ? null :
{showSummary &&
<div className="opblock-summary-description">
{toString(resolvedSummary || summary)}
</div>
}
</div>
{displayOperationId && (originalOperationId || operationId) ? <span className="opblock-summary-operation-id">{originalOperationId || operationId}</span> : null}
</button>

<CopyToClipboardBtn textToCopy={`${specPath.get(1)}`} />
{this.state.isChanged &&
<div className="changed-box">
<div className="is-changed">
<div className="types-item-tooltip">
{Array.isArray(changedTypes) &&
changedTypes.map((type) => `${type} is changed`).join('\n')}
{changedTypes && changedTypes.map((type) => `${type} is changed`).join('\n')}
</div>
</div>
</div>
Expand All @@ -114,21 +113,22 @@ export default class OperationSummary extends PureComponent {
<AuthorizeOperationBtn
isAuthorized={isAuthorized}
onClick={() => {
const applicableDefinitions = authSelectors.definitionsForRequirements(security)
authActions.showDefinitions(applicableDefinitions)
const applicableDefinitions = authSelectors.definitionsForRequirements(security);
authActions.showDefinitions(applicableDefinitions);
}}
/>
}
<JumpToPath path={specPath} />{/* TODO: use wrapComponents here, swagger-ui doesn't care about jumpToPath */}
<JumpToPath path={specPath} />
<button
aria-label={`${method} ${path.replace(/\//g, "\u200b/")}`}
className="opblock-control-arrow"
aria-expanded={isShown}
tabIndex="-1"
onClick={toggleShown}>
onClick={this.handleToggle}
>
{isShown ? <ArrowUpIcon className="arrow" /> : <ArrowDownIcon className="arrow" />}
</button>
</div>
)
);
}
}
19 changes: 9 additions & 10 deletions src/core/components/operation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ export default class Operation extends PureComponent {
summary: PropTypes.string,
response: PropTypes.instanceOf(Iterable),
request: PropTypes.instanceOf(Iterable),

toggleShown: PropTypes.func.isRequired,
onTryoutClick: PropTypes.func.isRequired,
onResetClick: PropTypes.func.isRequired,
onCancelClick: PropTypes.func.isRequired,
onExecute: PropTypes.func.isRequired,

getComponent: PropTypes.func.isRequired,
getConfigs: PropTypes.func.isRequired,
authActions: PropTypes.object,
Expand Down Expand Up @@ -76,21 +74,24 @@ export default class Operation extends PureComponent {
allowTryItOut,
displayRequestDuration,
tryItOutEnabled,
executeInProgress
executeInProgress,
// 추가된 부분: isChanged 및 changedTypes 전달
isChanged,
changedTypes
} = operationProps.toJS()

let {
description,
externalDocs,
schemes
} = op

const externalDocsUrl = externalDocs ? safeBuildUrl(externalDocs.url, specSelectors.url(), { selectedServer: oas3Selectors.selectedServer() }) : ""
let operation = operationProps.getIn(["op"])
let responses = operation.get("responses")
let parameters = getList(operation, ["parameters"])
let changedTypes = getList(operation, ["changedTypes"])
let isChanged = operation.get("isChanged");
let changedTypesList = getList(operation, ["changedTypes"])
let isChangedOperation = operation.get("isChanged")
let operationScheme = specSelectors.operationScheme(path, method)
let isShownKey = ["operations", tag, operationId]
let extensions = getExtensions(operation)
Expand All @@ -116,12 +117,11 @@ export default class Operation extends PureComponent {
}

let onChangeKey = [ path, method ]

const validationErrors = specSelectors.validationErrors([path, method])
console.log(isChanged);

return (
<div className={deprecated ? "opblock opblock-deprecated" : isShown ? `opblock opblock-${method} is-open` : `opblock opblock-${method}`} id={escapeDeepLinkPath(isShownKey.join("-"))} >
<OperationSummary operationProps={operationProps} isShown={isShown} toggleShown={toggleShown} getComponent={getComponent} authActions={authActions} authSelectors={authSelectors} specPath={specPath} isChanged = {isChanged} changedTypes = {changedTypes} />
<OperationSummary operationProps={operationProps} isShown={isShown} toggleShown={toggleShown} getComponent={getComponent} authActions={authActions} authSelectors={authSelectors} specPath={specPath} isChanged={isChanged} changedTypes={changedTypes} />
<Collapse isOpened={isShown}>
<div className="opblock-body">
<div className="description-wrapper">
Expand Down Expand Up @@ -165,7 +165,6 @@ export default class Operation extends PureComponent {
onCancelClick = { onCancelClick }
tryItOutEnabled = { tryItOutEnabled }
allowTryItOut={allowTryItOut}

fn={fn}
getComponent={ getComponent }
specActions={ specActions }
Expand Down
24 changes: 16 additions & 8 deletions src/core/containers/OperationContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export default class OperationContainer extends PureComponent {
props.specSelectors.allowTryItOutFor(props.path, props.method) : props.allowTryItOut)
const security = op.getIn(["operation", "security"]) || props.specSelectors.security()

// 추가된 부분: isChanged 및 changedTypes 가져오기
const changedTypes = op.getIn(["operation", "changedTypes"]) || []
const isChanged = op.getIn(["operation", "isChanged"]) || false

return {
operationId,
isDeepLinkingEnabled: deepLinking,
Expand All @@ -77,7 +81,10 @@ export default class OperationContainer extends PureComponent {
isShown: layoutSelectors.isShown(isShownKey, docExpansion === "full" ),
jumpToKey: `paths.${props.path}.${props.method}`,
response: props.specSelectors.responseFor(props.path, props.method),
request: props.specSelectors.requestFor(props.path, props.method)
request: props.specSelectors.requestFor(props.path, props.method),
// 추가된 부분: isChanged 및 changedTypes 전달
isChanged,
changedTypes
}
}

Expand Down Expand Up @@ -105,10 +112,8 @@ export default class OperationContainer extends PureComponent {

toggleShown =() => {
let { layoutActions, tag, operationId, isShown } = this.props
// pet, store, user ...
const resolvedSubtree = this.getResolvedSubtree()
if(!isShown && resolvedSubtree === undefined) {
// transitioning from collapsed to expanded
this.requestResolvedSubtree()
}
layoutActions.show(["operations", tag, operationId], !isShown)
Expand Down Expand Up @@ -154,7 +159,6 @@ export default class OperationContainer extends PureComponent {
specPath
} = this.props


if(specPath) {
return specActions.requestResolvedSubtree(specPath.toJS())
}
Expand Down Expand Up @@ -191,7 +195,10 @@ export default class OperationContainer extends PureComponent {
authSelectors,
oas3Actions,
oas3Selectors,
fn
fn,
// 추가된 부분: isChanged 및 changedTypes 전달
isChanged,
changedTypes
} = this.props

const Operation = getComponent( "operation" )
Expand All @@ -218,7 +225,10 @@ export default class OperationContainer extends PureComponent {
displayRequestDuration,
isDeepLinkingEnabled,
executeInProgress: this.state.executeInProgress,
tryItOutEnabled: this.state.tryItOutEnabled
tryItOutEnabled: this.state.tryItOutEnabled,
// 추가된 부분: isChanged 및 changedTypes 전달
isChanged,
changedTypes
})

return (
Expand All @@ -227,14 +237,12 @@ export default class OperationContainer extends PureComponent {
response={response}
request={request}
isShown={isShown}

toggleShown={this.toggleShown}
onTryoutClick={this.onTryoutClick}
onResetClick={this.onResetClick}
onCancelClick={this.onCancelClick}
onExecute={this.onExecute}
specPath={specPath}

specActions={ specActions }
specSelectors={ specSelectors }
oas3Actions={oas3Actions}
Expand Down

0 comments on commit 3c7cd3b

Please sign in to comment.