componentDidMountOrUpdate()

in frontend/src/js/components/viewer/AddToWorkspaceModal.tsx [55:78]


    componentDidMountOrUpdate(prevProps?: Props, prevState?: State) {
        if ((!prevProps || this.props.resource.uri !== prevProps.resource.uri) && this.props.resource.parents.length > 0) {
            const parentUriParts = this.props.resource.parents[0].uri.split('/');
            const lastPart = parentUriParts[parentUriParts.length - 1];

            this.setState({
                saveAs: decodeURIComponent(lastPart),
            });
        }

        if (this.state.workspaceId) {
            if(prevState && prevState.workspaceId !== this.state.workspaceId) {
                this.props.getWorkspace(this.state.workspaceId);
            }
        }

        if (this.props.isOpen && !(prevProps && prevProps.isOpen)) {
            this.props.getWorkspacesMetadata();

            if(this.state.workspaceId) {
                this.props.getWorkspace(this.state.workspaceId);
            }
        }
    }