Skip to content

Commit

Permalink
Fix "external override" bug. Resolves #26
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldenning committed Apr 22, 2020
1 parent e1df122 commit 8889eac
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/ui/import-map-overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ imo-popup a {
.imo-overrides-table tr td:first-child {
display: flex;
align-items: center;
padding-right: 32px;
position: relative;
}

.imo-needs-refresh {
position: absolute;
right: 8px;
font-size: 32px;
display: flex;
flex-direction: column;
justify-content: center;
}

.imo-needs-refresh::before {
content: "\27F2";
}

.imo-status {
Expand Down Expand Up @@ -156,6 +171,10 @@ imo-popup a {
background-color: orange;
}

.imo-next-default {
background-color: darkgoldenrod;
}

.imo-overrides-table tbody tr:hover {
cursor: pointer;
background-color: #404040;
Expand Down
39 changes: 36 additions & 3 deletions src/ui/list/list.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class List extends Component {
state = {
notOverriddenMap: { imports: {} },
currentPageMap: { imports: {} },
nextPageMap: { imports: {} },
dialogModule: null,
dialogExternalMap: null,
searchVal: "",
Expand All @@ -18,6 +19,9 @@ export default class List extends Component {
window.importMapOverrides.getCurrentPageMap().then((currentPageMap) => {
this.setState({ currentPageMap });
});
window.importMapOverrides.getNextPageMap().then((nextPageMap) => {
this.setState({ nextPageMap });
});
window.addEventListener("import-map-overrides:change", this.doUpdate);
this.inputRef.focus();
}
Expand Down Expand Up @@ -64,7 +68,8 @@ export default class List extends Component {
nextOverriddenModules = [],
disabledOverrides = [],
defaultModules = [],
externalOverrideModules = [];
externalOverrideModules = [],
pendingRefreshDefaultModules = [];

const overrideMap = window.importMapOverrides.getOverrideMap(true).imports;

Expand Down Expand Up @@ -95,6 +100,11 @@ export default class List extends Component {
this.state.currentPageMap.imports[moduleName]
) {
defaultModules.push(mod);
} else if (
this.state.notOverriddenMap.imports[moduleName] ===
this.state.nextPageMap.imports[moduleName]
) {
pendingRefreshDefaultModules.push(mod);
} else {
externalOverrideModules.push(mod);
}
Expand Down Expand Up @@ -192,7 +202,25 @@ export default class List extends Component {
>
<td>
<div className="imo-status imo-next-override" />
<div>Pending refresh</div>
<div>Inline Override</div>
<div className="imo-needs-refresh" />
</td>
<td>{mod.moduleName}</td>
<td>{toDomain(mod)}</td>
<td>{toFileName(mod)}</td>
</tr>
))}
{pendingRefreshDefaultModules.map((mod) => (
<tr
role="button"
tabIndex={0}
onClick={() => this.setState({ dialogModule: mod })}
key={mod.moduleName}
>
<td style={{ position: "relative" }}>
<div className="imo-status imo-next-default" />
<div>Default</div>
<div className="imo-needs-refresh" />
</td>
<td>{mod.moduleName}</td>
<td>{toDomain(mod)}</td>
Expand Down Expand Up @@ -350,7 +378,12 @@ export default class List extends Component {
this.setState({ dialogModule: null });
};

doUpdate = () => this.forceUpdate();
doUpdate = () => {
this.forceUpdate();
window.importMapOverrides.getNextPageMap().then((nextPageMap) => {
this.setState({ nextPageMap });
});
};

addNewModule = (name, url) => {
if (name && url) {
Expand Down

0 comments on commit 8889eac

Please sign in to comment.